Layout
Center
Centre content on both axes, with optional spacing between children.
Purpose
Center is a flex container that centres its children horizontally and vertically by default —
empty states, loading indicators, hero content.
Import
import { Center } from "@neshel-ui/layout";Usage
Preview: center-basic
No projects yet
Create your first project to get started.
import { Button } from "@neshel-ui/components";
import { Center, Stack } from "@neshel-ui/layout";
import { Heading, Paragraph } from "@neshel-ui/typography";
/** Centered content: an empty state centred on both axes inside a fixed-height region. */
export default function CenterBasic() {
return (
<Center className="min-h-56 rounded-lg border border-dashed border-[var(--neshel-border)]">
<Stack space="3" alignX="center">
<Heading as="h3" size="lg">
No projects yet
</Heading>
<Paragraph tone="muted" size="sm">
Create your first project to get started.
</Paragraph>
<Button size="sm">New project</Button>
</Stack>
</Center>
);
}API
CenterProps
| Prop | Type | Default | Description |
|---|---|---|---|
| align | Responsive<MainAxisAlign> | — | — |
| alignX | Responsive<MainAxisAlign> | — | — |
| alignY | Responsive<CrossAxisAlign> | — | — |
| as | LayoutElement | — | — |
| asChild | boolean | — | — |
| ref | Ref<HTMLElement> | — | — |
| space | Responsive<SpaceValue> | — | — |
| spaceX | Responsive<SpaceValue> | — | — |
| spaceY | Responsive<SpaceValue> | — | — |
Also accepts the props of: React DOM attributes.
alignX / alignY override the defaults (center). Vertical centring needs the Center to be taller
than its content — give it a height (min-h-*) or place it in a stretching parent.
Common mistakes
- Expecting vertical centring in an auto-height Center: there is no free space to distribute.
- Using Center to centre a page column: that is
Container.