Table
Structural table chrome for data lists. Compose rows and cells; put content in light DOM with existing Catnip primitives. The table does not own sorting, filtering, selection, or expansion logic.
Overview
| Piece | Role |
|---|---|
catnip-table | Table chrome, density M / L, optional striped body rows, optional sticky header |
catnip-table-row | Body row chrome: default / hover (neutral/subtler-hover) / selected (primary/subtler) / selected hover (primary/subtler-hover) |
catnip-table-cell | Slotted cell; header uses table-header + primary/stronger; body uses text-m/l + neutral/strongest |
Out of scope for v1 (build in the product): typed cell variants (badge, user, avatar), expandable rows, column filters inside headers, virtualization, column resize. Filters belong above or beside the table (for example catnip-dropdown). Prefer catnip-status for status dots and labels; badges and avatars remain consumer markup until dedicated primitives ship.
Live example
Guidelines
When to use
| Pattern | Use |
|---|---|
catnip-table + row + cell | Tabular data with shared density, hover/selected chrome, and optional sort affordances |
| Product-built grid | Virtualization, column resize, nested expandable rows, editable cells, or a typed cell catalog |
Composition rules
- Place
catnip-table-rowin the default slot (body) orslot="header". Placecatnip-table-cellas direct children of each row. - Parent owns the loop, selection, sort, and filter state — same model as List and Split Button.
- Cell content is light-DOM projection. Prefer existing primitives (
catnip-checkbox,catnip-link,catnip-button,catnip-icon) over inventing celltypeenums.
Selection
Bind selected on each body row. Put checkboxes in cells if you need bulk select; the table does not manage a selected-id set.
<catnip-table-row .selected="selectedIds.includes(row.id)">
<catnip-table-cell>
<catnip-checkbox
.modelValue="selectedIds.includes(row.id)"
.checkboxAriaLabel="'Select ' + row.name"
@update:modelValue="onToggle(row.id, $event.detail[0])"
/>
</catnip-table-cell>
<!-- ... -->
</catnip-table-row>Sorting
Use sortable and activeSort on header cells for UI only — the whole header cell is the hit target. On sort-click, update your sortKey / sortDir (or refetch) and rebind activeSort on the active column only. Do not expect the cell to cycle directions or reorder rows.
Filters
Keep filters outside the table header cells — for example a catnip-dropdown toolbar above the table (see the live playground). Do not treat column filters as part of the table API.
Pagination
Compose a catnip-pagination below the table; the table has no pagination API. Show it only when the rows span more than one page, and hide it when all rows fit on one page or there are none. See Pagination — Single page and empty results.
Caption and empty state
There is no caption or empty slot — compose labelling and empty UI in the product. For the table's name, see Accessibility — What you own.
Empty: when the data set is empty, either render one body row with a message cell, or show a short message below/beside the table. Prefer a simple paragraph; do not invent an empty prop.
<catnip-table table-aria-label="Events">
<catnip-table-row slot="header">
<catnip-table-cell header>Event</catnip-table-cell>
<catnip-table-cell header>Status</catnip-table-cell>
</catnip-table-row>
<catnip-table-row v-if="rows.length === 0">
<catnip-table-cell>No events match your filters.</catnip-table-cell>
</catnip-table-row>
<catnip-table-row v-for="row in rows" :key="row.id">
<!-- ... -->
</catnip-table-row>
</catnip-table>More actions
Compose a ghost-subtle utility catnip-button in a trailing cell with a consumer-owned catnip-list menu, following the Split Button menu recipe.
Cell content (Figma types → composition)
Figma defines many Cell types. Catnip keeps one slotted cell — compose content in light DOM. Do not pass a type prop.
| Figma type | How to compose |
|---|---|
| Text | Default slot text (body: text-m/l; header: set header) |
| Number | numeric + align="end"; header: header + align="end" |
| Link | Slot catnip-link (optional copy catnip-button / icon beside it) |
| Checkbox | Slot catnip-checkbox; header select-all often align="end" |
| Expand | Slot icon button (chevron-right) — consumer owns expand state |
| More | Slot icon catnip-button (more-horizontal) + consumer catnip-list menu |
| Status | Slot catnip-status; header filters stay outside the table |
| Badge | Slot catnip-badge for compact metadata or counts |
| User | Slot catnip-user |
| Logo | Slot catnip-icon / catnip-graphic |
Compact columns (checkbox, expand, more, logo) stay content-width — cells do not force a fixed width.
<!-- Number -->
<catnip-table-cell numeric align="end">42</catnip-table-cell>
<!-- Link -->
<catnip-table-cell>
<catnip-link appearance="underline" right-icon="" href="#">12569HDSU568</catnip-link>
</catnip-table-cell>
<!-- Status -->
<catnip-table-cell>
<catnip-status intent="success">Active</catnip-status>
</catnip-table-cell>
<!-- Badge -->
<catnip-table-cell>
<catnip-badge intent="informative">New</catnip-badge>
</catnip-table-cell>
<!-- More -->
<catnip-table-cell>
<catnip-button appearance="ghost-subtle" purpose="utility" size="s" left-icon="more-horizontal" button-aria-label="More"></catnip-button>
</catnip-table-cell>Badge and user
- Prefer
catnip-statusfor status dots + labels. - Slot
catnip-badgefor compact metadata or counts. - Slot
catnip-userfor assignee or owner. Leaveinteractionat the defaultstaticin cells that must not imply a menu; usehideNamewhen only the avatar circle should show.
Density and header chrome
- Density is driven by CSS custom properties on
catnip-table. Cells inherit those vars — they do not take asizeprop. - Body type uses
--catnip-font-text-m/--catnip-font-text-l; headers use--catnip-font-table-header-m/--catnip-font-table-header-l;numericuses--catnip-font-code-m/--catnip-font-code-l. - Header min height: 48px (M) / 52px (L). Body min height: 40px (M) / 44px (L).
- Header colour is content/primary/stronger.
- Cells use space/4 inline padding, space/2 gap, and a neutral/subtlest bottom border.
- Body row states: default (transparent), hover (neutral/subtler-hover), selected (primary/subtler), and selected hover (primary/subtler-hover).
- Striped body rows use neutral/subtler. Sortable header cells use neutral/subtler-hover on hover.
Do / don’t
- Do use
headeron header cells and keep body cells without it. - Do keep dense interactive content lightweight; avoid nesting heavy fields in every cell of large tables.
- Don’t encode product cell types (
status,user,badge) as Catnip props. - Don’t put multi-select filter panels inside header cells as a DS API.