- Accordion
- Action BarUpdated
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- BadgeUpdated
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- CalendarUpdated
- CardUpdated
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context MenuUpdated
- Data List
- Date Picker
- DialogUpdated
- DrawerUpdated
- Editable
- FieldUpdated
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- MarqueeUpdated
- Menu
- Native Select
- Number InputUpdated
- Pagination
- Popover
- Progress
- Prose
- QR Code
- Radio Group
- Rating
- Resizable
- Scroll Area
- Segment Group
- Select
- Separator
- Sheet
- Sidebar
- Signature Pad
- Skeleton
- Skip Nav
- Slider
- Spinner
- Status
- Steps
- Switch
- TableUpdated
- Tabs
- Textarea
- TimerUpdated
- ToastUpdated
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
Table
A responsive table component.
| Name | Role | Status | |
|---|---|---|---|
| Alice Johnson | alice.johnson@example.com | Admin | active |
| Bruno Silva | bruno.silva@example.com | Editor | invited |
| Clara Mendes | clara.mendes@example.com | Viewer | inactive |
| David Park | david.park@example.com | Editor | active |
Installation#
pnpm dlx shadcn@latest add @shark/table
Anatomy#
Table ├── TableCaption ├── TableHeader │ └── TableRow │ └── TableHead ├── TableBody │ └── TableRow │ └── TableCell └── TableFooter └── TableRow └── TableCell
Usage#
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow, TableFooter, } from "@/components/ui/table";
<Table> <TableCaption /> <TableHeader> <TableRow> <TableHead /> <TableHead /> </TableRow> </TableHeader> <TableBody> <TableRow> <TableCell /> <TableCell /> </TableRow> </TableBody> <TableFooter /> </Table>
Accessibility#
Always use a TableCaption to help assistive technologies announce what the table represents.
Use with the sr-only class to make the caption screen-reader only if you don't want to show it.
<Table> <TableCaption className="sr-only"> Monthly revenue by product. </TableCaption> {/* ... */} </Table>
Examples#
Striped#
Use variant="striped" on Table for alternating row backgrounds.
| Name | Role | Status | |
|---|---|---|---|
| Alice Johnson | alice.johnson@example.com | Admin | Active |
| Bruno Silva | bruno.silva@example.com | Editor | Invited |
| Clara Mendes | clara.mendes@example.com | Viewer | Inactive |
| David Park | david.park@example.com | Editor | Active |
With footer#
Use TableFooter for summary rows, totals, or notes.
| Item | Qty | Unit price | Amount |
|---|---|---|---|
| Wireless mouse | 2 | $29.99 | $59.98 |
| Mechanical keyboard | 1 | $149.99 | $149.99 |
| USB-C hub | 3 | $45.00 | $135.00 |
| Total | $379.47 | ||
With actions#
Add an actions column with buttons per row.
| Name | Actions | |
|---|---|---|
| Alice Johnson | alice@example.com | |
| Bruno Silva | bruno@example.com | |
| Clara Mendes | clara@example.com |
With action bar#
Use checkboxes for row selection and an action bar that appears when one or more rows are selected. See the action bar component.
| ID | Name | Status | Amount | |
|---|---|---|---|---|
| SO-01 | Macbook Pro 16 | progress | 245,12 $ | |
| SO-02 | Apple Watch Series 9 | transit | 122,18 $ | |
| SO-03 | AirPods Max | pending | 89,50 $ | |
| SO-04 | iPad Pro 13 | pending | 310,00 $ | |
| SO-05 | iPhone 15 Pro Max | transit | 156,75 $ |
With context menu#
Wrap each row with ContextMenuTrigger so right-clicking shows a context menu with row actions.
| Name | |
|---|---|
| Alice Johnson | alice@example.com |
| Bruno Silva | bruno@example.com |
| Clara Mendes | clara@example.com |
Disable row hover#
Set isHoverable={false} on Table to disable the hover background on body rows.
| Name | |
|---|---|
| Alice Johnson | alice@example.com |
| Bruno Silva | bruno@example.com |
| Clara Mendes | clara@example.com |
API Reference#
Table#
Scrollable wrapper around a native table. Supports striped and hover variants.
| Prop | Type | Default |
|---|---|---|
variant | "plain" | "striped" | "plain" |
isHoverable | boolean | true |
className | string | - |
asChild | boolean | false |
TableHeader#
Table header row group.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
TableBody#
Table body row group.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
TableFooter#
Table footer row group for totals or summary rows.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
TableRow#
A single table row.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
TableHead#
Header cell for column titles.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
TableCell#
Data cell for body or footer rows.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
TableCaption#
Accessible caption describing the table. Use sr-only for screen-reader only.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |