Search

Jump to any page.

Data display

Table

Editorial table with small-caps headers and hairline rows.

CauseVolumeStatusActions
Plan changes bill customers twiceBilling
412Fix drafted
OTP texts delayed on one operatorIdentity
268Investigating
Arabic statements cut off after 40 charactersStatements
97New
Card freeze needs a branch visitCards
64Resolving
pnpm dlx shadcn@latest add @paragon/table
Brings incn
registry/paragon/ui/table.tsx
import * as React from "react"
import { cn } from "cn"

/**
 * Plain, editorial tables: small-caps headers, hairline rows, generous cells.
 * Wrap in a card (bg-card rounded-card ring-1 ring-border) when it stands alone.
 * Right-align numbers with `text-end tabular-nums`.
 */
function Table({ className, ...props }: React.ComponentProps<"table">) {
  return (
    <div data-slot="table-container" className="relative w-full overflow-x-auto">
      <table data-slot="table" className={cn("w-full caption-bottom text-[0.9375rem]", className)} {...props} />
    </div>
  )
}

function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
  return <thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:hover:bg-transparent", className)} {...props} />
}

function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
  return <tbody data-slot="table-body" className={cn("[&_tr:last-child]:border-0", className)} {...props} />
}

function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
  return (
    <tfoot
      data-slot="table-footer"
      className={cn("border-t bg-foreground/[0.025] font-medium [&>tr]:last:border-b-0", className)}
      {...props}
    />
  )
}

function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
  return (
    <tr
      data-slot="table-row"
      className={cn(
        "border-b transition-colors duration-(--duration-fast) hover:bg-foreground/[0.025] has-aria-expanded:bg-foreground/[0.025] data-[state=selected]:bg-foreground/5",
        className
      )}
      {...props}
    />
  )
}

function TableHead({ className, ...props }: React.ComponentProps<"th">) {
  return (
    <th
      data-slot="table-head"
      className={cn(
        "h-10 px-3 text-start align-middle text-[0.6875rem] font-medium tracking-[0.08em] whitespace-nowrap text-muted-foreground uppercase first:ps-4 last:pe-4 [&:has([role=checkbox])]:pe-0",
        className
      )}
      {...props}
    />
  )
}

function TableCell({ className, ...props }: React.ComponentProps<"td">) {
  return (
    <td
      data-slot="table-cell"
      className={cn(
        "px-3 py-3 align-middle whitespace-nowrap first:ps-4 last:pe-4 [&:has([role=checkbox])]:pe-0",
        className
      )}
      {...props}
    />
  )
}

function TableCaption({ className, ...props }: React.ComponentProps<"caption">) {
  return <caption data-slot="table-caption" className={cn("mt-4 text-caption text-muted-foreground", className)} {...props} />
}

export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption }