CSS, design tokens and themes
Design tokens, themes, contrast, forced colours, print, fluid type, a sliding pill, touch targets, an icon sprite and a self-hosted font, in plain CSS.
Design tokens in plain CSS custom properties
Design tokens as CSS custom properties in one file: colour, type, space, shape and motion, how components read them, and the same tokens for Tailwind and Figma.
More articles
11 more, newest first.
Forced colours mode in CSS: fills become edges
How Windows High Contrast and other forced colour modes repaint a page, and the CSS that keeps cards, chosen items, icons and focus rings visible.
Print styles for a web app with @media print
A print stylesheet for a web app: the light theme on paper, the navigation left out, link addresses, page breaks, tables, and the fills that must still print.
Ten themes from one stylesheet with data-theme
Ten colour themes in one CSS file: each a rule of custom properties on data-theme, with color-scheme, the system's dark setting, and a theme inside a theme.
Fluid type with clamp() that grows with zoom
Why a clamp() font size made of vw alone ignores browser zoom and text size, what a rem part changes, and how to check fluid headings against WCAG 1.4.4.
Testing colour contrast in every theme
Test WCAG colour contrast in every theme automatically: rules for token pairs measured in Node, then the text of real pages measured on its ground in a browser.
Segmented control with a sliding pill in CSS
A segmented control on radio inputs, with a pill that slides to the choice in CSS or a little script, and stays still for reduced motion and forced colours.
CSS prefers-contrast: more, one grey step up
Answer prefers-contrast: more in CSS by moving each grey token one step towards the ink and giving fills an edge, then test it in DevTools and Playwright.
44px touch targets without bigger buttons
Give a small button a 44 pixel hit area with a positioned ::before, see what WCAG 2.5.8 and 2.5.5 ask, and measure the area with elementFromPoint.
An SVG icon sprite inside one script
Build an SVG sprite of symbol elements from a script, draw each icon with use and currentColor, hide it from screen readers and flip arrows right to left.
Self-hosting a web font with one woff2 file
Self-host a variable font from one woff2 file: the @font-face rule, font-display, a preload with crossorigin, CORS for other sites and the OFL licence.
Generate an accessible colour theme from four colours
Derive every colour token of a theme from a page, a tray, an ink and an accent: greys mixed in OKLab, each placed by its contrast, then checked against WCAG.
New articles in a feed
Add the Atom feed to a feed reader, and each new article comes to you whole, with its code.