# Center

Centers content on one or both axes with responsive structural sizing.

`Center` places content on the horizontal axis, vertical axis, or both. It can also define the region's size and responsive logical padding.

```tsx
import { Badge, Center } from "@zentara-co/zenos-ui";

function CenterExample() {
  return (
    <Center
      minHeight="24"
      padding="4"
      className="w-full max-w-xl rounded-xl border border-border bg-background-neutral-card"
    >
      <Badge variant="default" color="information">
        Centered on both axes
      </Badge>
    </Center>
  );
}
```

## Import

```tsx
import { Center } from "@zentara-co/zenos-ui";
```

## Axis

Choose only the axis the component should control. `both` is the default.

```tsx
import { Center, Grid, Text } from "@zentara-co/zenos-ui";

function CenterAxisExample() {
  const axes = ["both", "horizontal", "vertical"] as const;

  return (
    <Grid columns={{ base: 1, md: 3 }} gap="4" className="w-full">
      {axes.map((axis) => (
        <Center
          key={axis}
          axis={axis}
          minHeight="24"
          padding="3"
          className="rounded-xl border border-border bg-background-neutral-card"
        >
          <Text weight="bold" className="capitalize">
            {axis}
          </Text>
        </Center>
      ))}
    </Grid>
  );
}
```

## Sizing and logical padding

Size tokens constrain the centering region. Padding uses logical inline and block directions so layouts adapt to writing direction.

```tsx
import { Center, Stack, Text } from "@zentara-co/zenos-ui";

function CenterSizingExample() {
  return (
    <Stack gap="4" className="w-full">
      <Center
        axis="horizontal"
        maxWidth="lg"
        paddingInline={{ base: "4", md: "8" }}
        paddingBlock="4"
        className="mx-auto w-full rounded-xl border border-border bg-background-neutral-card"
      >
        <Text align="center">Horizontally centered inside a constrained region.</Text>
      </Center>
      <Center
        isInline
        paddingInline="4"
        paddingBlock="2"
        className="rounded-full border border-border bg-background-neutral-card"
      >
        <Text size="s">Inline center</Text>
      </Center>
    </Stack>
  );
}
```

Use `isScrollable` only when the centered region has a meaningful size constraint. When content may exceed the available height, test zoom and large text to ensure it remains reachable.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | ElementType | div | Rendered semantic element. |
| axis | both \| horizontal \| vertical | both | Axes on which content is centered. |
| isInline | boolean | false | Uses inline-flex instead of flex. |
| padding* | Responsive<Spacing> | — | Logical responsive padding props. |
| width / height / maxWidth / minHeight | SizeToken | — | Structural size constraints. |
| isScrollable | boolean | false | Allows centered content to scroll when it exceeds the region. |
| native props | React.HTMLAttributes<HTMLElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Center does not change semantics. Choose `as` for the region's meaning and avoid vertically centering long reading content in a fixed-height box, which can make overflow difficult to reach at high zoom.

Source: https://zenos-ui.pages.dev/layout/center/