Tables

A bare <table> is full-width with a bottom rule per row and a heavier rule under <thead> / above <tfoot>. Use <caption> and scope on your header cells.

Jellyfish by danger level
SpeciesDangerHabitat
Cotylorhiza tuberculataMildMediterranean Sea
Pelagia noctilucaSevereMediterranean Sea
Rhopilema nomadicaSevereIndo-Pacific Ocean

Modifiers

Add any combination to the <table>:

Table modifier classes
ClassEffect
.is-stripedShade alternate body rows.
.has-borderBorder every cell.
.is-hoverableHighlight the row under the pointer.
.is-responsiveBelow $table-responsive-breakpoint, each row stacks and every <td> shows its column label. Add data-label="…" to each cell, or let the JS fill them in on load.
.{family} on <table> / <tr> / <td>Colour the whole table, a row, or one cell (needs $generate-table-modifiers).

Striped

SpeciesDangerHabitat
Cotylorhiza tuberculataMildMediterranean Sea
Pelagia noctilucaSevereMediterranean Sea
Rhopilema nomadicaSevereIndo-Pacific Ocean

Bordered

SpeciesDangerHabitat
Cotylorhiza tuberculataMildMediterranean Sea
Pelagia noctilucaSevereMediterranean Sea
Rhopilema nomadicaSevereIndo-Pacific Ocean

Hoverable

SpeciesDangerHabitat
Cotylorhiza tuberculataMildMediterranean Sea
Pelagia noctilucaSevereMediterranean Sea
Rhopilema nomadicaSevereIndo-Pacific Ocean

Colours

Needs $generate-table-modifiers. A .{family} on <table> colours the whole table; on <tr> a row; on <td> one cell.

ClassHeading
table.primarytable.primary
tr.errortr.error
tr.primarytr.primary
td.successtd.error
td.warningtd.success
tr.warningtr.warning

Responsive stack

Two ways to keep a wide table usable on a narrow screen. .is-responsive is the preferred one — it's more work but reads far better on a phone; .table-container is the fallback for when a stack doesn't make sense for that table's data (lots of numeric columns you want to keep scanning across, for instance).

Method one: .is-responsive

Below $table-responsive-breakpoint (900px) each row stacks into its own block, and every cell — <td> or a row-header <th scope="row"> alike — needs its column heading repeated inline. Add data-label="…" to each cell yourself, or leave it out: responsive-tables.js copies each <thead> <th>'s text into the matching column's cells' data-label on DOMContentLoaded, by position — so it works whether that column's cells are <td> or <th>.

Resize the window below $table-responsive-breakpoint (900px) to see it stack
SpeciesStingerHabitat
Cotylorhiza tuberculata Harmless to humans, but best not touched. Very abundant in Mediterranean bays, especially in warmer water.
Rhopilema nomadica A bad stinger; told apart from Rhizostoma by its lack of a blue rim. An Indo-Pacific species that reached the eastern Mediterranean via the Suez Canal.

Method two: .table-container

Wrap the table instead of classing it, and it scrolls horizontally rather than reflowing — far less control (no per-column labelling, no reordering), so reach for it only when a stack genuinely doesn't suit the data.

SpeciesStingerHabitatHow to identify itAverage weight
Cotylorhiza tuberculata Harmless to humans, but best not touched. Very abundant in Mediterranean bays, especially in warmer water. Rigid, roundish umbrella to 30cm, reddish or yellow at the centre; manubrium resembles a bouquet of blue-purple buttons. Up to 3kg
Rhopilema nomadica A bad stinger; told apart from Rhizostoma by its lack of a blue rim. An Indo-Pacific species that reached the eastern Mediterranean via the Suez Canal. Hard to miss — umbrella to 80cm, forms extensive swarms. Up to 7kg

Overriding

  • One table / a scoped rule — set the --jf-table-* custom properties (tabled below) on the <table>, or on a single <tr> / <td> to scope it to that row or cell.
  • Everywhere — the Sass variables below.

Variables

Sass variables

Tables Sass variables
NameDefaultNotes
$generate-table-modifierstrueEmit the .{family} colour classes for tables, rows and cells.
$table-cell-padding0.5em 0.8emCell padding. In em, so it tracks $table-font-size.
$table-font-sizetoken(font-size-sm)--jf-table-font-size, declared on <table>. Override it there for one table.
$table-line-heightget-leading(snug)Cell line height. Baked at build; not a token.
$table-responsive-breakpoint900pxWidth below which .is-responsive switches to the stacked layout.

Custom properties

Tables custom properties
NameDefaultNotes
--jf-table-cell-backgroundtransparentPer-cell fill. <thead> / <tfoot>, stripes, hover and every .{family} modifier repoint this one token.
--jf-table-text-colorinheritPer-cell text colour, paired with the fill above.
--jf-table-border-colorfalls back to --jf-border-colorNot emitted by default — set it to restyle table rules without moving the shared border colour.
--jf-table-stripe-bg-colora neutral mixFill of alternate rows under .is-striped.
--jf-table-hover-backgroundneutral / mutedRow fill under the pointer with .is-hoverable.
--jf-table-text-hover-color--jf-color-on-neutral-mutedRow text colour on hover, so the pair stays readable as the fill changes.