Home

Datatables

Usage

Datatables are for typed datasets and default to table tokens. Override only what needs to differ from tables.

Start with these tokens when customizing datatables:

  • --datatable-spacing-top and --datatable-spacing-bottom for vertical rhythm

  • --datatable-header-background and --datatable-header-font-weight for headers

  • --datatable-row-striped and --datatable-row-hover for scanability

  • --datatable-cell-padding and --datatable-cell-font-size for density

  • --datatable-border-width and --datatable-border-color for framing

  • --datatable-caption-* and --datatable-notes-* for supporting text

Tokens

Layout Tokens

Control breakout width behavior for datatables.

TokenDescriptionDefault Value
--datatable-max-widthMaximum width for datatablesvar(--table-max-width)
--datatable-max-width-mobileMaximum width on mobile (640px)var(--table-max-width-mobile)
--datatable-max-width-printMaximum width in printvar(--table-max-width-print)

Spacing Tokens

Control vertical separation and layout spacing for datatables.

TokenDescriptionDefault Value
--datatable-spacing-topTop margin (automatic responsive scaling)var(--table-spacing-top)
--datatable-spacing-bottomBottom margin (automatic responsive scaling)var(--table-spacing-bottom)
--datatable-caption-spacing-bottomGap between caption and tablevar(--table-caption-spacing-bottom)

Caption Layout and Typography Tokens

Layout and typography styling for datatable captions (inherits from caption and label tokens).

TokenDescriptionDefault Value
--datatable-caption-font-familyFont family for captionsvar(--table-caption-font-family)
--datatable-caption-font-sizeFont size for captionsvar(--table-caption-font-size)
--datatable-caption-colorText color (automatic dark mode)var(--table-caption-color)
--datatable-caption-line-heightLine height for caption textvar(--table-caption-line-height)
--datatable-caption-alignText alignment (left, center, right, justify)var(--table-caption-align)
--datatable-caption-max-widthMaximum width for caption textvar(--table-caption-max-width)
--datatable-label-font-weightFont weight for datatable labelsvar(--table-label-font-weight)
--datatable-label-font-styleFont style for datatable labelsvar(--table-label-font-style)
--datatable-label-colorText color for datatable labelsvar(--table-label-color)

Notes Tokens

Styling for datatable notes and annotations.

TokenDescriptionDefault Value
--datatable-notes-font-familyFont family for notes textvar(--table-notes-font-family)
--datatable-notes-font-sizeFont size for notes textvar(--table-notes-font-size)
--datatable-notes-colorText color for notesvar(--table-notes-color)
--datatable-notes-spacing-topGap between table and notesvar(--table-notes-spacing-top)
--datatable-notes-line-heightLine height for notes textvar(--table-notes-line-height)
--datatable-notes-alignText alignment for notesvar(--table-notes-align)

Datatable Container Tokens

Border and corner styling for the datatable container.

TokenDescriptionDefault Value
--datatable-border-radiusCorner roundingvar(--table-border-radius)
--datatable-border-widthOuter border widthvar(--table-border-width)
--datatable-border-width-printOuter border width for printvar(--table-border-width-print)
--datatable-border-colorOuter border colorvar(--table-border-color)
--datatable-border-styleOuter border stylevar(--table-border-style)

Row and Column Border Tokens

TokenDescriptionDefault Value
--datatable-row-border-widthRow separator widthvar(--table-row-border-width)
--datatable-row-border-width-printRow separator width for printvar(--table-row-border-width-print)
--datatable-row-border-colorRow separator colorvar(--table-row-border-color)
--datatable-row-border-styleRow separator stylevar(--table-row-border-style)
--datatable-column-border-widthColumn separator widthvar(--table-column-border-width)
--datatable-column-border-width-printColumn separator width for printvar(--table-column-border-width-print)
--datatable-column-border-colorColumn separator colorvar(--table-column-border-color)
--datatable-column-border-styleColumn separator stylevar(--table-column-border-style)

Header Styling Tokens

Visual styling for datatable headers.

TokenDescriptionDefault Value
--datatable-header-backgroundBackground color for headersvar(--table-header-background)
--datatable-header-background-darkBackground color for dark modevar(--table-header-background-dark)
--datatable-header-background-printBackground color for printvar(--table-header-background-print)
--datatable-header-font-weightFont weight for header textvar(--table-header-font-weight)

Row Styling Tokens

Interactive and striping behavior for datatable rows.

TokenDescriptionDefault Value
--datatable-row-hoverBackground color on hovervar(--table-row-hover)
--datatable-row-hover-darkHover background color for dark modevar(--table-row-hover-dark)
--datatable-row-stripedBackground color for even rowsvar(--table-row-striped)
--datatable-row-striped-darkStriped background for dark modevar(--table-row-striped-dark)
--datatable-row-striped-printStriped background for print (transparent saves ink)var(--table-row-striped-print)

Cell Styling Tokens

Typography and spacing for datatable cells.

TokenDescriptionDefault Value
--datatable-cell-font-familyFont family for cell textvar(--table-cell-font-family)
--datatable-cell-font-sizeFont size for cell textvar(--table-cell-font-size)
--datatable-cell-line-heightLine height for cell textvar(--table-cell-line-height)
--datatable-cell-line-height-mobileLine height on mobilevar(--table-cell-line-height-mobile)
--datatable-cell-line-height-printLine height for printvar(--table-cell-line-height-print)
--datatable-cell-paddingCell paddingvar(--table-cell-padding)
--datatable-cell-padding-mobileCell padding on mobilevar(--table-cell-padding-mobile)
--datatable-cell-padding-printReduced padding for printvar(--table-cell-padding-print)

Examples

Default Datatables

Standard datatable styling with automatic responsive spacing and dark mode support:

:root {
  /* No design token overrides */
}
SpeciesCountDensity
Arripis trutta1234.56
Odax pullus7890.12
Haliotis iris345.6

Compact Datatables

Compact layout with reduced spacing for datatables with many rows:

:root {
  --datatable-spacing-top: var(--space-4);
  --datatable-spacing-bottom: var(--space-4);
  --datatable-cell-padding: var(--space-2);
  --datatable-caption-spacing-bottom: var(--space-2);
}
IDTimestampEventUserStatus
100109:15:23LoginaliceSuccess
100209:16:45UploadbobSuccess
100309:17:12DeletealiceFailed
100409:18:03ExportcharlieSuccess
100509:19:34LogindianaSuccess
100609:20:11UpdatebobSuccess
100709:21:47DeletealiceSuccess
100809:22:15LoginevaSuccess

Scientific Datatables

Enhanced spacing and typography for research data with numerical precision:

:root {
  --datatable-spacing-top: calc(var(--content-spacing) * 2);
  --datatable-spacing-bottom: calc(var(--content-spacing) * 2);
  --datatable-caption-spacing-bottom: var(--content-spacing);
  --datatable-caption-align: justify;
  --datatable-caption-line-height: var(--line-height-md);
}

Table 1: Summary of experimental measurements showing treatment effects across three independent trials. Values represent mean ± standard deviation with significance levels indicated.

TreatmentTrial 1Trial 2Trial 3p-value
Control12.3±2.111.8±1.912.6±2.3
Drug A18.7±3.219.1±2.818.3±3.5< 0.001
Drug B15.4±2.616.2±2.415.8±2.9< 0.01

Datatables with Multi-Paragraph Captions

Datatables supporting longer, detailed captions with multiple paragraphs:

:root {
  --datatable-caption-line-height: var(--line-height-md);
  --datatable-caption-spacing-bottom: var(--space-6);
}

Table 2: Performance metrics across three benchmark datasets. Execution time measured in milliseconds on standardized hardware.

All tests were conducted with identical parameters and repeated 100 times. The values shown represent median execution time with 95% confidence intervals.

AlgorithmDataset ADataset BDataset C
Method 123±2 ms45±4 ms67±5 ms
Method 218±1 ms38±3 ms55±4 ms
Method 331±3 ms52±5 ms78±6 ms

Datatables with Notes

Datatables with annotations and additional context below the data:

:root {
  --datatable-notes-spacing-top: var(--space-4);
  --datatable-notes-font-size: var(--font-size-xs);
}

Table 3: Population statistics by region for 2023-2024.

RegionPopulationGrowthDensity
North2,450,0001.2%145/km²
South1,875,0002.8%98/km²
East3,120,0000.9%201/km²
West1,650,0001.5%87/km²

Tips

Token inheritance: Datatable tokens default to table tokens, so override only the pieces you want to distinguish from presentation tables.

Headers and striping: Use --datatable-header-background and --datatable-row-striped (with -dark variants) to improve scanability.

Row interactions: Set --datatable-row-hover to add or remove hover feedback without custom CSS.

Captions and notes: Use --datatable-caption-* and --datatable-notes-* to match the shared caption/label system.

© 2026 Stencila