Skip to main content

Data table

Many records in one view, with search, filters, sorting, column choice, selection and paging.

Left out of Multi-brand Multi-brand draws on core, content and media families, not data. It avoids tools staff use all day and points those to Dense data. Use instead: Card, Tabs

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

  • Use it when: People find, compare and act on many records, often in bulk.
  • Not when: A handful of rows (a plain table), or items people browse rather than compare (cards).

Instead:

  • Table: A few rows, no tools.
  • Card: Items to browse, not compare.

How Multi-brand uses it​

A number in a table
Use type.body
Not A mono font
Prices sit in sentences and offers, not in columns to compare, so a mono font adds nothing in any brand.
A selected row or item
Use color.surface.selected (from the brand)
Not A fixed blue
Selection follows the brand color.
Table row height
Use size.row (comfortable)
Not A compact row
Customers browse on phones, and compact rows are hard to tap in any brand.
An action on one row or item
Use Button ghost with a word
Not An icon alone
A word says what will happen.

Words​

  • Shared structure: object, state, next step.
  • Brand tone lives in headlines and marketing copy, not in errors.
  • Errors and confirmations read the same in every brand.
  • Use: Get started, Plan, Order. Avoid: Brand-specific words in errors, Jargon.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Get started

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedEvery tool and row action is reachable by keyboard.undefined

Test before you ship:

  • It stays a real table with headers; sorting and selection are announced. undefined

Use it in code​

npx open-ds add data-table

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Data table reads 12 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Data table's tokens to change Data table alone.

Changes with theme

Multi-brand decides what changes when you switch theme. Here a switch changes colors, type and shape, so the marked rows differ between its brands and between light and dark; everything else holds steady.

PartIts token and the semantic it aliasesValue
Shared
Card radius
Changes with theme
component.card.radiusradius.containervar(--card-radius)Aster Lightradius.8:0.5remAster Darkradius.8:0.5remBirch Lightradius.16:1remBirch Darkradius.16:1remCoral Lightradius.20:1.25remCoral Darkradius.20:1.25rem
Table row heightcomponent.table.row-heightsize.rowvar(--table-row-height)size.48:3rem
Table row border
Changes with theme
component.table.row-bordercolor.border.defaultvar(--table-row-border)Aster Lightslate-deep.light.200:#E2E8F0Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.200:#E2E8F0Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.200:#E2E8F0Coral Darkslate-deep.dark.100:#1E293B
Data table
Gapcomponent.data-table.gapspace.gap.tightvar(--data-table-gap)space.8:0.5rem
Label hover
Changes with theme
on hover
component.data-table.label-hovercolor.text.primaryvar(--data-table-label-hover)Aster Lightslate-deep.light.900:#0F172AAster Darkslate-deep.dark.900:#F8FAFCBirch Lightslate-deep.light.900:#0F172ABirch Darkslate-deep.dark.900:#F8FAFCCoral Lightslate-deep.light.900:#0F172ACoral Darkslate-deep.dark.900:#F8FAFC
Paddingcomponent.data-table.paddingcomponent-spacing-map.x2var(--data-table-padding)space.8:0.5rem
Gap 2component.data-table.gap-2space.gap.defaultvar(--data-table-gap-2)space.12:0.75rem
Corner
Changes with theme
component.data-table.radiusradius.badgevar(--data-table-radius)Aster Lightradius.4:0.25remAster Darkradius.4:0.25remBirch Lightradius.999:9999pxBirch Darkradius.999:9999pxCoral Lightradius.999:9999pxCoral Darkradius.999:9999px
Padding, left and rightcomponent.data-table.padding-xcomponent-spacing-map.x2var(--data-table-padding-x)space.8:0.5rem
Padding, top and bottomcomponent.data-table.padding-ycomponent-spacing-map.x1var(--data-table-padding-y)space.4:0.25rem
Background hover
Changes with theme
on hover
component.data-table.background-hovercolor.surface.sunkenvar(--data-table-background-hover)Aster Lightslate-deep.light.100:#F1F5F9Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.100:#F1F5F9Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.100:#F1F5F9Coral Darkslate-deep.dark.100:#1E293B
Text
Changes with theme
component.data-table.labelcolor.text.mutedvar(--data-table-label)Aster Lightslate-deep.light.600:#4B5A6FAster Darkslate-deep.dark.400:#96A3B5Birch Lightslate-deep.light.600:#4B5A6FBirch Darkslate-deep.dark.400:#96A3B5Coral Lightslate-deep.light.600:#4B5A6FCoral Darkslate-deep.dark.400:#96A3B5
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Aster Lightslate-deep.light.200 · #E2E8F0Aster Darkslate-deep.dark.100 · #1E293BBirch Lightslate-deep.light.200 · #E2E8F0Birch Darkslate-deep.dark.100 · #1E293BCoral Lightslate-deep.light.200 · #E2E8F0Coral Darkslate-deep.dark.100 · #1E293B