Table
Provides style variants for displaying tabular data.
Provides style variants for displaying tabular data.
npm install @vrembem/table@use "@vrembem/table";Table is built as a Sass module. Sass options are used to control CSS output, while design token CSS variables control the styling of the component. Below are the available configuration options.
Table comes with the following Sass configuration options that can be set using either the config module or Sass with clause methods.
@use "@vrembem/table" with (
$config: (
// Toggle for outputting table--mobile modifier breakpoint variants
// @type boolean
"table-mobile": (
"breakpoints": true,
"attr": "data-mobile-label"
)
)
);Table uses design token CSS variables in a reference and fallback pattern. Variables are referenced in the component's styles but are not directly defined; instead, they are provided with sensible fallbacks.
| Variable | Fallback |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
For basic table styles, only the table component class is required. Use proper HTML table markup and styles should apply as expected.
| Name | Mass | Class | Variant |
|---|---|---|---|
| Locust | 20t | Light | LCT-1V |
| Shadow Hawk | 55t | Medium | SHD-2H |
| Thunderbolt | 65t | Heavy | TDR-5S |
| BattleMaster | 85t | Assault | BLR-1G |
<table class="table">
<caption>Example of a table caption.</caption>
<thead>
<tr>
<th>Name</th>
<th>Mass</th>
<th>Class</th>
<th>Variant</th>
</tr>
</thead>
<tbody>
<tr>
<td>Locust</td>
<td>20t</td>
<td>Light</td>
<td>LCT-1V</td>
</tr>
<tr>
<td>Shadow Hawk</td>
<td>55t</td>
<td>Medium</td>
<td>SHD-2H</td>
</tr>
<tr>
<td>Thunderbolt</td>
<td>65t</td>
<td>Heavy</td>
<td>TDR-5S</td>
</tr>
<tr>
<td>BattleMaster</td>
<td>85t</td>
<td>Assault</td>
<td>BLR-1G</td>
</tr>
</tbody>
</table>For simple responsive table styles, wrap your tables in a div with the overflow-auto utility. This provides horizontal scrolling when tables can't fit in their container.
| Book | Pages | Quote |
|---|---|---|
| The Hobbit | 272 | "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?" |
| The Fellowship of the Ring | 377 | "I wish it need not have happened in my time," said Frodo. "So do I," said Gandalf, "and so do all who live to see such times. But that is not for them to decide. All we have to decide is what to do with the time that is given us." |
| The Two Towers | 322 | "War must be, while we defend our lives against a destroyer who would devour all; but I do not love the bright sword for its sharpness, nor the arrow for its swiftness, nor the warrior for his glory. I love only that which they defend." |
| The Return of the King | 277 | "But I have been too deeply hurt, Sam. I tried to save the Shire, and it has been saved, but not for me. It must often be so, Sam, when things are in danger: some one has to give them up, lose them, so that others may keep them." |
<div class="overflow-auto">
<table class="table">
...
</table>
</div>Use the hug-content table utility when a table cell should fit the size of its contents. This is useful for columns with compact content like checkboxes, icons, or action buttons that shouldn't take up more space than necessary.
| Name | Mass | Class | Variant | |
|---|---|---|---|---|
| Locust | 20t | Light | LCT-1V | |
| Shadow Hawk | 55t | Medium | SHD-2H | |
| Thunderbolt | 65t | Heavy | TDR-5S | |
| BattleMaster | 85t | Assault | BLR-1G |
<table class="table">
<thead>
<tr>
<th class="hug-content"></th>
...
</tr>
</thead>
<tbody>
...
</tbody>
</table>Switches a table layout to fixed and adds ellipsis overflow styles to table cells and headers.
| Book | Pages | Quote |
|---|---|---|
| The Hobbit | 272 | "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?" |
| The Fellowship of the Ring | 377 | "I wish it need not have happened in my time," said Frodo. "So do I," said Gandalf, "and so do all who live to see such times. But that is not for them to decide. All we have to decide is what to do with the time that is given us." |
| The Two Towers | 322 | "War must be, while we defend our lives against a destroyer who would devour all; but I do not love the bright sword for its sharpness, nor the arrow for its swiftness, nor the warrior for his glory. I love only that which they defend." |
| The Return of the King | 277 | "But I have been too deeply hurt, Sam. I tried to save the Shire, and it has been saved, but not for me. It must often be so, Sam, when things are in danger: some one has to give them up, lose them, so that others may keep them." |
<table class="table table--ellipsis">
...
</table>Space will be split equally between columns when table--ellipsis is applied. For more control over specific column widths, use the <colgroup> and <col> elements and set their desired widths as needed.
| Book | Pages | Quote |
|---|---|---|
| The Hobbit | 272 | "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?" |
| The Fellowship of the Ring | 377 | "I wish it need not have happened in my time," said Frodo. "So do I," said Gandalf, "and so do all who live to see such times. But that is not for them to decide. All we have to decide is what to do with the time that is given us." |
| The Two Towers | 322 | "War must be, while we defend our lives against a destroyer who would devour all; but I do not love the bright sword for its sharpness, nor the arrow for its swiftness, nor the warrior for his glory. I love only that which they defend." |
| The Return of the King | 277 | "But I have been too deeply hurt, Sam. I tried to save the Shire, and it has been saved, but not for me. It must often be so, Sam, when things are in danger: some one has to give them up, lose them, so that others may keep them." |
<table class="table table--ellipsis">
<colgroup>
<col />
<col style="width: 5em;" />
<col />
</colgroup>
...
</table>Adds hover, focus and focus-within state styles for table row (<tr>) elements.
| Name | Mass | Class | Variant | |
|---|---|---|---|---|
| Jenner | 35t | Light | JR7-D | |
| Hunchback | 50t | Medium | HBK-4G | |
| Catapult | 65t | Heavy | CPLT-C1 | |
| Atlas | 100t | Assault | AS7-D |
<table class="table table--hover">
...
</table>A modifier that adds mobile styles to a table so that it's easier to read on mobile devices. This is done by using the data-mobile-label attribute on table cells that should correspond to the table column header for that specific cell.
| Name | Mass | Class | Variant |
|---|---|---|---|
| Jenner | 35t | Light | JR7-F |
| Hunchback | 50t | Medium | HBK-4P |
<table class="table table--mobile">
<thead>
<tr>
<th>key</th>
<th>value</th>
</tr>
</thead>
<tbody>
<tr>
<td data-mobile-label="key">...</td>
<td data-mobile-label="value">...</td>
</tr>
</tbody>
</table>The mobile label value will be truncated if it exceeds the width set by --vb-table-mobile-label-width CSS variable. The mobile label attribute used can be changed using the attr key in the table-mobile config options map.
This modifier come with media breakpoint variants. This allows changing styles based on a specific breakpoint key in the breakpoints config options map. Breakpoint variants output can be toggled using the breakpoints key in the table-mobile config options map (default: true).
Available variants
xs:table--mobilesm:table--mobilemd:table--mobilelg:table--mobilexl:table--mobileAdjust the padding of a table's <th>, <td>, and <caption> elements. These modifiers are generated using key/value pairs of the table-padding config options map.
| Name | Mass | Class | Variant |
|---|---|---|---|
| Griffin | 55t | Medium | GRF-1N |
| Wolverine | 55t | Medium | WVR-6R |
| Name | Mass | Class | Variant |
|---|---|---|---|
| Griffin | 55t | Medium | GRF-1N |
| Wolverine | 55t | Medium | WVR-6R |
<table class="table table--padding-sm">...</table>
<table class="table table--padding-lg">...</table>Available variants
table--padding-smtable--padding-mdtable--padding-lgThese modifiers come with media breakpoint variants. This allows changing styles based on a specific breakpoint key in the breakpoints config options map. Breakpoint variants output can be toggled using the breakpoints key in the table-padding config options map (default: true).
Current view-port width: ...
| Name | Mass | Class | Variant |
|---|---|---|---|
| Griffin | 55t | Medium | GRF-1N |
| Wolverine | 55t | Medium | WVR-6R |
<table class="table table--padding-sm lg:table--padding-md xl:table--padding-lg">
...
</table>Available variants
sm:table--padding-[key]md:table--padding-[key]lg:table--padding-[key]Adds zebra styled rows to a table to help increase its readability. This is done by alternating the background color of rows to help guide the reader's eye.
| Name | Mass | Class | Variant |
|---|---|---|---|
| Firestarter | 35t | Light | FS9-A |
| Uziel | 50t | Medium | UZL-6P |
| Crusader | 65t | Heavy | CRD-6T |
| Cyclops | 90t | Assault | CP-11-P |
<table class="table table--striped">
...
</table>Adds table styles based on the provided value.
| Name | Mass | Class | Variant |
|---|---|---|---|
| Griffin | 55t | Medium | GRF-2N |
| Wolverine | 55t | Medium | WVR-7K |
<table class="table table--style-rowed">
...
</table>| Name | Mass | Class | Variant |
|---|---|---|---|
| Griffin | 55t | Medium | GRF-2N |
| Wolverine | 55t | Medium | WVR-7K |
<table class="table table--style-bordered">
...
</table>Available variants
table--style-rowedtable--style-bordered