CSS for plain, semantic HTML with a checked vocabulary, designed so coding agents get it right the first time.
Compact core · 20 / 20 agent tasks correct · 4,750 → 210 lines of app CSS in a real migration · no JS, build step or dependencies
This app shell (kitchen-sink/app.html) has no CSS of its own. The
screenshot follows your GitHub theme: switch between light and dark to see the other mode.
Write HTML. It already looks finished.
<form data-tm-layout="stack" data-tm-gap="md">
<label>Email
<input type="email" aria-invalid="true">
<small data-tm-tone="danger">Enter a full address, like name@example.com.</small>
</label>
<div data-tm-layout="row" data-tm-gap="sm" data-tm-justify="end">
<button type="button" data-tm-variant="outline" data-tm-tone="danger">Discard</button>
<button>Save</button>
</div>
</form>No classes, no margins. Style (data-tm-variant) and color (data-tm-tone) are separate axes, so an
outline danger button is just both. aria-invalid is the error state and the error styling.
A typo fails the build, and the error tells you the fix.
$ npx temper check src
page.html:4:13 error TM101 data-tm-variant="danger" is not valid. Did you mean data-tm-tone="danger"? (allowed: secondary, outline, ghost, link, item)
page.html:7:3 error TM103 <button data-tm-icon="x"> has no visible text. Add aria-label.
2 error(s), 0 warning(s); 1 fixable with --fix
--fix rewrites the safe ones. The Vite plugin runs the same check in every build, and in Svelte,
Vue and JSX it follows expressions: failed ? 'danger' : 'sucess' is an error.
A modal dialog, no JavaScript.
<button commandfor="confirm" command="show-modal" data-tm-tone="danger">Delete…</button>
<dialog id="confirm" aria-labelledby="confirm-title">
<h2 id="confirm-title">Delete “Team retro”?</h2>
<footer>
<button commandfor="confirm" command="close" data-tm-variant="ghost">Keep</button>
<button data-tm-tone="danger">Delete event</button>
</footer>
</dialog>command="show-modal" is the declarative showModal(): the button opens the dialog as a modal,
with no script. It animates in and out, blocks the page behind it and closes on Escape. That's the
browser's own <dialog>, styled.
Rebrand with two numbers.
:root { --tm-hue: 180; --tm-chroma: 0.12; } /* teal, in light and dark mode */Every color is derived from those in OKLCH, and a test sweeps all 360 hues to keep text and buttons at WCAG AA contrast in both modes.
A dark section on a light page is one attribute.
<section data-tm-theme="dark" data-tm-pad="xl">…</section>Your CSS always wins. Everything lives in @layer tm.* behind :where(), so .card { padding: 2rem }
beats it. You never need !important.
npm install @tiaforge-ui/temperimport '@tiaforge-ui/temper/core.css';Then tell your agent about it, in CLAUDE.md or AGENTS.md:
UI uses temper. Read node_modules/@tiaforge-ui/temper/llms.txt before editing markup
(llms-full.txt before building whole pages). Run `npx temper check src` after editing.The optional modules, the Vite plugin and use without a bundler are under Install.
Every variant against every tone, plus badges, callouts and form controls:
A mail client from the kitchen sink (kitchen-sink/index.html; the
three-pane layout and the message list use a few lines of demo CSS):
npm run readme-shots regenerates them (2560×1440).
1. The vocabulary is closed and enforced. Each attribute is one axis with a fixed list of values, so the checker can do more than catch typos:
- Placement:
data-tm-pairsonly on adl,data-tm-railonly as a direct child of[data-tm-shell],data-tm-colsonly withdata-tm-layout="grid", anddata-tm-railneedsapp.cssimported somewhere. - Expressions: in Svelte, Vue and JSX it works out every value an expression can produce, and
flags
cond && 'danger', which rendersdata-tm-tone="false". - Types:
@tiaforge-ui/temper/react,/vue,/astro,/svelteand/sinterlet tsc reject things likedata-tm-collapsed={collapsed}, wherefalsewould renderdata-tm-collapsed="false". - Safe fixes and renames:
--fixonly applies fixes that can't go wrong (a value moved to its axis, a typo with one close match, a value dropped from a boolean). Deprecated names keep working until the next major version, with a warning that--fixresolves. - Accessibility: buttons without a name and fields without a label (a placeholder doesn't count).
- Your own CSS, as warnings, so it doesn't grow back after a migration:
!important, fixed colors that ignore dark mode, outer margins, spacing that equals a scale step (16px→var(--tm-space-md), fixable), rules that restyle[data-tm-variant]instead of setting tokens, andmargin/paddinginstyle. Atemper-ignorecomment silences one line.
It reads HTML, Svelte, Astro, Vue and JSX, plus --tm-* tokens in CSS. With classes none of this is
possible: nothing knows that .secondary.outline.contrast is a contradiction.
2. Nothing has an outer margin. The parent owns all space: data-tm-gap between children,
data-tm-pad inside, one scale xs sm md lg xl everywhere. This removes the most common failure we saw
with other libraries: agents stacking margin overrides against built-in margins. The one exception is
long-form text you don't write yourself (rendered Markdown, CMS HTML, a mail body): data-tm-prose
(prose.css) spaces its paragraphs, headings, lists and figures from the text flow.
3. State is HTML and ARIA. disabled, aria-invalid, aria-busy (spinner, blocks input),
aria-pressed, aria-current, :user-invalid, [open], :popover-open. Correct accessibility
markup is the styling, so it doesn't get left out.
4. Modern HTML works as-is. Dialog invokers, [popover] with light dismiss, role="switch"
checkboxes, details, dl as label/value pairs, enter and exit animations with @starting-style,
data-tm-sheet side panels and bottom sheets that slide in from their edge.
No JS components to wire up.
5. Dark mode is designed, not inverted. Colors are declared once with light-dark() at fixed
OKLCH lightness; raised surfaces get lighter and accents less saturated in the dark. Add
--tm-primary: var(--tm-accent) to give main buttons the brand color.
6. Right to left, high contrast and print work. dir="rtl" mirrors the layout and every
component (logical properties throughout). In Windows high contrast (forced colors) icons, switches and
selected items stay visible. A printed page leaves out the app chrome and prints scroll areas in full.
A data-tm-sr-only skip link shows while it has focus.
These are the things we measured instead of assuming.
Agent eval. Ten UI tasks from a real calendar/mail app (event form, delete confirmation, outline danger
button, invalid field, toolbar, status badges, settings switches, dark mode, brand color, exact spacing). A fresh
agent wrote each page with only temper's llms.txt and llms-full.txt as context; a grader then measured the
result in headless Chrome at 1024×768, in light and dark mode: colors, contrast, hue, alignment, sizes, gaps,
accessible names (82 checks per run). Re-run for 0.5, with the data-tm-* names:
| Runs (2 each) | Tasks fully correct | Checks passed | Classes used | Own CSS |
|---|---|---|---|---|
temper, with temper check |
20 / 20 | 164 / 164 | 0 | two tokens on :root (brand task) |
| temper, without the checker | 20 / 20 | 164 / 164 | 0 | the same |
Three of the four runs first missed one check: they set Start and End side by side, as temper's form recipe does, and the grader wanted one column. The check now asks that each row of fields start at one x (a ragged form still fails), which is what it was meant to test. The checker found nothing to fix in either run with it, so here the vocabulary carries the result and the checker is the safety net.
The harness, the agents' pages and a reference solution are in scripts/agent-eval/, so
the numbers can be rerun. An earlier version of the same tasks (with the unprefixed names; that harness was not
kept) also compared Pico CSS (11 / 20) and daisyUI (10 / 20); their misses were things a reader won't spot in code
review: button text below WCAG contrast in dark mode, an "outline danger" button that came out blue, badges with
unreadable text, an icon button that wasn't square. It's a small sample: 10 tasks × 2 runs.
A real migration. caley, a calendar, mail and contacts app, was moved from Pico CSS to temper page by page: contacts, mail, calendar, search, settings and login, including the Svelte components they share. A coding agent did the work from the docs, in four steps.
| Pico | temper | |
|---|---|---|
| App CSS (SCSS and component styles) | about 4,750 lines | about 210 lines |
| CSS shipped to the contacts page (gzip) | about 15.8 KB | 6.5 KB |
| Pico in sources or build output | everywhere | none |
| Inspector errors on the six pages | 0 |
What's left in the app is mostly inline custom properties like style="--tm-min: 13rem" and a few
app-specific rules. The navigation rail with collapse and phone drawer, avatars, clickable cards,
dropdown menus and checklists, the combobox, calendar grids and event chips, tabs and list rows,
dialogs and the floating action button all come from the library. For comparison, a separate Pico
rewrite of the contacts page alone still needed 134 lines of custom CSS. Every gap the migration hit
went back into the library or its docs; the ranked list is in
docs/backlog-from-caley.md.
Tests keep the docs honest. npm test asserts that every attribute and value in vocab.json
has a CSS selector and every selector has a vocab entry, that every documented token is declared,
and that llms.txt, llms-full.txt and html-custom-data.json are regenerated from vocab.json
and not stale. Docs, editor autocomplete and the checker can't drift apart from the CSS.
Contrast is checked for every hue. npm run contrast sweeps the accent hue 0–360 in light and
dark mode, lets headless Chrome resolve the real tokens, and checks WCAG AA for every text and
background pair (4.5:1 for text and solid buttons, 3:1 for the focus ring and scrollbar thumbs). All hues pass at the
default chroma. npm test runs the same check for the default look and the two theme examples.
Visual regression tests. npm run visual screenshots the kitchen-sink pages in 37 states (light and
dark, compact density, phone width, both theme examples, open menus, a scrolled dialog, side and bottom
sheets, the drawer) and compares them pixel by pixel with baselines in test/visual/. A change writes a diff
image with the changed pixels in red. Baselines depend on fonts and the Chrome version, so they are
compared on the machine that made them; npm run visual -- --update accepts an intended change.
Size budgets are enforced. npm run build fails above budget: core.css 6.8 KB, icons.css 2.8 KB, expressive.css 2.1 KB, all.css 14.9 KB, every other file 1.5 KB (brotli). Right now core.css uses 100 % of its budget, icons.css 97 %, expressive.css 98 % and all.css 98 %, so real growth means raising a budget on purpose (in scripts/build.mjs). npm test checks this paragraph and the table against a real build; npm run gen rewrites them.
| File | brotli | What's in it |
|---|---|---|
core.css |
6.8 KB | tokens, reset, type, layout (incl. sticky bars), buttons (incl. joined groups), forms (incl. meter, color, multi-row select), dialog (scroll lock, header and footer stay in view), popover, details, table, card (incl. edge-to-edge media), badge, callout, avatar |
app.css |
1.5 KB | app shell, navigation rail (collapsible, drawer on phones), floating action button, panes that adapt to their own width (data-tm-container) |
menu.css |
1.0 KB | dropdown menus (group labels, shortcut hints) |
feedback.css |
1.0 KB | toasts, tooltips (anchor-positioned, never clipped by a scroll container) |
table.css |
0.8 KB | data tables: sortable headers (aria-sort), row selection, number columns, sticky header |
icons.css |
2.7 KB | 56 default Lucide icons via data-tm-icon |
pico-compat.css |
0.4 KB | opt-in, while migrating from Pico: maps its --pico-* variables to temper tokens |
forms.css |
1.1 KB | fields with an icon, unit or button (data-tm-field), read-only and required marks, autofill tint, range slider, indeterminate progress |
prose.css |
0.6 KB | long-form text (data-tm-prose): rhythm between blocks, reading measure, fluid headings, inline images in text, plain layout tables, blockquote, figure |
sheet.css |
0.6 KB | dialogs as sheets (data-tm-sheet): side panels at the inline end or start, bottom sheets, a bottom sheet on phones only |
expressive.css |
2.0 KB | opt-in voice: glass, gradient and mesh surfaces, grain, brand-tinted elevation and halo, display type and font pairings, hero and bento layouts, seeded gradients (data-tm-surface, data-tm-display, data-tm-bento, …) |
drag.css |
0.8 KB | dragging and resizing: drag handles (data-tm-handle, grip, grab cursor, quiet until hover), the lifted row (data-tm-lifted), drop lines and targets (data-tm-drop) |
all.css |
14.7 KB | everything |
enhance/customizable-select.css |
0.8 KB | opt-in: the open <select> list styled like a menu (see below) |
llms.txt(~140 lines): rules, every attribute and value, tokens, icons and an anti-pattern table ("don't / do"). Enough for small edits.llms-full.txt: every attribute in detail plus copy-paste recipes: form, card, dialog, toolbar, status, settings rows, app shell, dropdown, card grid, label/value pairs, long-form text, page layout. Agents copy recipes instead of inventing markup.- Names that don't collide with habits. No numeric spacing (agents read
4as Tailwind's 1rem), no.btn-primary. Values likesecondary outline ghost linkfollow shadcn, which models have seen a lot. temper checkgives the agent a precise, fixable error instead of a silently wrong page.temper-inspectreplaces the screenshot loop. It loads a running page in headless Chrome at a wide and a narrow width, in light and dark mode, opens every dialog and popover through its real button, and reports horizontal overflow, misplaced overlays, low contrast, unlabeled controls and covered click targets as text, with a selector for each.--sheetwrites one contact-sheet image per page when you do want to look, each state at full size and a crop of each finding's element.--why "<selector>"names the rule behind each style of an element,--outlineprints the page as a screen reader gets it,--fail,--emptyand--delaycheck the page when a request fails, answers with an empty list or is pending,--connectchecks a tab of a running browser in the state a test or an agent brought it into, and--unusedlists CSS rules that match nothing.html-custom-data.jsongives VS Code (and other editors) autocomplete and hover docs for every attribute value.
npm install @tiaforge-ui/temperimport '@tiaforge-ui/temper/core.css'; // always
import '@tiaforge-ui/temper/app.css'; // app shell, navigation rail, floating action button
import '@tiaforge-ui/temper/menu.css'; // dropdown menus
import '@tiaforge-ui/temper/feedback.css'; // toasts, tooltips
import '@tiaforge-ui/temper/table.css'; // data tables
import '@tiaforge-ui/temper/prose.css'; // long-form text: articles, rendered Markdown, mail bodies
import '@tiaforge-ui/temper/forms.css'; // fields with icons, units and buttons; range, read-only, required
import '@tiaforge-ui/temper/sheet.css'; // dialogs as side panels and bottom sheets
import '@tiaforge-ui/temper/drag.css'; // drag handles for sortable lists and boards
import '@tiaforge-ui/temper/expressive.css'; // surfaces, display type, hero and bento, seeded colour
import '@tiaforge-ui/temper/icons.css'; // the default icon set
// or everything: import '@tiaforge-ui/temper/all.css';Add <meta name="color-scheme" content="light dark"> to avoid a flash of the wrong theme on load.
// vite.config.js
import temper from '@tiaforge-ui/temper/vite';
export default {
plugins: [
temper(),
// every Lucide icon by name, only the used ones emitted, plus your own SVG folder:
// temper({ icons: { dir: 'src/icons' } }) and import 'virtual:temper-icons.css';
// thinner Lucide strokes for light type (0.5 to 3, Lucide's own is 2; folder icons stay as they are):
// temper({ icons: { strokeWidth: 1.5 } })
// migrating step by step? check only the migrated parts:
// temper({ paths: ['src/contacts'] })
// opt-in enhancements, appended to core.css / all.css (see Browser support):
// temper({ enhance: ['customizable-select'] }) or enhance: 'all'
// smaller builds: drop rules for data-* attributes and values the project never uses
// temper({ prune: true })
// rendered-page findings in the dev terminal (overflow, contrast, clipped text); needs temper-inspect installed
// temper({ inspect: true })
],
};The plugin and @tiaforge-ui/temper/check come with type declarations, so a strict vite.config.ts
type-checks its options (they don't need vite itself to be installed for that).
icons, enhance and prune work whichever way temper is imported: from JS (import 'virtual:temper-icons.css')
or from a CSS file (@import '@tiaforge-ui/temper/core.css'; @import 'virtual:temper-icons.css';), which a
static site without a script needs. Vite reads a CSS @import itself, past every plugin, so the plugin writes
what such an @import should get into Vite's cache folder (node_modules/.vite/temper/) and points the
@import there. The icon CSS is also a real file, written when the config resolves, and resolve.alias points
virtual:temper-icons.css at it, so tools that compile project CSS through Vite's preprocessCSS (sinter, for
image sizes) find it too. Sass, Less and Stylus resolve their own imports, which the plugin cannot reach: it warns, and
temper is then imported from JS or a plain .css file.
A build also checks its own output: every data-tm-icon value in the built pages needs an icon rule in the built
CSS, or the plugin warns with page and line (warningsFail makes that fail the build). That catches names the
source does not show, such as a value bound from a JSON file whose SVG was deleted or misspelled.
prune scans every source file under the Vite root (or prune: { paths }) and only drops a rule
when an attribute or value it requires appears nowhere. Values it can't resolve (data-tm-icon={icon})
keep every value of that attribute, and data-* names in scripts (el.dataset.tmTone = …) keep the
whole attribute. Gains depend on how much is computed: about 8% of all.css for caley, where icons
and tones are mostly computed. npm run visual:prune checks that pruning changes nothing visible in
the kitchen sink.
inspect: true (install @tiaforge-ui/temper-inspect alongside, an optional peer dependency of the same version
or newer; with a missing or older one the plugin says so and skips it) runs that package's audit inside the page your dev
server serves: after load, after every hot update, when the page changes and when you open a dialog or popover
(each open one is checked as its own state, like temper-inspect does). What it finds (overflow, contrast, clipped
text, a dialog stuck in a corner) is printed in the dev terminal next to the static check's diagnostics, once per
change, as src/App.svelte:12 error contrast: …: in dev, plain HTML elements in your pages and components get a
data-tm-src="file:line" attribute so a finding can name its source line (inspect: { source: false } turns that
off). It audits what is on the page now; it does not resize the window or open dialogs by itself, which
temper-inspect does in headless Chrome (use that in CI). Dev server only, never in a build.
Icons from the plugin need lucide-static installed (optional peer dependency). The plugin emits the
icons your markup names: static ones and every literal an expression can produce
(data-tm-icon={dark ? 'sunrise' : 'moon-star'} emits both). A name it can't see, like
data-tm-icon={item.icon} from a data array, would render blank, so the plugin prints a notice with the file
and line instead (it doesn't fail the build). List such names in icons: { include: ['rocket', 'star'] },
then mark the line with a temper-ignore comment to silence the notice. temper check --lucide prints the
same notice.
The files in dist/ are plain CSS. Link them directly and run npx temper check in CI.
Enhancements are separate files: link dist/enhance/<id>.css after core.css.
Chrome / Edge 123+, Firefox 120+, Safari 17.5+ (Baseline 2024, set by light-dark()). No vendor
prefixes and no fallbacks for older browsers; that is part of how it stays small.
Newer features that not every engine has yet are opt-in enhancements, one file each, named by
their web-features id. Without them everything
still looks finished. Turn them on with the Vite plugin's enhance option, or import
@tiaforge-ui/temper/enhance/<id>.css after core.css.
| Enhancement | What it does | Where it works |
|---|---|---|
customizable-select |
appearance: base-select: the open list of a single <select> gets the menu look, an accent checkmark, styled optgroup/hr, and rich options via <selectedcontent> |
Chromium 135+; other browsers keep the native picker |
llms-full.txt: the complete reference (it's written for agents, and it's the best human reference too).kitchen-sink/: every component, app-like screens, and two alternative themes intheme-examples.css.SPEC.md: design principles and the reasoning behind them.CONTRIBUTING.md: how a release is made.
MIT. The default icons are from Lucide (ISC, see LICENSE-lucide).