Skip to content

Components

Table

A native data table with header, footer, caption, numeric columns and selected rows.

Customize
Ombelle · light

Installation

Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.

pnpm dlx @ombelle-ui/cli@1.1.2 add table

Adds components/ui/table.tsx and installs react, clsx, tailwind-merge, lucide-react with lifecycle scripts disabled.

In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.

Usage

example.tsx
import {
  Table, TableCaption, TableHeader, TableBody, TableRow, TableHead, TableCell,
} from '@/components/ui/table'

export function Projects() {
  return (
    <Table>
      <TableCaption>Projects and their owners.</TableCaption>
      <TableHeader>
        <TableRow><TableHead>Project</TableHead><TableHead numeric>Components</TableHead></TableRow>
      </TableHeader>
      <TableBody>
        <TableRow><TableCell>Website refresh</TableCell><TableCell numeric>12</TableCell></TableRow>
      </TableBody>
    </Table>
  )
}

// A denser list for application screens.
export function CompactProjects() {
  return (
    <Table density="compact" striped>
      <TableCaption>Compact project list</TableCaption>
      <TableHeader>
        <TableRow><TableHead>Project</TableHead><TableHead>Status</TableHead></TableRow>
      </TableHeader>
      <TableBody>
        <TableRow><TableCell>Website</TableCell><TableCell>Active</TableCell></TableRow>
        <TableRow><TableCell>Mobile</TableCell><TableCell>Review</TableCell></TableRow>
      </TableBody>
    </Table>
  )
}

API and states

API
Table (density: default, compact; striped, stickyHeader, maxBlockSize, loading), TableCaption, TableHeader, TableBody, TableFooter, TableRow (selected), TableHead (numeric, scope, sort, onSort, actions), TableCell (numeric, actions), TableSkeletonRows (rows, columns)
Minimum states
Default, compact, striped rows, selected row, numeric column
Native basis
Native <table> in a horizontal scroll container
Styles
Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.