Center
Center children on one or both axes without writing the flex classes again.
No deploys yet
Push to main to trigger the first one.
Installation
pnpm dlx nachui add centerAnatomy
Center is a flex container with items-center and justify-center. Give it a height, or let it fill a parent that has one, and whatever is inside sits in the middle. Add flex-col and gap-* through className when there are several children.Examples
Default
An empty state centered in a card.
text also centers the text inside.No deploys yet
Push to main to trigger the first one.
Axis
axis limits centering to one direction.both
axis="both"horizontal
axis="horizontal"vertical
axis="vertical"API Reference
Center
| Prop | Type | Default | Description |
|---|---|---|---|
axis | 'both' | 'horizontal' | 'vertical' | 'both' | Which axes to center on |
inline | boolean | false | Use inline-flex instead of flex |
text | boolean | false | Also apply text-center |
as | React.ElementType | 'div' | Element to render |
className | string | - | Additional CSS classes |
Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.