Usage
After setting up the CSS, add dv-data-table to a table with header cells. Include a caption when the surrounding text does not identify the table.
<table class="dv-data-table dv-data-table--row-line">
<caption>Project milestones</caption>
<thead>
<tr><th scope="col">Milestone</th><th scope="col">Status</th></tr>
</thead>
<tbody>
<tr><th scope="row">Design</th><td>Complete</td></tr>
<tr><th scope="row">Review</th><td>In progress</td></tr>
<tr><th scope="row">Release</th><td>Scheduled</td></tr>
</tbody>
</table> Examples
Row and column separators
Use one row option and one column option. Line draws borders, gap adds space, and none disables the separator. The defaults are row lines and no column separator.
| Milestone | Status |
|---|---|
| Design | Complete |
| Review | In progress |
| Release | Scheduled |
<table class="dv-data-table dv-data-table--sm dv-data-table--row-gap dv-data-table--col-line dv-appearance-paper">
<caption>Project milestones</caption>
<thead>
<tr><th scope="col">Milestone</th><th scope="col">Status</th></tr>
</thead>
<tbody>
<tr><th scope="row">Design</th><td>Complete</td></tr>
<tr><th scope="row">Review</th><td>In progress</td></tr>
<tr><th scope="row">Release</th><td>Scheduled</td></tr>
</tbody>
</table> Striped and hover rows
Striping shades even rows. Hover shading is applied on devices that support hover. Add an appearance to provide the surface and its hover color.
| Milestone | Status |
|---|---|
| Design | Complete |
| Review | In progress |
| Release | Scheduled |
<table class="dv-data-table dv-data-table--striped dv-data-table--hoverable dv-color-primary dv-appearance-subtle">
<caption>Project milestones</caption>
<thead>
<tr><th scope="col">Milestone</th><th scope="col">Status</th></tr>
</thead>
<tbody>
<tr><th scope="row">Design</th><td>Complete</td></tr>
<tr><th scope="row">Review</th><td>In progress</td></tr>
<tr><th scope="row">Release</th><td>Scheduled</td></tr>
</tbody>
</table> API reference
| Class or attribute | Behavior |
|---|---|
dv-data-table | Styles the native table, caption and cells. Use scope on row and column headers. |
dv-data-table--smdv-data-table--mddv-data-table--lg | Controls cell padding. Medium is the default. |
dv-data-table--row-linedv-data-table--row-nonedv-data-table--row-gap | Sets the separator between rows. |
dv-data-table--col-linedv-data-table--col-nonedv-data-table--col-gap | Sets the separator between columns. |
dv-data-table--stripeddv-data-table--hoverable | Optional row treatments. |
Customization
Use the table tokens to tune density, separators, and cell surfaces.
| Property | Effect and defaults |
|---|---|
--dv-data-table-padding-block / --dv-data-table-padding-inline | Cell padding set by the selected size. |
--dv-data-table-row-gap / --dv-data-table-col-gap | Spacing for the gap variants. Both default to space-75. |
--dv-data-table-border-color | Color of line separators. Defaults to the shared border color. |
--dv-data-table-radius | Corner radius used by gap variants. Defaults to the medium radius. |
--dv-data-table-row-background | Set on a row to override the surface painted by its cells. |