Style tables with the opt-in table class — striped and hoverable rows, borders, context colors, sticky headers, and responsive and stacked layouts.
Introduction
Table styles are opt-in: the .table class enables them, so the native <table> elements of third-party widgets such as calendars and date pickers keep their own look. Modifier classes add stripes, hover and active states, borders and context colors. The styles reach only the direct rows and cells of a .table, so a nested table without the class is not styled.
Basic structure
Add .table to a <table> element. Cells take their padding, their colors and a bottom border from the table, and the cells of the <thead> take the colors of the head.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>John</td>
<td>Smith</td>
<td>@john</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Mehmet</td>
<td>Sarıçizmeli</td>
<td>@mehmet</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Jane</td>
<td>Doe</td>
<td>@jane</td>
</tr>
</tbody>
</table>Accented tables
Stripes set alternating rows or columns apart, which makes wide or dense tables easier to scan.
Striped rows
Add .striped to give every other row of the <tbody> the striped colors.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table striped">
...
</table>Striped columns
Add .striped-columns to stripe every other column instead of the rows.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table striped-columns">
...
</table>Hoverable rows
Add .hoverable to give the rows of the <tbody> a hover state.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table hoverable striped">
...
</table>Active state
Add .active to a <tr> or to a single cell to highlight it. An active row or cell also gets a cue on its inline-start edge.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table hoverable striped">
<thead>
...
</thead>
<tbody>
<tr class="active">
...
</tr>
<tr>
<th scope="row">2</th>
<td>Mehmet</td>
<td class="active">Sarıçizmeli</td>
<td>@mehmet</td>
</tr>
<tr>
...
</tr>
</tbody>
</table>Table borders
Border modifiers add borders around every cell, or remove the borders of a table.
Bordered tables
Add .bordered for borders on all sides of the table and of its cells.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table bordered">
...
</table>A border color utility changes the color of the borders:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table bordered border-primary">
...
</table>Borderless tables
Add .borderless for a table without borders.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table borderless">
...
</table>Border radius
The corners of a table take their radius from a design token. Set --cx-border-radius on the table to override it.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table bordered" style="--cx-border-radius: 0">
...
</table>Set --cx-table-border-radius on a wrapper to give the radius to every table inside it.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<div style="--cx-table-border-radius: 1rem">
<table class="table bordered">
...
</table>
</div>The radius is part of the build while $enable-table-border-radius is true, its default in scss/config/_settings.scss.
Context variants
CSS OnlyA context class gives a table the colors of a context. Add .context and a context name such as .primary; the .solid and .smooth classes change how strongly the color shows.
Context colors
Add .context and a context name (.context.primary, .context.success) to a table, a <thead>, a <tbody>, a row or a single cell.
| Class | Heading | Heading |
|---|---|---|
| Base | Cell | Cell |
| Default | Cell | Cell |
| Alternate | Cell | Cell |
| Primary | Cell | Cell |
| Secondary | Cell | Cell |
| Neutral | Cell | Cell |
| Danger | Cell | Cell |
| Success | Cell | Cell |
| Warning | Cell | Cell |
| Info | Cell | Cell |
| Black | Cell | Cell |
| White | Cell | Cell |
<!-- On tables -->
<table class="table context default">...</table>
<table class="table context alternate">...</table>
<table class="table context primary">...</table>
<table class="table context secondary">...</table>
<table class="table context neutral">...</table>
<table class="table context danger">...</table>
<table class="table context success">...</table>
<table class="table context warning">...</table>
<table class="table context info">...</table>
<table class="table context black">...</table>
<table class="table context white">...</table>
<!-- On heads -->
<thead class="context primary">
...
</thead>
<!-- On bodies -->
<tbody class="context primary">
...
</tbody>
<!-- On rows -->
<tr class="context primary">
...
</tr>
<!-- On cells (`td` or `th`) -->
<td class="context primary">
...
</td>Accessibility tip: Color alone shouldn't convey meaning as it's not perceived by assistive technology users. Ensure clarity through text with adequate contrast, ARIA attributes where needed, and consider using .visually-hidden for screen reader content.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table striped hoverable context primary">
...
</table>Context styles
Add .solid or .smooth next to .context and the context name. .solid applies the context color at full strength, and .smooth a softer tint of it.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table striped context primary solid">
...
</table>| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table striped context primary smooth">
...
</table>Color modes
The data-cx-theme attribute sets the color mode of a single table, whatever the mode of the page. Add data-cx-theme="light" or data-cx-theme="dark" to the table:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table" data-cx-theme="dark">
...
</table>A context class keeps its colors under an explicit color mode:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table context primary" data-cx-theme="dark">
...
</table>Table sizing
Custom properties set the cell padding and the font sizes of a table, in place of the values of the design tokens.
Basic sizing
Set --cx-cell-padding-y and --cx-td-font-size on the table itself:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table" style="--cx-td-font-size: 1rem; --cx-cell-padding-y: 1rem">
...
</table>Targeted elements
Set the same properties on a <thead> or a <tbody> to size one section, or set the --cx-table-* properties on a wrapper to size every table inside it:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<div style="--cx-table-cell-padding-y: 1rem; --cx-table-th-font-size: 1rem;">
<table class="table">
<thead style="--cx-cell-padding-y: .25rem">
...
</thead>
<tbody style="--cx-td-font-size: 1rem">
...
</tbody>
</table>
</div>Nesting
A nested table does not take the modifier classes of the table around it: it needs .table and modifiers of its own.
| Column 1 | Column 2 | Column 3 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| First | Second | Third | ||||||||||||||||
|
||||||||||||||||||
| First | Second | Third | ||||||||||||||||
<table class="table striped bordered">
...
<tr>
<td colspan="3" class="p-md">
<table class="table mb-0">
...
</table>
</td>
</tr>
...
</table>Inherit context
Add .context without a context name to a nested table so that it takes the context of the table around it.
| Column 1 | Column 2 | Column 3 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| First | Second | Third | ||||||||||||||||
|
||||||||||||||||||
| First | Second | Third | ||||||||||||||||
<table class="table striped bordered context primary">
...
<tr>
<td colspan="3" class="p-md">
<table class="table context mb-0">
...
</table>
</td>
</tr>
...
</table>Anatomy
The head, the foot and the caption of a table each take their own styling.
Table head
Add a context class to the <thead>, or utility classes to its <tr>, to set the head apart from the body.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table">
<thead class="context alternate">
...
</thead>
<tbody>
...
</tbody>
</table>| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table">
<thead>
<tr class="bg-main fg-primary">
...
</tr>
</thead>
<tbody>
...
</tbody>
</table>Table foot
A <tfoot> holds totals, summaries or notes at the bottom of a table. Like the head, it takes a context class, and its <tr> takes utility classes.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
| Footer 1 | Footer 2 | Footer 3 | Footer 4 |
<table class="table">
<thead>
...
</thead>
<tbody>
...
</tbody>
<tfoot class="context neutral">
...
</tfoot>
</table>Captions
A <caption> names the table and says what it holds. Screen readers announce it before the content, so their users can decide whether to read the table.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table">
<caption>List of users</caption>
...
</table>Add .caption-top to place the caption above the table.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
<table class="table caption-top">
<caption>List of users</caption>
...
</table>Group dividers
Add .table-divider to a <tbody> or a <tfoot> to draw a thicker border above its first row.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
| Footer 1 | Footer 2 | Footer 3 | Footer 4 |
<table class="table">
<thead>
...
</thead>
<tbody class="table-divider">
...
</tbody>
<tfoot class="table-divider">
...
</tfoot>
</table>| # | First | Last | Handle |
|---|---|---|---|
| 1 | John | Smith | @john |
| 2 | Mehmet | Sarıçizmeli | @mehmet |
| 3 | Jane | Doe | @jane |
| Footer 1 | Footer 2 | Footer 3 | Footer 4 |
<table class="table context primary">
<thead>
...
</thead>
<tbody class="table-divider">
...
</tbody>
<tfoot class="table-divider">
...
</tfoot>
</table>Vertical alignment
Cells of the <thead> align their content to the middle, and cells of the <tbody> inherit the alignment of the table, which is top by default.
The vertical align utilities (.align-top, .align-middle, .align-bottom) change the alignment of a table, a row or a single cell:
| Column 1 | Column 2 | Column 3 | Column 4 |
|---|---|---|---|
This cell inherits vertical-align: middle; from the table |
This cell inherits vertical-align: middle; from the table |
This cell inherits vertical-align: middle; from the table |
This here is some long text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
This cell inherits vertical-align: bottom; from the table row |
This cell inherits vertical-align: bottom; from the table row |
This cell inherits vertical-align: bottom; from the table row |
This here is some long text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
This cell inherits vertical-align: middle; from the table |
This cell aligned to the top. | This cell is aligned to the bottom. | This here is some long text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
...
</tr>
</thead>
<tbody>
<tr>
...
</tr>
<tr class="align-bottom">
...
</tr>
<tr>
<td>...</td>
<td class="align-top">This cell is aligned to the top.</td>
<td class="align-bottom">This cell is aligned to the bottom.</td>
<td>...</td>
</tr>
</tbody>
</table>
</div>Responsive tables
A .table-responsive wrapper lets a table scroll horizontally when it is wider than its container. .max-{breakpoint}:table-responsive limits the scrolling to viewports below a breakpoint.
Vertical clipping/truncation
A responsive table scrolls inside its wrapper, which is positioned, so everything the table holds stays in it, absolutely positioned content included: a .visually-hidden header never widens the page. A menu in the last rows therefore opens inside the scroll area and is clipped at its bottom edge. Give its toggle data-cx-strategy="fixed" or data-cx-container="body" so the menu opens above the table.
Always responsive
.table-responsive lets the table scroll horizontally at every viewport width.
| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="table-responsive">
<table class="table">
...
</table>
</div>Breakpoint specific
.max-{breakpoint}:table-responsive lets the table scroll horizontally below that breakpoint. From the breakpoint up, the wrapper does not scroll, so each table in these examples overflows its container at the viewport widths where its class does not apply.
| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="max-sm:table-responsive">
<table class="table">
...
</table>
</div>| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="max-md:table-responsive">
<table class="table">
...
</table>
</div>| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="max-lg:table-responsive">
<table class="table">
...
</table>
</div>| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="max-xl:table-responsive">
<table class="table">
...
</table>
</div>| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="max-2xl:table-responsive">
<table class="table">
...
</table>
</div>Sticky positioning
Pin the header row or the first column of a table so key labels stay visible while the rest of the table scrolls. .sticky-header and .sticky-column both use position: sticky on the affected cells — the header requires a scrolling ancestor on the block axis, the column pairs with .table-responsive for horizontal scrolling. Sticky cells keep the current row's --bg-color (striped, hover, and active states included), so they stay opaque over content scrolling underneath.
Sticky header
Add .sticky-header to keep the <thead> visible while rows scroll past it. The table needs a scrolling ancestor on the vertical axis — here a wrapper with a fixed max-height and overflow-y: auto.
| # | Heading | Heading | Heading |
|---|---|---|---|
| 1 | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell |
| 4 | Cell | Cell | Cell |
| 5 | Cell | Cell | Cell |
| 6 | Cell | Cell | Cell |
| 7 | Cell | Cell | Cell |
| 8 | Cell | Cell | Cell |
| 9 | Cell | Cell | Cell |
| 10 | Cell | Cell | Cell |
<div class="overflow-y-auto" style="max-height: 12.5rem;">
<table class="table sticky-header">
...
</table>
</div>Sticky columns
Add .sticky-column to pin the first cell of every row to the inline-start edge, keeping row labels visible while the remaining columns scroll horizontally. Pair it with .table-responsive so the table has a horizontal scrolling ancestor.
| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="table-responsive">
<table class="table sticky-column">
...
</table>
</div>Both directions
Combine .sticky-header and .sticky-column on the same table within a container with overflow: auto to pin the corner cell in both directions as the table scrolls vertically and horizontally.
| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|
| 1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 4 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 5 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 6 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 7 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 8 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 9 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
| 10 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
<div class="overflow-auto" style="max-height: 12.5rem;">
<table class="table sticky-header sticky-column">
...
</table>
</div>Stacked tables
Add .stacked to turn the rows of a table into stacked blocks. Each row becomes a block and each <td> a line of its own, with a label above its value. The label is the data-cell attribute of the <td>, set in the font of the head; the <thead> itself is hidden visually and stays available to screen readers.
.stacked uses container queries, so the table needs a .table-responsive wrapper as its query container. .max-md:stacked, .max-lg:stacked and the other breakpoint variants stack the table below that container width, and .stacked alone always stacks. Resize the example below to see the table switch between the two layouts.
| Name | Type | Default | Description |
|---|---|---|---|
| animation | boolean | true | Applies a CSS fade transition on show and hide. |
| autohide | boolean | true | Hides the toast automatically after delay milliseconds. The timer pauses while the pointer is over the toast or focus is within it. |
| delay | number | 5000 | Milliseconds to wait before hiding. Only applies when autohide is true. |
<div class="table-responsive">
<table class="table max-md:stacked">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Type</th>
<th scope="col">Default</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td data-cell="Name">animation</td>
<td data-cell="Type">boolean</td>
<td data-cell="Default">true</td>
<td data-cell="Description">Applies a CSS fade transition on show and hide.</td>
</tr>
<tr>
<td data-cell="Name">autohide</td>
<td data-cell="Type">boolean</td>
<td data-cell="Default">true</td>
<td data-cell="Description">Hides the toast automatically after delay milliseconds. The timer pauses while the pointer is over the toast or focus is within it.</td>
</tr>
<tr>
<td data-cell="Name">delay</td>
<td data-cell="Type">number</td>
<td data-cell="Default">5000</td>
<td data-cell="Description">Milliseconds to wait before hiding. Only applies when autohide is true.</td>
</tr>
</tbody>
</table>
</div><!-- Always stacked -->
<div class="table-responsive">
<table class="table stacked">...</table>
</div>
<!-- Stacked below md container width -->
<div class="table-responsive">
<table class="table max-md:stacked">...</table>
</div>CSS
The Table component can be customized through Sass variables at compile time.
Custom properties
The Table component exposes CSS custom properties to control its appearance at runtime.
--fg-color: var(--table-td-fg-color, #{$table-td-fg-color});
--bg-color: var(--table-td-bg-color, #{$table-td-bg-color});
--th-fg-color: var(--table-th-fg-color, #{$table-th-fg-color});
--th-bg-color: var(--table-th-bg-color, #{$table-th-bg-color});
--striped-fg-color: var(--table-striped-fg-color, #{$table-striped-fg-color});
--striped-bg-color: var(--table-striped-bg-color, #{$table-striped-bg-color});
--hover-fg-color: var(--table-hover-fg-color, #{$table-hover-fg-color});
--hover-bg-color: var(--table-hover-bg-color, #{$table-hover-bg-color});
--active-fg-color: var(--table-active-fg-color, #{$table-active-fg-color});
--active-bg-color: var(--table-active-bg-color, #{$table-active-bg-color});
--border-width: var(--table-border-width, #{$table-border-width});
--border-color: var(--table-border-color, #{$table-border-color});
--cue-color: var(--table-cue-color, #{$table-cue-color});
--caption-color: var(--table-caption-color, #{$table-caption-color});
--cell-padding-y: var(--table-cell-padding-y, #{$table-cell-padding-y});
--cell-padding-x: var(--table-cell-padding-x, #{$table-cell-padding-x});
--stacked-cell-padding-y: var(--table-stacked-cell-padding-y, #{$table-stacked-cell-padding-y});
--stacked-cell-padding-x: var(--table-stacked-cell-padding-x, #{$table-stacked-cell-padding-x});
--stacked-row-padding-y: var(--table-stacked-row-padding-y, #{$table-stacked-row-padding-y});
--stacked-row-padding-x: var(--table-stacked-row-padding-x, #{$table-stacked-row-padding-x});
@if $enable-table-font-tokens {
@include map-font($table-td-font, table, td); // e.g. --td-[property-name]: var(--table-td-[propery-name], [value]);
@include map-font($table-th-font, table, th); // e.g. --th-[property-name]: var(--table-th-[propery-name], [value]);
}
@if $enable-table-border-radius {
--border-radius: var(--table-border-radius, #{$table-border-radius});
@include border-radius(var(--border-radius));
}Sass variables
The Table component uses Sass variables in scss/config/_defaults.scss to define its defaults.
// Reboot
$table-th-font-weight: var(--font-weight-ui-strong);
// CSS custom properties
$table-divider-color: currentcolor;
$table-cell-vertical-align: top;
$table-stacked-row-padding-y: $table-cell-padding-y;
$table-stacked-row-padding-x: $table-cell-padding-x;
$table-stacked-cell-padding-y: .25rem;
$table-stacked-cell-padding-x: .25rem;
// Sass-only variables
$table-striped-order: even;
$table-striped-columns-order: even;
// Context colors
$table-caption-color: var(--fg-subtle);
$table-td-fg-context: var(--fg-main);
$table-td-bg-context: var(--bg-main);
$table-th-fg-context: var(--fg-main);
$table-th-bg-context: var(--bg-evident);
$table-striped-fg-context: var(--fg-main);
$table-striped-bg-context: var(--bg-even);
$table-hover-fg-context: var(--fg-main);
$table-hover-bg-context: var(--dim-slight);
$table-active-fg-context: var(--fg-highlight);
$table-active-bg-context: var(--bg-highlight);
$table-border-context: var(--border-subtle);
$table-cue-context: var(--cue-main);Design tokens
The Table component consumes design tokens from Chassis Tokens with the $cx- prefix. — See the design tokens page.
$table-td-fg-color: $cx-color-table-fg-data;
$table-td-bg-color: $cx-color-table-bg-data;
$table-th-fg-color: $cx-color-table-fg-head;
$table-th-bg-color: $cx-color-table-bg-head;
$table-striped-fg-color: $cx-color-table-fg-data;
$table-striped-bg-color: $cx-color-table-bg-alt;
$table-active-fg-color: $cx-color-table-fg-data;
$table-active-bg-color: $cx-color-table-bg-active;
$table-hover-fg-color: $cx-color-table-fg-data;
$table-hover-bg-color: $cx-color-table-bg-hover;
$table-cue-color: $cx-color-table-cue-active;
$table-border-color: $cx-color-table-border-main;
$table-cell-padding-y: $cx-space-table-cell-padding-y;
$table-cell-padding-x: $cx-space-table-cell-padding-x;
$table-border-width: $cx-border-width-table-main;
$table-border-radius: $cx-border-radius-table-main;
$table-active-indicator-size: $cx-size-asset-indicator;
$table-th-font: $cx-font-table-head-text;
$table-td-font: $cx-font-table-data-text;