- 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
Installation#
pnpm dlx shadcn@latest add @zui/tableThe CLI writes components/ui/table.tsx, installs Text and Utils, and
adds @rn-primitives/table.
Usage#
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from '@/components/ui/table';
import { Text } from '@/components/ui/text';<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead>
<Text>Invoice</Text>
</TableHead>
<TableHead className="items-end">
<Text>Amount</Text>
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>
<Text>INV001</Text>
</TableCell>
<TableCell className="items-end">
<Text>250.00</Text>
</TableCell>
</TableRow>
</TableBody>
</Table>API reference#
Table#
Takes every prop of the @rn-primitives/table root. It is announced as a table, inside a box that scrolls
sideways when the table is wider than the box; give a wide table a minimum width, such as min-w-[640px].
Every Text inside is small. A TableCaption is drawn below the rows wherever it is placed.
TableHeader, TableBody, TableFooter#
Each takes every prop of its @rn-primitives/table part and is announced as a row group. The last row of a
TableBody or a TableFooter has no border under it. TableFooter draws a muted band in the medium weight.
TableRow#
Takes every prop of the @rn-primitives/table row, a Pressable announced as a row. Pass onPress to make it
take a press, and aria-selected to draw it on the muted background and announce it as selected. A row with
no onPress lets a screen reader reach each cell, and a control in one, on its own; a row with onPress is a
single element, so put no control in its cells, or pass accessible={false}.
TableHead, TableCell#
Each takes every prop of its @rn-primitives/table part. TableHead is announced as a column header, its Text
in the foreground colour and medium weight; TableCell is announced as a cell. The cells of a row share its
width equally and centre their content vertically. Give a cell items-end to align it right, a flex-[2] to
take twice the width, or a fixed width such as w-24; give the cells of one column the same width in every
row so the column lines up.
TableCaption#
Takes every prop of Text, muted.
Differences from upstream#
- A browser sizes a table's columns from the content of every row. React Native has no table layout, so the rows are rows of views and the cells share each row's width; to line a column up, give its cells the same width or flex in every row.
- Upstream marks a selected row with
data-state="selected". The native row takesaria-selected, which also announces it. - Upstream colours a row when hovered. A touch screen has no hover, and the native row draws no pressed colour.
- Upstream keeps a header or a cell on one line. A native Text wraps unless given
numberOfLines.