Skip to content
@erikakers/slate

Table

table, caption, thead, tbody, tr, th, td, and the scroll wrapper a wide one needs. No type on table itself: a table's cells inherit from wherever it sits, and a font-size here would reset type the surrounding context legitimately chose.

The element

Contrast of every control boundary, measured rather than claimed.
SurfaceLightDark
bg3.693.80
bg-subtle3.413.56
bg-raised3.223.21
bg-inset3.503.66

Why caption reverses its flow

@erikakers/typography files caption as not yet covered: it derives caption's type at 15.24px with margins shaped for a <figcaption>, which sits below its figure. A <caption> sits above the table it labels (caption-side: top, restated rather than left to the UA), so the tight edge belongs under it instead of over it: the module's derived margins are asymmetric the wrong way round for this element. Slate takes the role's type and writes the spacing itself, reversed: margin-block: 0 var(--slate-space-3). Legitimate because caption is claimed by nothing, so this is a first source rather than a second one.

The scroll wrapper

A table wider than its container scrolls inside a wrapper rather than taking the page's own scrollbar with it (WCAG 1.4.10). The wrapper needs three attributes CSS cannot supply: tabindex="0", role="region" and an accessible name, so the region is reachable by keyboard even in engines that do not make an overflowing scroller focusable on their own.

Every derived role, at a 16px root.
RoleStepSizeLeadingTrackingWeightLeadFlowFamily
display74.5rem1.05-0.02embolder3.885168rem1.942584remHanken Grotesk
h253.0521rem1.318-0.01embolder3.885168rem0.971292remHanken Grotesk
body01.1563rem1.680emnormal0rem1.942584remPetrona
fine-20.7842rem1.680.01emnormal0.971292rem1.942584remFragment Mono

Keyboard interaction

  • Tab reaches the scroll wrapper above (tabindex="0"), which is announced as a region named "Every derived type role".
  • With the wrapper focused, the arrow keys scroll a table wider than its container (WCAG 2.1.1: a scroll container that is not keyboard-focusable cannot be scrolled by keyboard at all).
  • A table with no scroll wrapper carries no extra tab stop, because it needs none.