Skip to main content
PimentCSS v1.0.1, what's new
Home

Tables

Semantic row tables with a horizontal scroll region, plus column stacks and mobile-friendly card patterns.

Styles live in scss/components/_table.scss. PimentCSS styles semantic <table> markup; on narrow screens, pair it with a scroll container or an alternate list layout.

Responsive strategy (phone / tablet)

Recommended patterns

  • Row tables (many columns), wrap with .table-scroll so overflow stays inside a labeled region. Users swipe horizontally; the page does not.
  • Long text, add .table__text--wrap on cells that may wrap; keep sort labels and numbers in nowrap (default) when alignment matters.
  • Very small screens, consider a card/list view (same data, no horizontal scroll) for critical flows such as checkout or profile.
  • Column metrics, use .table__column when each column is a vertical stack (dashboards), not a classic data grid.

Row table + mobile cards

From min-width: 48rem you see the full table inside .table-scroll (checkbox, Name, Role, Status). Below that breakpoint, the same dataset is shown as cards (doc pattern) so nothing is crushed. Click a row to toggle selection (data-table-live); hover and selected row styles are documented in Row states.

Team members and roles
Name Role Status
Alex MartinProduct designerActive
Samira ChenEngineerActive
Jordan LeeContent strategistPaused

On phone and tablet, scroll inside the shaded region. The page itself does not scroll sideways.

Alex Martin Active
Role
Product designer
Samira Chen Active
Role
Engineer
Jordan Lee Paused
Role
Content strategist

Cell content primitives

Small pieces that can appear inside a cell: text, icon, checkbox, status dot, and so on. Place them in <td class="table__cell">, usually wrapped in .table__item when you need icon and label on one line (left-aligned). The live table above already combines several of them (checkbox + heading + status).

Not a WYSIWYG toolbar

Documentation only: one row per primitive, with the markup you would put in a real cell.

Atomic pieces you combine inside a <td class="table__cell">. Not a toolbar or a standalone menu.

Type Markup in a cell
Copy Body text
Heading Column title
Icon & copy Sortable column
Checkbox
Copy underline Link action
Status Active

Row states

Hover uses tr:hover or .table__row--hover. Selection uses .table__row--selected with aria-selected="true" on interactive rows.

State Example
DefaultNormal row
Hovertable__row--hover or tr:hover
Selectedtable__row--selected

Column layout

.table__column stacks cells vertically for KPI-style columns, not a horizontal grid.

Metric
Revenue
Users
Healthy

JavaScript

data-table-live on the <table> enables click-to-select rows. .table-scroll[data-table-scroll-hint] adds a focus hint for keyboard users. Call wireAllTables() after load.

Class reference

ClassDescription
.tableSemantic table (collapse borders, 100% width in scroll region)
.table-scrollHorizontal scroll region for row layouts on narrow viewports
.table__cellCell padding and background
.table__cell--headingHeader cell surface
.table__cell--border-bottomBottom border between rows
.table__cell--border-fullFull grid borders
.table__row--hoverHover row background
.table__row--selectedSelected row (action surface)
.table__text--wrapAllow wrapping inside scroll regions
.table__columnVertical stack of cells (column layout)
.pdoc-table-cardsDoc-only mobile card list pattern

Customize (Sass)

  1. Table spacing

    Override cell padding and compact checkbox size in cells.
    @use "pimentcss-design-system" with (
      $table-cell-padding-x: 1rem,
      $table-cell-padding-y: 0.75rem,
      $table-icon-size: 1.25rem
    );
  2. Rebuild CSS

    Run after editing _table.scss.
    npm run build:css

Accessibility (RGAA / WCAG)

Tables on small screens

  • Captions, use <caption class="sr-only"> or visible caption; associate headers with scope="col" / scope="row".
  • Scroll region, .table-scroll needs role="region", tabindex="0", and aria-label describing the dataset.
  • Selection, for clickable rows use aria-selected and a clear focus style; prefer checkboxes when multi-select.
  • Do not rely on hover alone, provide text labels and visible status dots with text.
  • Mobile alternative, when cards replace the table, keep the same heading order and expose all column values in the card body.

Next steps