css-clamplisted
Install: claude install-skill Willem-Jaap/cssclamp
# CSS clamp()
A fluid value is a straight line between two points: a minimum size at a minimum
viewport width and a maximum size at a maximum viewport width, capped at both ends.
```css
font-size: clamp(MIN, INTERCEPT + SLOPEvw, MAX);
```
## Always calculate with the script
Do not work the numbers out by hand. Run the bundled script, which does the
maths and rounds to three decimals:
```bash
node scripts/clamp.mjs <minSize> <maxSize> [minViewport] [maxViewport] [--unit vw|cqi] [--root 16]
```
- Sizes and viewports accept `px` or `rem` (`16`, `16px`, `1rem`). Bare numbers are px.
- Viewports default to `360px` and `1440px`.
- `--unit cqi` scales with the nearest container instead of the viewport.
- `--root` is the root font size in px, default `16`.
```bash
node scripts/clamp.mjs 16px 64px 320px 1440px
# clamp(1rem, 0.143rem + 4.286vw, 4rem)
```
The script lives next to this file. Resolve the path relative to the skill
directory. If Node is not available, use the formula below.
## Formula
All values in px, converted to rem by dividing by the root font size (16):
```
slope = (maxSize - minSize) / (maxViewport - minViewport)
intercept = minSize - slope × minViewport
preferred = intercept(rem) + (slope × 100)vw
result = clamp(minSize(rem), preferred, maxSize(rem))
```
Check the result: at `minViewport` the preferred value must equal `minSize`, and at
`maxViewport` it must equal `maxSize`.
## Rules
1. **Use rem for the bounds and the intercept, never px.** rem