algorithmic-color-pale…
Derive a full UI colour palette algorithmically from one or two brand colours. Darker and lighter variants for interactive states, desaturated greys from the…
Which CSS unit a value should be written in. rem for anything a text-size preference must move — type, control heights, padding around text. px only for what must not move — hairlines, borders, shadow offsets. Relative units for layout widths. Use when defining spacing and
$ npx -y skills add dembrandt/dembrandt-skills --skill sizing-units --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/sizing-unitsContext preview
The summary Claude sees to decide when to auto-load this skill.
Which CSS unit a value should be written in. rem for anything a text-size preference must move — type, control heights, padding around text. px only for what must not move — hairlines, borders, shadow offsets. Relative units for layout widths. Use when defining spacing and
name: sizing-units
description: Which CSS unit a value should be written in. rem for anything a text-size preference must move — type, control heights, padding around text. px only for what must not move — hairlines, borders, shadow offsets. Relative units for layout widths. Use when defining spacing and sizing tokens, choosing between px and rem, setting control heights, writing media queries, or fixing a layout that breaks when the user enlarges text.
metadata:
priority: 5
pathPatterns:
- "design-system/**"
- "ui/**"
- "**/tokens*"
- "**/*.css"
- "**/tailwind.config.*"
- "components/**"
- "src/components/**"
promptSignals:
phrases:
- "rem"
- "px"
- "em"
- "spacing scale"
- "sizing tokens"
- "root font size"
- "text zoom"
- "which unit"
retrieval:
aliases:
- px vs rem
- css units
- spacing units
- sizing tokens
- root font size
- text scaling
intents:
- decide between px and rem for spacing
- define a spacing scale
- fix a layout that breaks when text is enlarged
- choose units for media queries
- set control heights that survive text scaling
examples:
- should spacing be in rem or px
- our buttons clip when the user enlarges text
- what unit for border radius and shadows
- should media queries use px or emA unit is not a formatting preference. It is a declaration of what happens to a value when the user enlarges text.
Pick the unit by answering that question, not by picking a house style and applying it everywhere. Both absolutist positions — all-rem and all-px — produce defects, and they are different defects.
The common argument for px everywhere is that browsers already have full-page zoom, so the root font size can be ignored. They are separate controls serving separate people.
A product that hard-codes every dimension in px answers the first user and silently refuses the second. WCAG 2.2 SC 1.4.4 (Resize Text) requires text to reach 200% without loss of content or function, and SC 1.4.10 (Reflow) requires the page to survive it in a single column. See [[wcag-accessibility]].
**Typography.** Every font size and line height. See [[modular-scale-typography]].
**Padding around text.** A button's inner padding in px means large text presses against its edges. In rem the breathing room scales with the words it surrounds.
**Control heights.** A 40px control holding 24px text is broken. Write the height token in rem and it stays a control-shaped control at every text size. See [[component-family-consistency]].
**Measure.** `max-width` on a text column: `65ch` or a rem value, never px.
**Gaps between text-bearing blocks.** Stack spacing in a form or an article is part of the reading rhythm.
**Hairlines and borders.** `1px` is one device pixel by intent. In rem it becomes `1.25px` at a larger root size and renders as a blurry smear.
**Shadow offsets and blur.** Elevation is a screen-space effect. See [[elevation-and-depth]].
**Small icons inside controls** where the icon is a fixed glyph rather than text.
**Sub-pixel corrections** — the `-1px` that makes two borders overlap instead of doubling.
Layout widths and gaps. This is where the "lock it in px so it stays stable" instinct goes wrong: a px-locked container is not stable, it is brittle. The text inside it still grows, and a fixed box is exactly what makes growing text clip.
/* Brittle — the box cannot absorb anything */
.card { width: 320px; height: 180px; }
.sidebar { width: 280px; }
/* Resilient */
.card { max-width: 20rem; min-height: 11.25rem; }
.sidebar { width: clamp(16rem, 22%, 22rem); }**`min-height`, never `height`,** on anything containing text. A fixed height cannot grow; a minimum height holds the shape at rest and yields when it must.
Use `em` in media queries. Media-query `rem` and `em` both resolve against the browser's default font size, ignoring any `html { font-size }` you set — so `em` is the honest spelling, and both respect the user's preference where a px breakpoint does not. A user with a large default font size gets the layout their effective text size warrants, not the one their device width claims.
@media (min-width: 48em) { /* ~768px at default settings */ }html { font-size: 62.5%; } /* Do not do this */The 62.5% trick exists to make rem arithmetic easy — `1.6rem` for 16px. It buys you mental arithmetic and pays for it by overriding the user's stated preference by default. Keep the root at the browser default and let the tooling do the division.
UX and design-system skills for AI agents. Install once, and your agent knows how to design. --all installs every skill at once. They load only when a prompt needs them, so there is no runtime cost to having them all. Want to pick by hand?
Repo: dembrandt/dembrandt-skills
Derive a full UI colour palette algorithmically from one or two brand colours. Darker and lighter variants for interactive states, desaturated greys from the…
The persistent shell around an application — the top bar, the app launcher, the tenant and environment cue, and in heavy tools a status bar. In an estate of…
Product visuals — hero shots, demos, screenshots, landing-page panels — must reproduce the real product, not a stylised poster of it. Design with real content…
A brand's visual tone — playful or serious, rounded or angular — should be consistent across all UI elements. Shape language in typography, border-radius, and…
Every interactive element needs a complete set of visual states — rest, hover, active/pressed, focus, disabled, and loading. States should be derived…
Rebuild an existing web page 1:1 from measurement instead of by eye — into Figma, Penpot, or code. Captures the rendered page, the raw source and the computed…