Start here
  • InstallationAdd Nelumbo to a shadcn project
  • ThemingBrand accent, neutrals, dynamic color
  • Biology componentsSequences, maps, plates and trees
  • katalyx.bio

    Table

    Rows and columns for comparing things. The same parts as shadcn's Table in a rounded, soft-headed container that scrolls sideways on small screens. For sorting, search, selection and paging, see Data Table.

    Install

    npx shadcn@latest add @nelumbo/table

    Invoices

    A header surface and faint row dividers do the work of borders. Rows light up on hover, and the selected row is filled in (data-state="selected"). Numbers are right-aligned with tabular figures.

    Invoices issued in May.
    InvoiceClientStatusMethodAmount
    INV-2041Northwind StudioPaidCard$2,450.00
    INV-2042Fernhill CoffeePendingBank transfer$380.50
    INV-2043Lumen ArchitectsPaidCard$12,900.00
    INV-2044Okafor and DaughtersOverdueBank transfer$1,175.25
    INV-2045Tidewater BooksPaidPayPal$640.00
    INV-2046Paper Moon PressPendingCard$89.99
    Total$17,635.74

    Compact

    density="compact" tightens rows from 56px to 40px, for tables that carry a lot of data.

    Invoices issued in May.
    InvoiceClientStatusMethodAmount
    INV-2041Northwind StudioPaidCard$2,450.00
    INV-2042Fernhill CoffeePendingBank transfer$380.50
    INV-2043Lumen ArchitectsPaidCard$12,900.00
    INV-2044Okafor and DaughtersOverdueBank transfer$1,175.25
    INV-2045Tidewater BooksPaidPayPal$640.00
    INV-2046Paper Moon PressPendingCard$89.99
    Total$17,635.74

    stickyHeader keeps the header in view while the body scrolls. Give the container a height with containerClassName.

    Invoices issued in May.
    InvoiceClientStatusMethodAmount
    INV-2041Northwind StudioPaidCard$2,450.00
    INV-2042Fernhill CoffeePendingBank transfer$380.50
    INV-2043Lumen ArchitectsPaidCard$12,900.00
    INV-2044Okafor and DaughtersOverdueBank transfer$1,175.25
    INV-2045Tidewater BooksPaidPayPal$640.00
    INV-2046Paper Moon PressPendingCard$89.99
    Total$17,635.74

    Usage

    import {  Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow,} from "@/components/ui/table"​<Table density="compact">  <TableCaption>Invoices issued in May.</TableCaption>  <TableHeader>    <TableRow>      <TableHead>Invoice</TableHead>      <TableHead className="text-end">Amount</TableHead>    </TableRow>  </TableHeader>  <TableBody>    {invoices.map((i) => (      <TableRow key={i.id} data-state={i.id === selected ? "selected" : undefined}>        <TableCell className="font-medium">{i.id}</TableCell>        <TableCell className="text-end tabular-nums">{money.format(i.amount)}</TableCell>      </TableRow>    ))}  </TableBody></Table>

    Accessibility

    Real table elements, so screen readers announce rows and columns. Use TableCaption (or aria-label) to name the table. While the table overflows its container, the container can take focus, so keyboard users can scroll it with the arrow keys. For sortable columns, set aria-sort on the TableHead; Data Table does this for you.

    Props

    PropTypeDefaultNotes
    Table density"comfortable" | "compact""comfortable"Row height: 56px or 40px
    Table stickyHeaderbooleanfalseHeader stays while the body scrolls; needs a container height
    Table containerClassNamestringClasses for the scroll container, such as max-h-96
    Table classNamestringClasses for the <table>, such as min-w-max
    TableRow data-state"selected"Fills the row
    TableHead / TableCellth / td propsPadding follows the density; checkbox cells narrow themselves
    TableHeader, TableBody, TableFooter, TableCaptionAs in shadcn