Center
Centres a block on one or both axes. Add a max-width to keep prose at a readable measure.
Install
Install the component
Add the source straight into your project with the shadcn CLI — no package dependency to track.
npx shadcn@latest add https://vert-ui.dev/r/center.jsonPreview
Live preview
Centred on both axes
Usage
Examples
Readable prose column
Centred, measured prose.
<Center maxWidth="46rem" padded>
<p>Long-form copy stays centred and readable…</p>
</Center>Horizontal centring only
axis="horizontal"
<Center axis="horizontal">
<Button>Saved</Button>
</Center>Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| axis | "both" | "horizontal" | "vertical" | "both" | Which axes to centre on. Horizontal keeps the natural height. |
| maxWidth | string | — | Caps the content measure — a comfortable line length. Any CSS length. |
| padded | boolean | false | Adds responsive horizontal gutters so edge content never touches the viewport. |
| asChild | boolean | false | Render the child element instead of a div. |
Accessibility
Accessibility notes
- Purely presentational flex container; choose a meaningful element with asChild (main, figure, section) rather than relying on it for structure.
- A max-width measure keeps line length in the 45–75 character range, which aids readers with low vision or dyslexia.
- padded keeps centred content from touching the viewport edge down to 320px.