Clinia UI

Table

Rows and columns of data to scan and compare.

shadcn docs →

When to use

  • Rows of records to scan and compare across the same columns: sources, API keys, clinicians.
  • Read-only data where each row has the same shape.

When not to use

  • Users filter, sort, or select rows to act on them: use Data Table, which adds selection to Table.
  • A few items with an image, a description and actions: use Item.
  • Page layout or a form: use CSS grid or Field. A table is for data only.

Install

npx shadcn@latest add @clinia/table
IDNameStatusLast visit
P-001Jane CooperActiveJun 3, 2025
P-002Floyd MilesInactiveMay 20, 2025
P-003Ronald RichardsActiveJun 4, 2025

Anatomy

Sources in Montreal clinic.
SourceRecords
Lab results12,480
Imaging860
Referrals3,112
  1. 1Column header[data-slot=table-head]:last-childfont-medium · text-foreground
  2. 2Row[data-slot=table-body] [data-slot=table-row]border-b · data-interactive:hover:bg-foreground/4
  3. 3Cell[data-slot=table-body] [data-slot=table-cell]p-3 · text-sm
  4. 4Captiondata-slot="table-caption"text-sm · text-muted-foreground

Clinia rules

  • A selected row (data-state="selected", set by Data Table) is tinted bg-accent/15. The tint is not the only cue: pair it with a checked Checkbox.
  • Rows don't hover by default. Set interactive on a row that opens, selects or links to something: it takes the bg-foreground/4 hover tint. Rows of static data, such as a permissions matrix, stay still.
  • The header and footer sit on bg-foreground/3, a faint ink tint that follows the theme.
  • Right-align numbers and set them in tabular-nums, so values line up and compare at a glance.
  • Headers are sentence case and name the content: Last sync, not Last Sync or Date.
  • className on Table styles the table, not the scrolling container around it.

Do and don't

SourceRecords
Lab results12,480
Imaging860
Referrals3,112
Do right-align numbers so they compare at a glance.
SourceRecords
Lab results12,480
Imaging860
Referrals3,112
Don't left-align numbers of different lengths.

States

resting
P-001Jane CooperJun 3, 2025
P-002Floyd MilesMay 20, 2025
interactive · hover
P-001Jane CooperJun 3, 2025
P-002Floyd MilesMay 20, 2025
selected
P-001Jane CooperJun 3, 2025
P-002Floyd MilesMay 20, 2025
overflow · named scroll region
Recent patients
IDNameStatusLast visit
P-001Jane CooperActiveJun 3, 2025
P-002Floyd MilesInactiveMay 20, 2025

Toggle the site theme to review both themes.

Accessibility

Built in

  • Renders native <table>, <thead>, <th> and <td> elements, so screen readers announce the row, the column and its header.
  • The table sits in a container that scrolls sideways, so a wide table never widens the page.
  • While the table is wider than its container, the container is a tab stop and a region named like the table, so a keyboard user can scroll it with the arrow keys. It shows the Trust focus ring.

Your responsibility

  • Name the table: a TableCaption, or an aria-label on Table when a heading above already names it. The scroll container takes the same name, so a table that can overflow always needs one.
  • Put column headers in TableHead inside TableHeader. For a row header, render TableHead in the row with scope="row".
  • Write empty cells out (Never, None) or use a dash with a caption that explains it. A blank cell reads as missing data.

How to test

  1. With a screen reader, move into the table: it announces the caption, then the number of rows and columns.
  2. Move cell by cell (Ctrl+Option+arrows in VoiceOver, Ctrl+Alt+arrows in NVDA): each cell is read with its column header.
  3. Narrow the window to 320px: the table scrolls inside its container and the page does not scroll sideways.
  4. At that width, press Tab: the container takes focus with the Trust ring, the arrow keys scroll it, and a screen reader announces it as a region with the table's name.

API

Table

PropValuesDefaultDescription
aria-label
string
–

Names the table, and its scroll container while it overflows. Leave it off when a TableCaption names the table.

TableRow

PropValuesDefaultDescription
interactive
boolean
false

Tints the row on hover. Set it on a row that opens, selects or links to something; leave it off for rows of static data.

All other props come from the native table element.