Tables ​

The table base component provides a set of styles for tables, captions, rows, and cells. Use modifiers to change borders, stripes, and colours.

Base elements ​

The styles apply directly to the table and its elements by default.

Variants and modifiers ​

There are three table colour variants provided by default: .primary, .secondary, and .tertiary. Add the variant class to the table.

ClassDescription
.borderedAdds borders to the table and its cells.
.collapsedCollapses the borders between cells.
.striped-columnsStyles odd cells in each row of the table body.
.striped-rowsStyles odd rows in the table body.
.hoverableChanges the colour of body rows on hover.
.highlightHighlights a row or cell inside the table.
.responsive-tableLets a wrapper around the table scroll horizontally.

Add the border, stripe, and hover classes to the table. Add .highlight to the row or cell you want to highlight. For a wide table, add .responsive-table to a wrapper. Give the wrapper a label and tabindex="0" so keyboard users can focus it and scroll. The responsive preview uses .min-w-full-screen to make the table wide enough to scroll.

Table modifiers

If you are compiling your own version of Graupl, you can set the table module’s $themeable variable to false to skip generating theme variants.

Custom Properties ​

The following custom properties can be used to customize the table component:

PropertyDescriptionDefault Value
--graupl-table-caption-sideThe caption side of the table component.bottom
--graupl-table-caption-padding-xThe horizontal padding of the table caption component.var(--graupl-spacer-3)
--graupl-table-caption-padding-yThe vertical padding of the table caption component.var(--graupl-spacer-3)
--graupl-table-caption-paddingThe padding of the table caption component (combines x and y padding).var(--graupl-table-caption-padding-y) var(--graupl-table-caption-padding-x)
--graupl-table-header-font-weightThe font weight of the table header component.var(--graupl-font-weight-bold)
--graupl-table-header-padding-xThe horizontal padding of the table header component.var(--graupl-spacer-3)
--graupl-table-header-padding-yThe vertical padding of the table header component.var(--graupl-spacer-3)
--graupl-table-header-paddingThe padding of the table header component (combines x and y padding).var(--graupl-table-header-padding-y) var(--graupl-table-header-padding-x)
--graupl-table-header-backgroundThe background colour of the table header component.var(--graupl-background)
--graupl-table-header-colorThe text colour of the table header component.var(--graupl-color)
--graupl-table-cell-padding-xThe horizontal padding of the table cell component.var(--graupl-spacer-3)
--graupl-table-cell-padding-yThe vertical padding of the table cell component.var(--graupl-spacer-3)
--graupl-table-cell-paddingThe padding of the table cell component (combines x and y padding).var(--graupl-table-cell-padding-y) var(--graupl-table-cell-padding-x)
--graupl-table-cell-backgroundThe background colour of the table cell component.var(--graupl-background)
--graupl-table-cell-colorThe text colour of the table cell component.var(--graupl-color)
--graupl-table-border-top-widthThe top border width of the table component.var(--graupl-border-top-width)
--graupl-table-border-right-widthThe right border width of the table component.var(--graupl-border-right-width)
--graupl-table-border-bottom-widthThe bottom border width of the table component.var(--graupl-border-bottom-width)
--graupl-table-border-left-widthThe left border width of the table component.var(--graupl-border-left-width)
--graupl-table-border-widthThe border width of the table component (combines top, right, bottom, and left widths).var(--graupl-table-border-top-width) var(--graupl-table-border-right-width) var(--graupl-table-border-bottom-width) var(--graupl-table-border-left-width)
--graupl-table-border-top-styleThe top border style of the table component.var(--graupl-border-top-style)
--graupl-table-border-right-styleThe right border style of the table component.var(--graupl-border-right-style)
--graupl-table-border-bottom-styleThe bottom border style of the table component.var(--graupl-border-bottom-style)
--graupl-table-border-left-styleThe left border style of the table component.var(--graupl-border-left-style)
--graupl-table-border-styleThe border style of the table component (combines top, right, bottom, and left styles).var(--graupl-table-border-top-style) var(--graupl-table-border-right-style) var(--graupl-table-border-bottom-style) var(--graupl-table-border-left-style)
--graupl-table-border-top-left-radiusThe top left border radius of the table component.var(--graupl-border-top-left-radius)
--graupl-table-border-top-right-radiusThe top right border radius of the table component.var(--graupl-border-top-right-radius)
--graupl-table-border-bottom-right-radiusThe bottom right border radius of the table component.var(--graupl-border-bottom-right-radius)
--graupl-table-border-bottom-left-radiusThe bottom left border radius of the table component.var(--graupl-border-bottom-left-radius)
--graupl-table-border-radiusThe border radius of the table component (combines top left, top right, bottom right, and bottom left radii).var(--graupl-table-border-top-left-radius) var(--graupl-table-border-top-right-radius) var(--graupl-table-border-bottom-right-radius) var(--graupl-table-border-bottom-left-radius)
--graupl-table-border-colorThe border colour of the table component.var(--graupl-border-color)
--graupl-table-cell-border-top-widthThe top border width of the table cell component.var(--graupl-border-top-width)
--graupl-table-cell-border-right-widthThe right border width of the table cell component.var(--graupl-border-right-width)
--graupl-table-cell-border-bottom-widthThe bottom border width of the table cell component.var(--graupl-border-bottom-width)
--graupl-table-cell-border-left-widthThe left border width of the table cell component.var(--graupl-border-left-width)
--graupl-table-cell-border-widthThe border width of the table cell component (combines top, right, bottom, and left widths).var(--graupl-table-cell-border-top-width) var(--graupl-table-cell-border-right-width) var(--graupl-table-cell-border-bottom-width) var(--graupl-table-cell-border-left-width)
--graupl-table-cell-border-top-styleThe top border style of the table cell component.var(--graupl-border-top-style)
--graupl-table-cell-border-right-styleThe right border style of the table cell component.var(--graupl-border-right-style)
--graupl-table-cell-border-bottom-styleThe bottom border style of the table cell component.var(--graupl-border-bottom-style)
--graupl-table-cell-border-left-styleThe left border style of the table cell component.var(--graupl-border-left-style)
--graupl-table-cell-border-styleThe border style of the table cell component (combines top, right, bottom, and left styles).var(--graupl-table-cell-border-top-style) var(--graupl-table-cell-border-right-style) var(--graupl-table-cell-border-bottom-style) var(--graupl-table-cell-border-left-style)
--graupl-table-cell-border-top-left-radiusThe top left border radius of the table cell component.var(--graupl-border-top-left-radius)
--graupl-table-cell-border-top-right-radiusThe top right border radius of the table cell component.var(--graupl-border-top-right-radius)
--graupl-table-cell-border-bottom-right-radiusThe bottom right border radius of the table cell component.var(--graupl-border-bottom-right-radius)
--graupl-table-cell-border-bottom-left-radiusThe bottom left border radius of the table cell component.var(--graupl-border-bottom-left-radius)
--graupl-table-cell-border-radiusThe border radius of the table cell component (combines top left, top right, bottom right, and bottom left radii).var(--graupl-table-cell-border-top-left-radius) var(--graupl-table-cell-border-top-right-radius) var(--graupl-table-cell-border-bottom-right-radius) var(--graupl-table-cell-border-bottom-left-radius)
--graupl-table-cell-border-colorThe border colour of the table cell component.var(--graupl-table-border-color)
--graupl-table-header-border-top-widthThe top border width of the table header component.var(--graupl-table-cell-border-top-width)
--graupl-table-header-border-right-widthThe right border width of the table header component.var(--graupl-table-cell-border-right-width)
--graupl-table-header-border-bottom-widthThe bottom border width of the table header component.var(--graupl-table-cell-border-bottom-width)
--graupl-table-header-border-left-widthThe left border width of the table header component.var(--graupl-table-cell-border-left-width)
--graupl-table-header-border-widthThe border width of the table header component (combines top, right, bottom, and left widths).var(--graupl-table-header-border-top-width) var(--graupl-table-header-border-right-width) var(--graupl-table-header-border-bottom-width) var(--graupl-table-header-border-left-width)
--graupl-table-header-border-top-styleThe top border style of the table header component.var(--graupl-table-cell-border-top-style)
--graupl-table-header-border-right-styleThe right border style of the table header component.var(--graupl-table-cell-border-right-style)
--graupl-table-header-border-bottom-styleThe bottom border style of the table header component.var(--graupl-table-cell-border-bottom-style)
--graupl-table-header-border-left-styleThe left border style of the table header component.var(--graupl-table-cell-border-left-style)
--graupl-table-header-border-styleThe border style of the table header component (combines top, right, bottom, and left styles).var(--graupl-table-header-border-top-style) var(--graupl-table-header-border-right-style) var(--graupl-table-header-border-bottom-style) var(--graupl-table-header-border-left-style)
--graupl-table-header-border-top-left-radiusThe top left border radius of the table header component.var(--graupl-table-cell-border-top-left-radius)
--graupl-table-header-border-top-right-radiusThe top right border radius of the table header component.var(--graupl-table-cell-border-top-right-radius)
--graupl-table-header-border-bottom-right-radiusThe bottom right border radius of the table header component.var(--graupl-table-cell-border-bottom-right-radius)
--graupl-table-header-border-bottom-left-radiusThe bottom left border radius of the table header component.var(--graupl-table-cell-border-bottom-left-radius)
--graupl-table-header-border-radiusThe border radius of the table header component (combines top left, top right, bottom right, and bottom left radii).var(--graupl-table-header-border-top-left-radius) var(--graupl-table-header-border-top-right-radius) var(--graupl-table-header-border-bottom-right-radius) var(--graupl-table-header-border-bottom-left-radius)
--graupl-table-header-border-colorThe border colour of the table header component.var(--graupl-table-border-color)
--graupl-table-striped-backgroundThe background colour of the striped table component modifier.var(--graupl-theme-active--secondary--200)
--graupl-table-cell-striped-backgroundThe background colour of striped table cell components.var(--graupl-table-striped-background)
--graupl-table-header-striped-backgroundThe background colour of striped table header components.var(--graupl-table-striped-background)
--graupl-table-striped-colorThe text colour of the striped table component modifier.var(--graupl-theme-active--secondary--900)
--graupl-table-cell-striped-colorThe text colour of striped table cell components.var(--graupl-table-striped-color)
--graupl-table-header-striped-colorThe text colour of striped table header components.var(--graupl-table-striped-color)
--graupl-table-hover-backgroundThe background colour of the hoverable table component modifier.var(--graupl-theme-active--secondary--300)
--graupl-table-cell-hover-backgroundThe background colour of hoverable table cell components.var(--graupl-table-hover-background)
--graupl-table-header-hover-backgroundThe background colour of hoverable table header components.var(--graupl-table-hover-background)
--graupl-table-hover-colorThe text colour of the hoverable table component modifier.var(--graupl-theme-active--secondary--900)
--graupl-table-cell-hover-colorThe text colour of hoverable table cell components.var(--graupl-table-hover-color)
--graupl-table-header-hover-colorThe text colour of hoverable table header components.var(--graupl-table-hover-color)
--graupl-table-highlight-backgroundThe background colour of the highlighted table component modifier.var(--graupl-theme-active--secondary--700)
--graupl-table-cell-highlight-backgroundThe background colour of highlighted table cell components.var(--graupl-table-highlight-background)
--graupl-table-header-highlight-backgroundThe background colour of highlighted table header components.var(--graupl-table-highlight-background)
--graupl-table-highlight-colorThe text colour of the highlighted table component modifier.var(--graupl-theme-active--secondary--100)
--graupl-table-cell-highlight-colorThe text colour of highlighted table cell components.var(--graupl-table-highlight-color)
--graupl-table-header-highlight-colorThe text colour of highlighted table header components.var(--graupl-table-highlight-color)

Sass variables ​

The following Sass variables can be used to customize the generation of the table component:

VariableDescriptionDefault Value
$selector-baseThe selector base for the component.""
$modifier-selector-baseThe selector base for component modifiers."."
$generate-base-theme-mapA flag to generate the base theme maps for table variants.true
$themeableA flag that determines whether theme modifiers are generated.true
$table-selector-baseThe selector base for the table component.""
$table-selectorThe selector for the table component."table"
$table-caption-selector-baseThe selector base for the table caption component.""
$table-caption-selectorThe selector for the table caption component."caption"
$table-header-selector-baseThe selector base for the table header cell component.""
$table-header-selectorThe selector for the table header cell component."th"
$table-cell-selector-baseThe selector base for the table cell component.""
$table-cell-selectorThe selector for the table cell component."td"
$table-row-selector-baseThe selector base for the table row component.""
$table-row-selectorThe selector for the table row component."tr"
$table-body-selector-baseThe selector base for the table body component.""
$table-body-selectorThe selector for the table body component."tbody"
$table-theme-prefix-selector-baseThe selector base for the themed table component modifiers."."
$table-theme-prefix-selectorThe selector prefix for the themed table component modifiers.""
$table-bordered-selector-baseThe selector base for the bordered table component modifier."."
$table-bordered-selectorThe selector for the bordered table component modifier."bordered"
$table-collapsed-selector-baseThe selector base for the collapsed table component modifier."."
$table-collapsed-selectorThe selector for the collapsed table component modifier."collapsed"
$table-striped-columns-selector-baseThe selector base for the striped columns table component modifier."."
$table-striped-columns-selectorThe selector for the striped columns table component modifier."striped-columns"
$table-striped-rows-selector-baseThe selector base for the striped rows table component modifier."."
$table-striped-rows-selectorThe selector for the striped rows table component modifier."striped-rows"
$table-hoverable-selector-baseThe selector base for the hoverable table component modifier."."
$table-hoverable-selectorThe selector for the hoverable table component modifier."hoverable"
$table-highlight-selector-baseThe selector base for the highlighted table component modifier."."
$table-highlight-selectorThe selector for the highlighted table component modifier."highlight"
$table-responsive-selector-baseThe selector base for the responsive table component modifier."."
$table-responsive-selectorThe selector for the responsive table component modifier."responsive-table"
$table-caption-sideThe side of the table used to render the caption.bottom
$table-theme-mappingsA map of properties and color shades used to generate all table variants.()
$table-theme-mapA map of all properties, colors, and color shades used to generate all table variants.()