stnd.build

Tables

Tables

Content

A bare <table> gets full styling with no class required: collapsed borders, uppercase small-caps headers, compact cell padding. .striped and .numeric are the only two opt-in classes.

Name Description
table Zero-class collapsed table layout with hairline borders and compact padding.
th Uppercase small-caps table header with surface background and subtle tracking.
caption Bold caption element positioned above table with rhythm padding.
.striped Zebra-stripes even <tbody> rows with a 3% foreground tint.
.numeric Right-aligns content and switches on tabular-nums for numeric columns.
.properties Table variant keeping leading identifier/token columns unwrapped.
th[aria-sort] Sortable column header: its inner button.sort inherits the header look and shows a ▲/▼ arrow for the active direction (driven by aria-sort, used by @stnd/ui DataTable).
tr[data-selected] Selected table row, filled with --color-selected.

Bare table, zero classes

<table>
  <thead>
    <tr><th>Name</th><th class="numeric">Count</th></tr>
  </thead>
  <tbody>
    <tr><td>Widgets</td><td class="numeric">42</td></tr>
  </tbody>
</table>

Live

NameCount
Widgets42

A caption and zebra stripes

<table class="striped">
  <caption>Quarterly sales</caption>
  <thead><tr><th>Quarter</th><th>Region</th><th>Notes</th></tr></thead>
  <tbody>
    <tr><td>Q1</td><td>North</td><td>Steady</td></tr>
    <tr><td>Q2</td><td>North</td><td>Up</td></tr>
    <tr><td>Q3</td><td>South</td><td>Flat</td></tr>
    <tr><td>Q4</td><td>South</td><td>Up</td></tr>
  </tbody>
</table>

Live

Quarterly sales
QuarterRegionNotes
Q1NorthSteady
Q2NorthUp
Q3SouthFlat
Q4SouthUp

Numeric columns align right with tabular figures

<table>
  <thead><tr><th>Item</th><th class="numeric">Price</th><th class="numeric">Qty</th></tr></thead>
  <tbody>
    <tr><td>Notebook</td><td class="numeric">12.50</td><td class="numeric">3</td></tr>
    <tr><td>Pen</td><td class="numeric">1.20</td><td class="numeric">120</td></tr>
    <tr><td>Stapler</td><td class="numeric">9.99</td><td class="numeric">12</td></tr>
  </tbody>
</table>

Live

ItemPriceQty
Notebook12.503
Pen1.20120
Stapler9.9912

Properties: the leading identifier column stays on one line

<table class="properties">
  <thead><tr><th>Token</th><th>Value</th><th>Description</th></tr></thead>
  <tbody>
    <tr><td><code>--space</code></td><td><code>1rlh</code></td><td>One line of the baseline grid.</td></tr>
    <tr><td><code>--radius</code></td><td><code>var(--trim)</code></td><td>The standard corner.</td></tr>
  </tbody>
</table>

Live

TokenValueDescription
--space1rlhOne line of the baseline grid.
--radiusvar(--trim)The standard corner.

Sortable headers and a selected row

<table>
  <thead>
    <tr>
      <th aria-sort="ascending"><button class="sort" type="button">Name</button></th>
      <th aria-sort="none"><button class="sort" type="button">Size</button></th>
      <th aria-sort="none"><button class="sort" type="button">Modified</button></th>
    </tr>
  </thead>
  <tbody>
    <tr><td>Alpha</td><td>12 KB</td><td>Today</td></tr>
    <tr data-selected><td>Beta</td><td>3 KB</td><td>Yesterday</td></tr>
    <tr><td>Gamma</td><td>48 KB</td><td>Last week</td></tr>
  </tbody>
</table>

Live

Alpha12 KBToday
Beta3 KBYesterday
Gamma48 KBLast week

All classes

Tables

Class Declares
.numeric text-align: right
.striped tbody tr:nth-child(even) background: rgb(from var(--color-foreground) r g b / 0.03)
.properties white-space: nowrap