Add web-frontend, web-project-audit and web-project-scaffold-containerized-python skills

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Neil Bantoc 2026-11-04 14:46:25 -08:00
parent 59fc08fa5f
commit 5201aa9bd5
63 changed files with 3042 additions and 0 deletions

View file

@ -0,0 +1,128 @@
---
name: web-frontend
description: House style and build guidance for any web frontend work, so pages and apps come out with a deliberate, polished look and feel instead of generic AI-generated design. Use whenever writing or restyling frontend code — a landing page, marketing site, web app, dashboard, admin tool, component library, or a single component or page in an existing React/Vue/Svelte/plain-HTML project. Provides a token-based design system (color in OKLCH with light/dark themes, type scale, spacing, radius, motion), font pairings, a default library stack, layout patterns, component recipes, copywriting rules and a pre-ship checklist.
---
# Web Frontend
The aim: frontends that look like a design lead at a small studio made them. That means a specific visual identity grounded in the subject, precise spacing and type, both themes designed, and none of the stock AI-generated looks. The look comes from **process plus a small system**, not a fixed template: the tokens in `assets/tokens.css` are the structure, and each project gets its own hue, fonts and one bold move.
`SKILL_DIR` is the directory holding this file. Reference files, read when the step needs them:
| File | Read when |
|---|---|
| `assets/tokens.css` | Always, before writing styles. Copy it into the project and tune it. |
| `references/libraries.md` | Choosing a stack or adding a dependency. |
| `references/layout.md` | Building page shells, grids, app layouts, dashboards. |
| `references/components.md` | Writing buttons, inputs, cards, tables, nav, toasts, empty states. |
| `references/tailwind.md` | The project uses Tailwind (or you are choosing it). |
## Precedence
1. The user's own words. If they name a look, follow it exactly, even one listed under "Avoid" below.
2. The project's existing design system: a tokens/theme file, Tailwind config, component library, CLAUDE.md. Apply it and fill gaps only. Never re-skin an existing product unasked.
3. This skill.
When the output is a claude.ai Artifact, the `artifact-design` skill's page contract (CSP, skeleton, safe areas) wins over anything here; this skill's taste still applies.
## Process
1. **Read the request and pick a treatment.**
- *Utilitarian* (internal tool, dashboard, admin, docs, settings, a feature inside an app): polished, quiet, dense where useful. No hero. Flourishes kept to near zero.
- *Editorial* (landing page, portfolio, launch page, game, something meant to be shared): an opinionated identity with one real aesthetic risk.
- If unsure, choose utilitarian done well. A well-composed page is always acceptable; an over-designed one sometimes isn't.
2. **Define the subject.** One concrete subject, its audience, and the page's single job. Pull at least one detail only this subject would have (its units, terms of art, document conventions) into the content itself. Use real copy, never lorem ipsum.
3. **Set the tokens.** Copy `assets/tokens.css` and change, at minimum:
- `--hue` (and maybe `--chroma`): the accent's hue, chosen from the subject's world. The neutrals pick up a faint tint of it automatically.
- `--font-display`, `--font-body`, `--font-mono` from the pairing table below.
- A one-line layout-concept comment above `:root` (e.g. `/* Layout: two-pane ledger, filters left, results right */`).
Every color, size and space in the code then comes from a token. No hex literals in components.
4. **Lay out with the patterns** in `references/layout.md`. Get structure right at phone width (~400px) and desktop before adding detail.
5. **Build components** from `references/components.md`, styled only through tokens.
6. **Write the copy** by the rules below.
7. **Run the checklist** at the end of this file. Render it once if you can (dev server plus a screenshot, or Playwright), fix what you see in one pass, and stop.
## The system in brief
Everything below is defined in `assets/tokens.css`.
- **Color:** OKLCH. One accent hue drives `--accent`, `--accent-fg`, `--accent-soft` and a faintly tinted neutral ramp (`--bg`, `--surface`, `--surface-2`, `--border`, `--fg`, `--fg-muted`, `--fg-subtle`). Semantic colors (`--ok`, `--warn`, `--danger`, `--info`) are separate from the accent and never stand in for it.
- **Themes:** light on bare `:root`. Dark redefines the same tokens under `@media (prefers-color-scheme: dark)`, guarded by `:root:not([data-theme="light"])`, and again under `:root[data-theme="dark"]`, so an explicit toggle wins both ways. Dark is designed, not inverted: surfaces get lighter as they rise, the accent gets lighter and a little less saturated, and borders carry more of the separation than shadows do.
- **Type:** a modular scale (ratio 1.2 for UI, 1.25 to 1.333 for editorial) from `--text-xs` to `--text-4xl`. Body copy 16px minimum on the web (15px is fine in dense tools). Measure ~65ch. Headings `text-wrap: balance`, paragraphs `text-wrap: pretty`. Uppercase labels get `letter-spacing: 0.06em`. Digits that line up use `tabular-nums`.
- **Space:** a 4px base, `--space-1` … `--space-16`. Siblings get spacing from `gap` in flex/grid, not margins.
- **Radius:** small and consistent. `--radius-sm` 4px for inputs and chips, `--radius-md` 8px for cards and popovers, `--radius-full` for pills and avatars. Not everything is rounded.
- **Elevation:** three shadows only, used by role: a raised card (rarely), a popover/menu, and a modal.
- **Motion:** 120 to 200ms with `--ease-out` for UI, one orchestrated moment at most on editorial pages, everything wrapped in `prefers-reduced-motion`.
## Font pairings
All on Google Fonts (or self-host with `@fontsource/*`). Always declare a full fallback stack. Pick by the subject's character, not by habit. Avoid the defaults listed under "Avoid".
| Character | Display | Body | Mono / data |
|---|---|---|---|
| Precise, technical, product UI | Geist | Geist | Geist Mono |
| Warm, humane, consumer | Bricolage Grotesque | Figtree | JetBrains Mono |
| Editorial, long-form, cultural | Newsreader | Source Sans 3 | IBM Plex Mono |
| Engineered, industrial, data-heavy | IBM Plex Sans Condensed | IBM Plex Sans | IBM Plex Mono |
| Playful, crafted, games | Fredoka or Gluten (headings only) | Nunito Sans | Martian Mono |
| Luxury, fashion, quiet confidence | Cormorant Garamond | Hanken Grotesk | DM Mono |
| Civic, institutional, trustworthy | Public Sans | Public Sans | Roboto Mono |
Use the display face with restraint: headings and one or two hero moments. For utilitarian work it is fine for display and body to be the same family at different weights.
## Avoid (the stock AI-generated looks)
Unless the user asks for them:
- Warm cream background (#F4F1EA-ish) with serif display and terracotta accent.
- Near-black page with a single acid-green or vermilion pop.
- Purple-to-blue gradient hero on white; gradient text on headlines.
- Inter or Space Grotesk as the unexamined "safe" face.
- Emoji as section icons or bullet markers.
- Everything centered; every block a rounded card with the same shadow; an accent bar down the left of rounded cards.
- `rounded-2xl` + `shadow-lg` on everything; glassmorphism blur panels.
- Numbered `01 / 02 / 03` markers on content that isn't a sequence.
- A `100vh` hero that pushes all real content below the fold.
- Big-number stat tiles as the opener when the numbers aren't the point.
- Fake logos ("Trusted by…") and invented testimonials.
## Principles that make it look deliberate
- **One bold move.** Put the boldness in one place (a type treatment, a color field, an interactive hero, a striking grid) and keep everything around it quiet. If the accent fights the background, desaturate it or shift it to an analogous hue.
- **Hierarchy through type and space first,** then color, and only then borders and shadows. Card styling marks something as a separate object, so use it by role.
- **Consistent repeated elements.** Same padding, baselines and placement across sibling cards, rows and badges. Let content set heights. Pick a column count the items fill evenly.
- **Structure encodes information.** Eyebrows, numbering, dividers and labels must say something true about the content.
- **Complete at rest.** Everything readable is visible on load. Animations start from a visible state, never `opacity: 0` waiting on a scroll observer. Tools open in a realistic working state with sample data clearly marked as examples, not an empty shell.
- **UIs are scanned.** Summary before detail. State shown in form as well as numbers (pill, chip, severity stripe). Interactive things look interactive.
- **Charts to scale,** colored from tokens, labels clear of marks, both themes legible. For anything more than a sparkline, load the `dataviz` skill if available.
## Copy
- Write from the user's side: name things by what people recognize ("Notifications", not "Webhook config").
- Buttons say exactly what happens ("Save changes", "Delete project"), and the confirmation echoes it ("Changes saved").
- Errors say what went wrong and how to fix it. No apologies, no vagueness.
- Short, direct, plain sentences. No em-dash asides, no "not X but Y", no colon-then-reveal, no scare quotes, no stock phrases ("seamless", "unlock", "elevate", "worth noting").
- Sentence case for headings and buttons.
- Page `<title>`: a real name for the page, 2 to 4 words, no "– explainer" tail.
## Accessibility and build hygiene (non-negotiable)
- Semantic HTML first: `button` for actions, `a` for navigation, real `label`s, landmarks (`header`, `nav`, `main`), one `h1`.
- Text contrast at least 4.5:1 (3:1 for large text and UI boundaries) in **both** themes.
- Visible `:focus-visible` ring (`--ring` token) on everything focusable. Never `outline: none` without a replacement.
- Touch targets at least 40px tall on touch layouts.
- `prefers-reduced-motion` respected. No information conveyed by color alone.
- `body` always has an explicit background from a token.
- No horizontal page scroll at 360px. Wide tables, code and diagrams scroll inside their own `overflow-x: auto` container. Flex/grid children holding text or tables get `min-width: 0`.
- Images get `max-width: 100%`, width/height or `aspect-ratio` to avoid layout shift, and real `alt`.
## Pre-ship checklist
- [ ] Every color, size, radius and shadow comes from a token; no stray hex or px literals in components.
- [ ] Light, dark, and explicit `data-theme` toggling all look right; no text is unreadable in either theme.
- [ ] Works at 360px, 768px and 1280px+ with no horizontal scroll.
- [ ] One display face used with restraint, a body face, a mono/data face if needed, all with fallbacks.
- [ ] Nothing from the "Avoid" list crept in by default.
- [ ] Focus states visible, keyboard path works, reduced motion respected.
- [ ] Copy follows the rules above; no placeholder text.
- [ ] Repeated elements share edges, padding and baselines.
- [ ] Empty, loading and error states exist for anything that fetches data.

View file

@ -0,0 +1,210 @@
/* =====================================================================
web-frontend design tokens
Copy into the project (e.g. src/styles/tokens.css) and tune.
Minimum per project: --hue, --chroma, the three font tokens, and the
layout-concept comment below. Components use ONLY these tokens.
Change --hue/--chroma/--tint on :root itself. Derived tokens are computed
where they are declared, so setting --hue on a nested element does NOT
re-tint it; for a differently colored section, redeclare the tokens it uses.
Layout: <one line describing this project's layout concept>
===================================================================== */
:root {
/* ---- Identity knobs ------------------------------------------------ */
--hue: 250; /* accent hue, 0-360. Pick from the subject's world. */
--chroma: 0.15; /* accent saturation. 0.08 muted ... 0.2 vivid. */
--tint: 0.012; /* how much the neutrals lean toward --hue. */
/* ---- Neutrals (light) ---------------------------------------------- */
--bg: oklch(0.985 var(--tint) var(--hue));
--surface: oklch(1 0 0);
--surface-2: oklch(0.965 var(--tint) var(--hue)); /* wells, table headers, code */
--border: oklch(0.90 calc(var(--tint) * 1.5) var(--hue));
--border-strong: oklch(0.80 calc(var(--tint) * 2) var(--hue));
--fg: oklch(0.22 calc(var(--tint) * 2) var(--hue));
--fg-muted: oklch(0.45 calc(var(--tint) * 2) var(--hue));
--fg-subtle: oklch(0.60 calc(var(--tint) * 1.5) var(--hue));
/* ---- Accent ---------------------------------------------------------- */
--accent: oklch(0.52 var(--chroma) var(--hue));
--accent-hover:oklch(0.46 var(--chroma) var(--hue));
--accent-fg: oklch(0.99 0.01 var(--hue)); /* text on --accent */
--accent-soft: oklch(0.95 calc(var(--chroma) * 0.3) var(--hue)); /* selected rows, chips */
--accent-text: oklch(0.45 var(--chroma) var(--hue)); /* links, accent text on --bg */
--ring: oklch(0.60 var(--chroma) var(--hue) / 0.55);
/* ---- Semantic (independent of the accent) ---------------------------- */
--ok: oklch(0.55 0.13 150); --ok-soft: oklch(0.95 0.04 150);
--warn: oklch(0.68 0.15 75); --warn-soft: oklch(0.96 0.05 85);
--danger: oklch(0.55 0.19 25); --danger-soft: oklch(0.95 0.04 25);
--info: oklch(0.55 0.12 230); --info-soft: oklch(0.95 0.03 230);
/* ---- Type ------------------------------------------------------------ */
--font-display: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--font-body: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
/* Scale: ratio 1.2 (UI). For editorial pages raise the top steps (see comment). */
--text-xs: 0.75rem; /* 12 captions, table meta */
--text-sm: 0.875rem; /* 14 secondary text, dense UI */
--text-base: 1rem; /* 16 body */
--text-lg: 1.125rem; /* 18 lead paragraph, card titles */
--text-xl: 1.375rem; /* 22 section headings (h3) */
--text-2xl: 1.75rem; /* 28 page sections (h2) */
--text-3xl: 2.25rem; /* 36 page title (h1) in apps */
--text-4xl: clamp(2.5rem, 1.6rem + 3.6vw, 4.5rem); /* editorial hero only */
--leading-tight: 1.15; /* display, h1-h2 */
--leading-snug: 1.3; /* h3-h4, UI labels */
--leading-body: 1.6; /* paragraphs */
--tracking-tight: -0.02em; /* large display */
--tracking-label: 0.06em; /* UPPERCASE labels */
--measure: 65ch;
--weight-regular: 400;
--weight-medium: 500;
--weight-semibold: 600;
--weight-bold: 700;
/* ---- Space (4px base) ---------------------------------------------- */
--space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
--space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
--space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
--space-16: 4rem; --space-24: 6rem;
--gutter: max(16px, 4vw); /* page side padding, capped by layout */
--content-max: 72rem; /* app/site content width */
--prose-max: var(--measure);
/* ---- Shape & elevation -------------------------------------------- */
--radius-sm: 4px; /* inputs, chips, small buttons */
--radius-md: 8px; /* cards, popovers, buttons */
--radius-lg: 14px; /* modals, large media */
--radius-full: 999px; /* pills, avatars, toggles */
--shadow-raised: 0 1px 2px oklch(0.2 0.02 var(--hue) / 0.06), 0 1px 1px oklch(0.2 0.02 var(--hue) / 0.04);
--shadow-popover: 0 4px 12px oklch(0.2 0.02 var(--hue) / 0.10), 0 1px 3px oklch(0.2 0.02 var(--hue) / 0.08);
--shadow-modal: 0 24px 48px oklch(0.2 0.02 var(--hue) / 0.18), 0 4px 12px oklch(0.2 0.02 var(--hue) / 0.10);
/* ---- Motion ---------------------------------------------------------- */
--ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
--ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
--dur-fast: 120ms; /* hover, press */
--dur-base: 180ms; /* menus, toggles */
--dur-slow: 320ms; /* modals, page moments */
/* ---- Layers -------------------------------------------------------- */
--z-sticky: 10; --z-dropdown: 20; --z-modal: 40; --z-toast: 50;
color-scheme: light;
}
/* ---- Dark: same tokens, redesigned values. Two blocks so an explicit
data-theme toggle wins over the OS setting in both directions. ---- */
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: oklch(0.17 calc(var(--tint) * 1.5) var(--hue));
--surface: oklch(0.21 calc(var(--tint) * 1.5) var(--hue));
--surface-2: oklch(0.245 calc(var(--tint) * 1.5) var(--hue));
--border: oklch(0.30 calc(var(--tint) * 2) var(--hue));
--border-strong: oklch(0.40 calc(var(--tint) * 2) var(--hue));
--fg: oklch(0.95 calc(var(--tint) * 1) var(--hue));
--fg-muted: oklch(0.74 calc(var(--tint) * 1.5) var(--hue));
--fg-subtle: oklch(0.60 calc(var(--tint) * 1.5) var(--hue));
--accent: oklch(0.70 calc(var(--chroma) * 0.85) var(--hue));
--accent-hover:oklch(0.76 calc(var(--chroma) * 0.85) var(--hue));
--accent-fg: oklch(0.18 0.02 var(--hue));
--accent-soft: oklch(0.30 calc(var(--chroma) * 0.4) var(--hue));
--accent-text: oklch(0.78 calc(var(--chroma) * 0.8) var(--hue));
--ring: oklch(0.72 var(--chroma) var(--hue) / 0.6);
--ok: oklch(0.72 0.14 150); --ok-soft: oklch(0.30 0.05 150);
--warn: oklch(0.80 0.14 80); --warn-soft: oklch(0.32 0.05 80);
--danger: oklch(0.70 0.17 25); --danger-soft: oklch(0.30 0.06 25);
--info: oklch(0.72 0.11 230); --info-soft: oklch(0.30 0.05 230);
--shadow-raised: 0 1px 2px oklch(0 0 0 / 0.4);
--shadow-popover: 0 6px 16px oklch(0 0 0 / 0.45), 0 0 0 1px var(--border);
--shadow-modal: 0 24px 56px oklch(0 0 0 / 0.55), 0 0 0 1px var(--border);
color-scheme: dark;
}
}
:root[data-theme="dark"] {
--bg: oklch(0.17 calc(var(--tint) * 1.5) var(--hue));
--surface: oklch(0.21 calc(var(--tint) * 1.5) var(--hue));
--surface-2: oklch(0.245 calc(var(--tint) * 1.5) var(--hue));
--border: oklch(0.30 calc(var(--tint) * 2) var(--hue));
--border-strong: oklch(0.40 calc(var(--tint) * 2) var(--hue));
--fg: oklch(0.95 calc(var(--tint) * 1) var(--hue));
--fg-muted: oklch(0.74 calc(var(--tint) * 1.5) var(--hue));
--fg-subtle: oklch(0.60 calc(var(--tint) * 1.5) var(--hue));
--accent: oklch(0.70 calc(var(--chroma) * 0.85) var(--hue));
--accent-hover:oklch(0.76 calc(var(--chroma) * 0.85) var(--hue));
--accent-fg: oklch(0.18 0.02 var(--hue));
--accent-soft: oklch(0.30 calc(var(--chroma) * 0.4) var(--hue));
--accent-text: oklch(0.78 calc(var(--chroma) * 0.8) var(--hue));
--ring: oklch(0.72 var(--chroma) var(--hue) / 0.6);
--ok: oklch(0.72 0.14 150); --ok-soft: oklch(0.30 0.05 150);
--warn: oklch(0.80 0.14 80); --warn-soft: oklch(0.32 0.05 80);
--danger: oklch(0.70 0.17 25); --danger-soft: oklch(0.30 0.06 25);
--info: oklch(0.72 0.11 230); --info-soft: oklch(0.30 0.05 230);
--shadow-raised: 0 1px 2px oklch(0 0 0 / 0.4);
--shadow-popover: 0 6px 16px oklch(0 0 0 / 0.45), 0 0 0 1px var(--border);
--shadow-modal: 0 24px 56px oklch(0 0 0 / 0.55), 0 0 0 1px var(--border);
color-scheme: dark;
}
/* =====================================================================
Base layer — sensible defaults built on the tokens.
===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
margin: 0;
background: var(--bg);
color: var(--fg);
font-family: var(--font-body);
font-size: var(--text-base);
line-height: var(--leading-body);
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
font-family: var(--font-display);
line-height: var(--leading-tight);
font-weight: var(--weight-semibold);
text-wrap: balance;
margin: 0;
}
h1 { font-size: var(--text-3xl); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-xl); line-height: var(--leading-snug); }
h4 { font-size: var(--text-lg); line-height: var(--leading-snug); }
p { margin: 0; text-wrap: pretty; max-width: var(--prose-max); }
small, .text-muted { color: var(--fg-muted); }
code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
a { color: var(--accent-text); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
input, button, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--fg); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); }
.label { /* uppercase eyebrow / column label */
font-size: var(--text-xs); font-weight: var(--weight-semibold);
letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--fg-muted);
}
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}
}
/* Editorial pages: widen the top of the scale.
:root {
--text-xl: 1.5rem; --text-2xl: 2.25rem; --text-3xl: 3rem;
--text-4xl: clamp(3rem, 1.5rem + 6vw, 6.5rem);
}
*/

View file

@ -0,0 +1,113 @@
# Components
Recipes in plain CSS on the tokens. Port them to CSS Modules, Tailwind (`tailwind.md`) or a component library's styling API as the project requires. Every interactive element has hover, active, `:focus-visible` and disabled states.
## Buttons
Three variants and two sizes cover almost everything. One primary button per view.
```css
.btn {
display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
height: 2.5rem; padding-inline: var(--space-4);
font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1;
border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer;
transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn-danger { background: var(--danger); color: var(--accent-fg); }
.btn-sm { height: 2rem; padding-inline: var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
```
Icon-only buttons are square (`width` = `height`) and need `aria-label`.
## Inputs
```css
.field { display: grid; gap: var(--space-2); }
.field > label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field > .hint { font-size: var(--text-xs); color: var(--fg-muted); }
.field > .error { font-size: var(--text-xs); color: var(--danger); display: flex; gap: var(--space-1); }
.input {
height: 2.5rem; padding-inline: var(--space-3); width: 100%;
background: var(--surface); color: var(--fg);
border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder { color: var(--fg-subtle); }
.input:hover { border-color: var(--fg-subtle); }
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { height: auto; min-height: 6rem; padding-block: var(--space-2); resize: vertical; }
```
Placeholders show an example value, never the label.
## Cards and surfaces
Use a card only when the thing is a separate object (an item in a collection, a self-contained panel). A section of a page is not a card.
```css
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-5); }
.card-interactive { transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.card-interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-raised); }
.well { background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-4); }
```
In a row of cards: same padding, title in the same place, actions pinned to the same edge (`display: flex; flex-direction: column` with `margin-top: auto` on the footer).
## Badges, pills, status
```css
.badge { display: inline-flex; align-items: center; gap: var(--space-1); height: 1.375rem; padding-inline: var(--space-2);
font-size: var(--text-xs); font-weight: var(--weight-medium); border-radius: var(--radius-full);
background: var(--surface-2); color: var(--fg-muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: oklch(from var(--warn) calc(l - 0.15) c h); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
```
Status always pairs color with a word or icon.
## Tables
```css
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: var(--weight-medium);
color: var(--fg-muted); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
```
No zebra stripes and borders together; pick one. Truncate long cells with a tooltip rather than letting a row explode.
## Navigation
- Top nav: logo/name left, 3 to 6 links, one action right. Active link marked by weight or color plus `aria-current="page"`, not just an underline that is hard to see.
- Side nav: items 2.25rem tall, icon + label, active item `background: var(--accent-soft); color: var(--accent-text)`. Group headings use `.label`.
- Tabs: underline style (2px `--accent` bar under the active tab) for page sections; segmented control (pill group on `--surface-2`) for view switches.
## Overlays
- Popovers/menus: `--surface`, `--shadow-popover`, `--radius-md`, 4px inner padding, items 2rem tall. Animate opacity + 4px translate in `--dur-base`.
- Modals: max-width 32rem (forms) or 48rem (content), `--shadow-modal`, `--radius-lg`, backdrop `oklch(0 0 0 / 0.4)`. Focus trapped, Escape closes, title in an `h2`. Use the native `<dialog>` or Radix Dialog.
- Toasts: bottom-right on desktop, bottom-center on phones; short past-tense message ("Invoice sent"); an Undo action for destructive operations instead of a confirm dialog where possible.
## States
- **Loading:** skeletons shaped like the real content (`--surface-2` blocks with a subtle shimmer that stops under reduced motion) for page loads; inline spinners only inside buttons.
- **Empty:** say what will appear here and how to add the first one, with the primary action. A small icon at most, no large illustration unless the product has an illustration style.
- **Error:** what failed, why if known, and a retry. Keep the rest of the page usable.
## Data display details
- Numbers: `tabular-nums`, right-aligned in columns, units in `--fg-muted`, thousands separators via `Intl.NumberFormat`.
- Dates: relative for recent ("3 min ago") with the absolute date in a `title`/tooltip; absolute in tables.
- Code and IDs: `--font-mono`, `--surface-2` background, copy button on hover.

View file

@ -0,0 +1,85 @@
# Layout
Rules first, then patterns to copy. All values come from `assets/tokens.css`.
## Rules
- Spacing between siblings comes from `gap` on a flex/grid parent. Margins only for one-off offsets.
- One side gutter, set once on the outer wrapper: `padding-inline: var(--gutter)`. Use `padding-block` for vertical padding so the sides never get zeroed by a shorthand.
- Design at ~400px and ~1280px, then check 768px. Rows wrap or stack to one column on phones.
- Flex/grid children that hold text, code or tables get `min-width: 0`.
- Only tables, code blocks and diagrams may be wider than the screen, each inside an `overflow-x: auto` wrapper.
- Size heroes to their content, never `100vh`. For full-screen apps, use `height: 100dvh` on the shell (or `100%` from `html`/`body`), not `100vh`.
- Let content set heights. Don't stretch cards over empty space. Choose column counts the items fill.
- Left-align by default. Center only short, self-contained things (an empty state, a one-line hero on a launch page).
- Vertical rhythm: inside a component `--space-2` to `--space-4`; between components `--space-6` to `--space-8`; between page sections `--space-12` to `--space-24`.
## Page container
```css
.page { padding-inline: var(--gutter); padding-block: var(--space-8) var(--space-16); }
.container { max-width: var(--content-max); margin-inline: auto; }
.prose { max-width: var(--prose-max); }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-3)); }
```
## Auto-fitting grid (cards, galleries)
```css
.grid-auto {
display: grid; gap: var(--space-6);
grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
}
```
## Sidebar + content (docs, settings)
```css
.with-sidebar { display: grid; gap: var(--space-8); grid-template-columns: 1fr; }
@media (min-width: 900px) { .with-sidebar { grid-template-columns: 15rem minmax(0, 1fr); } }
.with-sidebar > aside { position: sticky; top: var(--space-6); align-self: start; }
```
## App shell (tools, dashboards)
```css
.app { display: grid; height: 100dvh; grid-template-rows: auto 1fr; grid-template-columns: 1fr; }
@media (min-width: 900px) {
.app { grid-template-columns: 15rem minmax(0, 1fr); grid-template-areas: "nav top" "nav main"; }
.app > nav { grid-area: nav; border-right: 1px solid var(--border); }
.app > header { grid-area: top; }
.app > main { grid-area: main; }
}
.app > header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--gutter);
border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: var(--z-sticky); }
.app > main { overflow: auto; padding: var(--space-6) var(--gutter); }
```
On phones the nav becomes a top bar with a menu button or a bottom tab bar (max 5 items).
## Dashboard
- Order: page title and time range → the 3 to 5 numbers that matter → the main chart → supporting tables.
- KPI row: `grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr))`. Each tile shows label, value (`tabular-nums`), change vs. previous period with a semantic color, and optionally a sparkline.
- Status shown in form: a colored dot or pill plus a word, never color alone.
- Tables: sticky header, right-aligned numbers, muted secondary columns, row hover in `--surface-2`.
## Editorial / landing page
- The hero states the thesis: the subject's most characteristic thing (a headline set big, a live demo, a striking image), sized to content.
- Break the grid on purpose once: an oversized type moment, a full-bleed band, an asymmetric 7/5 split. Keep the rest on a calm 12-column grid:
```css
.grid-12 { display: grid; gap: var(--space-6); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; }
@media (max-width: 800px) { .grid-12 > * { grid-column: 1 / -1; } }
```
- Full-bleed bands keep the gutter on their inner wrapper, not the band itself.
- Section headings are left-aligned with a short lead paragraph. No eyebrow on every section; use one only when it encodes something (a category, a step).
- End with one clear call to action, not three.
## Forms
- One column. Labels above inputs. Group related fields with a heading, not a box around each.
- Inputs width by expected content (a ZIP code field is short), max ~32rem for text fields.
- Primary action at the end, left-aligned with the fields; secondary actions as quieter buttons next to it.
- Validate on blur and on submit; inline errors under the field in `--danger` with an icon and text.

View file

@ -0,0 +1,44 @@
# Libraries
Reach for few dependencies, each doing real work. If the project already has a choice for a role, keep it. Install current stable versions (`npm view <pkg> version`). Don't add a library for something CSS or the platform already does well.
## Pick a base by project type
| Project | Stack |
|---|---|
| Static page, single landing page, prototype | Plain HTML + `tokens.css` + a little vanilla JS. No framework. |
| Content site, blog, docs, marketing site | **Astro** (static by default, islands where needed). MDX for content. |
| Interactive SPA, internal tool, dashboard (no SEO needs) | **Vite + React + TypeScript**. |
| Product with SEO, auth, server data, many routes | **Next.js (App Router) + TypeScript**. |
| Team already on Vue / Svelte | **Nuxt** or **SvelteKit**; map the roles below to their equivalents. |
## Roles (React defaults)
| Role | Default | Notes |
|---|---|---|
| Styling | `tokens.css` + **CSS Modules** or **Tailwind v4** | Tailwind only with tokens mapped into `@theme` (`tailwind.md`). Never a second color system alongside the tokens. |
| Accessible primitives | **Radix UI** primitives (or **shadcn/ui** for copy-in components) | shadcn's stock look is a known AI tell: always restyle it to the tokens (radius, colors, fonts, shadows). |
| Icons | **Lucide** (`lucide-react`) | One icon set per project. 16px in dense UI, 20px default, `stroke-width` 1.75. Never emoji as icons. |
| Fonts | `@fontsource/<family>` or `next/font/google` | Self-host to avoid layout shift; set `font-display: swap`. |
| Routing | Framework router; **TanStack Router** or **React Router** for Vite SPAs | Type-safe routes when available. |
| Server state | **TanStack Query** | Caching, retries, loading/error states. Don't hand-roll fetch-in-`useEffect`. |
| Client state | React state/context first; **Zustand** when shared state grows | No Redux unless the project has it. |
| Forms + validation | **React Hook Form** + **Zod** | Zod schemas double as API types. |
| Tables | **TanStack Table** | Headless; style with tokens. |
| Charts | **Recharts** for standard charts; **visx** or **D3** for custom | Color from tokens; load the `dataviz` skill if present. |
| Motion | CSS transitions first; **Motion** (`motion/react`) for orchestrated sequences, layout and gestures | Always honor reduced motion. |
| Toasts | **Sonner** | Restyle to tokens. |
| Command palette | **cmdk** | |
| Dates | **date-fns** (or `Intl` alone for formatting) | Format with `Intl.DateTimeFormat`/`NumberFormat` for locale-aware output. |
| Markdown | **react-markdown** + **remark-gfm** | |
| Syntax highlighting | **Shiki** | Pick a theme pair that matches both color themes. |
| Testing | **Vitest** + **Testing Library**; **Playwright** for e2e and screenshots | Playwright also gives the one rendered check before shipping. |
| Lint/format | ESLint (flat config) + Prettier, or **Biome** | Match the project. |
## Don't reach for
- Full UI kits with a strong look of their own (Material UI, Ant Design, Chakra default theme, Bootstrap) unless the project already uses one. They fight the tokens.
- Animation libraries for hover states.
- jQuery, Moment.js, Lodash as a whole (import single functions or use the platform).
- CSS-in-JS runtimes (styled-components, Emotion) in new projects. They cost runtime and clash with server components.
- Icon fonts.

View file

@ -0,0 +1,68 @@
# Tailwind with the tokens
Tailwind is fine as long as the tokens stay the single source of truth. Never use Tailwind's stock palette (`bg-blue-600`, `text-gray-500`) in components. Map the tokens into the theme and use only those names.
## Tailwind v4 (CSS-first config)
```css
/* src/styles/app.css */
@import "tailwindcss";
@import "./tokens.css"; /* the file from assets/tokens.css */
/* Explicit toggle. System dark mode needs no variant: the tokens already switch. */
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
@theme inline {
--color-*: initial; /* drop the stock palette */
--color-bg: var(--bg);
--color-surface: var(--surface);
--color-surface-2: var(--surface-2);
--color-border: var(--border);
--color-border-strong: var(--border-strong);
--color-fg: var(--fg);
--color-fg-muted: var(--fg-muted);
--color-fg-subtle: var(--fg-subtle);
--color-accent: var(--accent);
--color-accent-hover: var(--accent-hover);
--color-accent-fg: var(--accent-fg);
--color-accent-soft: var(--accent-soft);
--color-accent-text: var(--accent-text);
--color-ring: var(--ring);
--color-ok: var(--ok); --color-ok-soft: var(--ok-soft);
--color-warn: var(--warn); --color-warn-soft: var(--warn-soft);
--color-danger: var(--danger); --color-danger-soft: var(--danger-soft);
--color-info: var(--info); --color-info-soft: var(--info-soft);
--color-transparent: transparent;
--color-current: currentColor;
/* Names must differ from the token they read, or the variable refers to itself and becomes invalid. */
--font-heading: var(--font-display); /* class: font-heading */
--font-sans: var(--font-body);
--shadow-card: var(--shadow-raised); /* class: shadow-card */
--shadow-menu: var(--shadow-popover);
--shadow-dialog: var(--shadow-modal);
/* --radius-sm/md/lg, --font-mono and --ease-out need no mapping: tokens.css declares them
with Tailwind's own names, unlayered, so they override Tailwind's defaults. */
}
```
Because the colors resolve through CSS variables that already switch with the theme, components rarely need `dark:` variants at all: `bg-surface text-fg border-border` is correct in both themes.
Usage examples:
```html
<button class="inline-flex h-10 items-center gap-2 rounded-md bg-accent px-4 text-sm font-medium text-accent-fg hover:bg-accent-hover focus-visible:outline-2 focus-visible:outline-ring">Save changes</button>
<div class="rounded-md border border-border bg-surface p-5">…</div>
<span class="text-xs font-semibold uppercase tracking-[0.06em] text-fg-muted">Revenue</span>
```
## Tailwind v3 projects
Put the same mapping in `tailwind.config` under `theme.extend.colors` (`bg: 'var(--bg)'`, `fg: 'var(--fg)'`, …), plus `fontFamily`, `borderRadius` and `boxShadow`. Set `darkMode: ['selector', '[data-theme="dark"]']` for the toggle. As in v4, the variables already follow the system theme, so `dark:` classes are rarely needed.
## Habits to avoid in Tailwind output
- `rounded-xl shadow-lg` as the default on every container.
- `bg-gradient-to-r from-purple-500 to-blue-500` anywhere.
- `text-center` on whole sections.
- Arbitrary values (`p-[13px]`, `text-[#333]`) instead of tokens.
- Very long class strings repeated across files: extract a component instead.