Table
A structured data display component with rows, columns, headers, and optional footer and caption.
The Table component displays structured data in rows and columns. It supports horizontal scrolling for wide tables, a compound component API with header, body, footer, and caption parts, and is styled with NativeWind for consistent appearance across platforms.
Preview
Installation
npx novaui-cli add tableImport
import {
Table,
TableHeader,
TableBody,
TableFooter,
TableHead,
TableRow,
TableCell,
TableCaption,
} from 'novaui-components'Basic Usage
The Table is a compound component with these parts:
Table- Root container with horizontal scroll supportTableHeader- Container for header rowsTableBody- Container for data rowsTableFooter- Optional footer row (e.g. totals)TableRow- A single rowTableHead- Header cell with muted stylingTableCell- Data cellTableCaption- Optional caption below the table
import {
Table,
TableHeader,
TableBody,
TableRow,
TableHead,
TableCell,
} from 'novaui-components'
const invoices = [
{ id: 'INV001', status: 'Paid', amount: '$250.00' },
{ id: 'INV002', status: 'Pending', amount: '$150.00' },
]
export function BasicTable() {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.id}>
<TableCell className="font-medium">{invoice.id}</TableCell>
<TableCell>{invoice.status}</TableCell>
<TableCell className="text-right">{invoice.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
}With Footer
Add a footer row for totals or summaries:
<Table>
<TableHeader>
<TableRow>
<TableHead>Item</TableHead>
<TableHead className="text-right">Price</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>Design System</TableCell>
<TableCell className="text-right">$99.00</TableCell>
</TableRow>
<TableRow>
<TableCell>Component Library</TableCell>
<TableCell className="text-right">$149.00</TableCell>
</TableRow>
</TableBody>
<TableFooter>
<TableRow>
<TableCell className="font-medium">Total</TableCell>
<TableCell className="text-right font-medium">$248.00</TableCell>
</TableRow>
</TableFooter>
</Table>With Caption
Add a descriptive caption to the table:
<Table>
<TableCaption>A list of recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell className="font-medium">INV001</TableCell>
<TableCell>Paid</TableCell>
<TableCell className="text-right">$250.00</TableCell>
</TableRow>
</TableBody>
</Table>Props API
Table Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
The Table wraps content in a horizontal ScrollView for wide table support.
TableHeader Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
TableBody Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
TableFooter Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
TableRow Props
Extends React.ComponentPropsWithoutRef<typeof Pressable>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
Rows use Pressable and support active:bg-muted/50 for press feedback.
TableHead Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes. Use text-right or text-center for alignment. |
TableCell Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes. Use text-right or text-center for alignment. |
TableCaption Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
Best Practices
-
Use flex-row for columns: Each
TableRowusesflex-row— give cellsflex-1or fixed widths for consistent columns -
Right-align numbers: Use
className="text-right"onTableHeadandTableCellfor numeric columns -
Footer for totals: Use
TableFooterfor sum rows — it hasbg-muted/50background to distinguish from data -
Horizontal scroll: The
Tablecomponent wraps in a horizontalScrollView— wide tables scroll naturally on small screens -
Caption for context: Add
TableCaptionwhen the table needs a descriptive label
Related Components
- Use
Cardto wrap tables for a bordered container look - Use
Paginationbelow tables for paginated data sets - Use
Skeletonfor table loading states