Skip to content
All components
Data display

Table

Present records whose row and column relationships matter, using native table semantics so every value can be read with its headers.

A scrollable data table with a sticky-looking header row.

Installation

tdpxl is not an npm dependency of your app. The @tdpxl/cli command (not published to npm yet) copies the source into your project, with the registry items and npm packages it imports.

npx @tdpxl/cli add table

Then import it from @/components/ui/table. New project? Start with the installation guide.

Examples

Each example is one branch of the official demo, rendered in its own frame. The code is that branch as you would write it, with imports pointing at the default install paths.

Row headers

Use row headers when the first column names each row. Header cells with row and column scope let assistive technology announce both headers for every value. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const plans = [
  { feature: "Projects", starter: "3", team: "Unlimited", enterprise: "Unlimited" },
  { feature: "Members", starter: "1", team: "Up to 50", enterprise: "Unlimited" },
  { feature: "File history", starter: "7 days", team: "90 days", enterprise: "1 year" },
  { feature: "Single sign-on", starter: "Not included", team: "Not included", enterprise: "Included" },
]

export function TableRowHeaders() {
  return (
    <div className="flex w-full max-w-2xl flex-col gap-10">
      <div className="w-full max-w-xl">
        <Table>
          <TableCaption>Plan comparison. Each row is a feature; each column is a plan.</TableCaption>
          <TableHeader>
            <TableRow>
              <TableHead scope="col">Feature</TableHead>
              <TableHead scope="col">Starter</TableHead>
              <TableHead scope="col">Team</TableHead>
              <TableHead scope="col">Enterprise</TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            {plans.map((plan) => (
              <TableRow key={plan.feature}>
                <TableHead scope="row" className="bg-transparent text-label-sm text-strong-950">
                  {plan.feature}
                </TableHead>
                <TableCell>{plan.starter}</TableCell>
                <TableCell>{plan.team}</TableCell>
                <TableCell>{plan.enterprise}</TableCell>
              </TableRow>
            ))}
          </TableBody>
        </Table>
      </div>
    </div>
  )
}

Horizontal scroll

Scroll a wide table inside its own focusable region. The page keeps its width while the table scrolls sideways with the keyboard or touch. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const shipments = [
  { id: "SHP-2041", origin: "Rotterdam", destination: "Lisbon", carrier: "Road", weight: "1,240 kg", departed: "2026-11-02", eta: "2026-11-05", status: "Delivered" },
  { id: "SHP-2042", origin: "Hamburg", destination: "Vienna", carrier: "Rail", weight: "860 kg", departed: "2026-11-04", eta: "2026-11-07", status: "In transit" },
  { id: "SHP-2043", origin: "Valencia", destination: "Lyon", carrier: "Road", weight: "2,015 kg", departed: "2026-11-06", eta: "2026-11-08", status: "Delayed" },
]

export function TableHorizontalScroll() {
  return (
    <div className="flex w-full max-w-2xl flex-col gap-10">
      <div className="w-full max-w-sm">
        <Table>
          <TableCaption>Shipments this week. Scroll the table sideways to see every column.</TableCaption>
          <TableHeader>
            <TableRow>
              <TableHead scope="col">Shipment</TableHead>
              <TableHead scope="col">Origin</TableHead>
              <TableHead scope="col">Destination</TableHead>
              <TableHead scope="col">Mode</TableHead>
              <TableHead scope="col" className="text-right">Weight</TableHead>
              <TableHead scope="col">Departed</TableHead>
              <TableHead scope="col">Arrives</TableHead>
              <TableHead scope="col">Status</TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            {shipments.map((shipment) => (
              <TableRow key={shipment.id}>
                <TableHead scope="row" className="bg-transparent font-mono text-label-sm text-strong-950">
                  {shipment.id}
                </TableHead>
                <TableCell className="whitespace-nowrap">{shipment.origin}</TableCell>
                <TableCell className="whitespace-nowrap">{shipment.destination}</TableCell>
                <TableCell>{shipment.carrier}</TableCell>
                <TableCell className="text-right whitespace-nowrap tabular-nums">{shipment.weight}</TableCell>
                <TableCell className="whitespace-nowrap">
                  <time dateTime={shipment.departed}>{shipment.departed}</time>
                </TableCell>
                <TableCell className="whitespace-nowrap">
                  <time dateTime={shipment.eta}>{shipment.eta}</time>
                </TableCell>
                <TableCell className="whitespace-nowrap">{shipment.status}</TableCell>
              </TableRow>
            ))}
          </TableBody>
        </Table>
      </div>
    </div>
  )
}

Empty result

Explain an empty result inside the table body. Column headers stay visible and a single row spans every column with the message. Preserves the complete example's required parts, labels and providers. The example's local state remains owned by that composition.

"use client"

import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

export function TableEmptyResult() {
  return (
    <div className="flex w-full max-w-2xl flex-col gap-10">
      <div className="w-full max-w-lg">
        <Table>
          <TableCaption>Refunds from the last 30 days.</TableCaption>
          <TableHeader>
            <TableRow>
              <TableHead scope="col">Refund</TableHead>
              <TableHead scope="col">Invoice</TableHead>
              <TableHead scope="col" className="text-right">Amount</TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            <TableRow className="hover:bg-transparent">
              <TableCell colSpan={3} className="py-8 text-center text-sub-600">
                No refunds in this period. Refunds appear here after they are issued.
              </TableCell>
            </TableRow>
          </TableBody>
        </Table>
      </div>
    </div>
  )
}

API reference

Generated from the component's TypeScript signatures. Inherited DOM and primitive props are listed separately.

Table

Present data whose row and column relationships matter.

Table props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
Table inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLTableElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLTableElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLTableElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLTableElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLTableElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLTableElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLTableElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

TableBody

The TableBody part of table. Use it with the complete source composition and preserve its required parent context.

TableBody props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
TableBody inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLTableSectionElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLTableSectionElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLTableSectionElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLTableSectionElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLTableSectionElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLTableSectionElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLTableSectionElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

TableCaption

The TableCaption part of table. Use it with the complete source composition and preserve its required parent context.

TableCaption props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
TableCaption inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

TableCell

The TableCell part of table. Use it with the complete source composition and preserve its required parent context.

TableCell props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
TableCell inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLTableDataCellElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLTableDataCellElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLTableDataCellElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLTableDataCellElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLTableDataCellElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLTableDataCellElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLTableDataCellElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

TableFooter

Footer layout for supporting content or actions; consumers own the actions and their outcomes.

TableFooter props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
TableFooter inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLTableSectionElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLTableSectionElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLTableSectionElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLTableSectionElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLTableSectionElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLTableSectionElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLTableSectionElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

TableHead

The TableHead part of table. Use it with the complete source composition and preserve its required parent context.

TableHead props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
TableHead inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLTableHeaderCellElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLTableHeaderCellElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLTableHeaderCellElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLTableHeaderCellElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLTableHeaderCellElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLTableHeaderCellElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLTableHeaderCellElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

TableHeader

Header layout for related title and description content; it does not add application workflow behavior.

TableHeader props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
TableHeader inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLTableSectionElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLTableSectionElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLTableSectionElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLTableSectionElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLTableSectionElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLTableSectionElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLTableSectionElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

TableRow

The TableRow part of table. Use it with the complete source composition and preserve its required parent context.

TableRow props
PropTypeDefaultDescription
inputMode"search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined—Hints at the type of data that might be entered by the user while editing the element or its contents
aria-describedbystring | undefined—Identifies the element (or elements) that describes the object.
aria-invalidboolean | "false" | "true" | "grammar" | "spelling" | undefined—Indicates the entered value does not conform to the format expected by the application.
aria-labelstring | undefined—Defines a string value that labels the current element.
aria-labelledbystring | undefined—Identifies the element (or elements) that labels the current element.
childrenReact.ReactNode—Represents all of the things React can render.
Inherited props (13)
TableRow inherited props
PropTypeDefaultDescription
refReact.Ref<HTMLTableRowElement> | undefined—Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
defaultCheckedboolean | undefined—Initial checked state for a control supporting uncontrolled selection. Inherited DOM typing does not give a layout wrapper checkbox behavior.
defaultValuestring | number | readonly string[] | undefined—Initial value for a control supporting uncontrolled state. Inherited DOM typing alone does not give a layout wrapper input behavior.
autoFocusboolean | undefined—Request automatic focus when the element mounts or the primitive opens, according to its source behavior. Choose initial focus deliberately in context.
classNamestring | undefined—Additional classes for this part. Preserve contrast, visible focus and responsive content when adapting styles.
idstring | undefined—Stable DOM identifier used by labels, descriptions or other explicit associations.
roleReact.AriaRole | undefined—Semantic role appropriate to the rendered element. Preserve required relationships and keyboard behavior.
onFocusReact.FocusEventHandler<HTMLTableRowElement> | undefined—Receive the native focus event. Preserve the component's existing keyboard and focus behavior.
onBlurReact.FocusEventHandler<HTMLTableRowElement> | undefined—Receive the native blur event when focus leaves this control.
onChangeReact.ChangeEventHandler<HTMLTableRowElement, Element> | undefined—Receive the native change event; read the actual control value or checked state from its event target.
onKeyDownReact.KeyboardEventHandler<HTMLTableRowElement> | undefined—Receive keyboard events. Preserve built-in keyboard behavior unless deliberately implementing an accessible alternative.
onClickReact.MouseEventHandler<HTMLTableRowElement> | undefined—Receive activation events. The consumer owns the action performed and its result.
onSelectReact.ReactEventHandler<HTMLTableRowElement> | undefined—Handle the selection event defined by this part's source signature. DOM text-selection events differ from menu or command activation callbacks.

Accessibility & usage

From registry/ui/table.meta.json (authored guidance; human review may still be pending). Behavior is checked by Storybook tests, not certified here.

When to use

  • Display a modest, already-ordered set of records that people read or compare across the same columns.
  • Show a comparison matrix where the first column names each row (plans by feature, regions by month) using row headers.
  • Render static or server-rendered data where sorting, filtering and pagination are not needed or are handled elsewhere.
  • Build a custom data grid layout on top of semantic table parts (DataTable itself is composed from them).

When not to use

  • Users need to sort, filter, page or select rows in the browser; use DataTable, which wires those states to the same markup.
  • Page layout or visual alignment of non-tabular content; tables used for layout break reading order and reflow.
  • A list of objects with one or two fields each, or rich content per object; an item list or cards read better, especially on mobile.
  • Editable spreadsheet-like grids with cell-level keyboard navigation; that is an ARIA grid pattern this component does not implement.

Anatomy

Table
A native table inside a container that scrolls horizontally and is keyboard focusable (tabIndex 0). Props go to the table element, not the container.
TableCaption
The native caption: the table's accessible name, shown below the table.
TableHeader
The thead with the column header row.
TableBody
The tbody with the data rows.
TableFooter
The tfoot for totals or summaries.
TableRow
A tr with a hover tint and a data-state=selected appearance hook.
TableHead
A th; set scope="col" for column headers and scope="row" for row headers in the body.
TableCell
A td for one value.

Keyboard & interaction

  • The table is read, not operated: screen readers move by cell with table navigation commands and announce the column (and row) header for each value.
  • The scroll container is focusable so keyboard users can scroll a wide table with the arrow keys; Tab then continues to the next control (WCAG 2.1.1).
  • Row hover is a visual aid only; rows are not focusable and do not activate. Put links or buttons inside cells for actions, one primary action per row.
  • Sorting, selection and filtering are not built in; when you add them, expose state on the header (aria-sort) and on real controls, or use DataTable.

Responsive behavior

  • Wide tables scroll horizontally inside their wrapper so the page itself reflows at 320 CSS pixels (WCAG 1.4.10 allows two-dimensional scrolling for data tables).
  • Keep the first column meaningful (an identifier or name) so the row stays identifiable while scrolling sideways; prefer row headers for it.
  • At narrow widths, remove low-value columns or offer a details view instead of shrinking text; do not convert rows to cards with CSS alone, which loses header relationships.
  • Avoid wrapping short values like dates, amounts and identifiers (whitespace-nowrap) and let long descriptive text wrap.

Content guidelines

  • Write a caption that names the data and its scope ('Invoices from the last 30 days'); visually hide it only when a visible heading already says the same.
  • Use short, specific column headers in sentence case; include units in the header ('Weight (kg)') rather than in every cell.
  • Right-align numbers and amounts and use tabular figures so digits line up; left-align text.
  • Format dates and numbers consistently for the locale; use a time element when the exact date matters.
  • For no data, keep the headers and show one row spanning all columns that explains why it is empty and what to do next.
  • Put status in words (Paid, Pending, Failed); a badge color can reinforce it but must not replace it.

Alternatives

  • Data table — Sorting, filtering, pagination, selection and column visibility on top of the same table parts.
  • Item — A compact list of objects where columns would be mostly empty or not compared.
  • Card — A few heterogeneous objects, each with its own title and actions.

Resources