- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
A box that centers its children on both axes, stretched or kept to its content's width, with its element swappable through render.
Installation#
pnpm dlx shadcn@latest add @zui/centerThe CLI writes components/layout/center.tsx, installs Utils, and adds class-variance-authority.
Usage#
import { Center } from '@/components/layout/center';<Center className="h-32">
<Text>Centered content</Text>
</Center>The centring is fixed, unlike a plain View: reach for flex-row items-center justify-center directly when the
caller needs to change the alignment itself. Its text goes in a Text, as any
View's does.
API reference#
Center#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
inline | boolean | false |
render | ReactElement | ((props, state) => ReactElement) | - |
It lays its children out in a row, as the web's flex box does. Size, spacing and placement (h-32, gap-2) come
from className; inline keeps the box to its content's width rather than stretching across its parent.
render draws its element in place of the View, such as a <Pressable />, given Center's props under its own and
its classes after Center's; a function is called with those props and { slot: 'center' }. The element's
semantics are then the caller's.
centerVariants#
The inline variant: false (the default) renders flex, true renders flex self-start.
Differences from the web#
- A device has no inline flow, so
inlinekeeps the box to its content's width, which is what the web'sinline-flexchanges in a block, instead of placing it in a line of text.