@cssints/fluid

Fluid lengths for cssints: fluid(min, max) is a length that is min on a narrow viewport, max on a wide one, and grows linearly between. The clamp() is computed at build time, and a range that breaks text resizing (WCAG 1.4.4) fails the build. Two value members of cssints/plugin scope() (fn({ args, value }), positional arguments and an options object). No runtime.

import { fontSize, padding } from "cssints" with { type: "cssints" };
import { fluid } from "@cssints/fluid" with { type: "cssints" };

// fluid(min, max, { from?, to?, zoom? }): from and to are the widths, 20rem and 80rem when left out
export const title = fontSize(fluid("1rem", "1.5rem"));
export const lead = fontSize(fluid("16px", "24px", { from: "40rem", to: "90rem" }));
// against the inline size of the nearest container instead of the viewport
export const card = padding(fluid.container("1rem", "2rem", { to: "60rem" }));

export const hero = fontSize(fluid("1rem", "4rem")); // build error: fails WCAG 1.4.4
._bkcdcr {
  font-size: clamp(1rem, 0.8333vw + 0.8333rem, 1.5rem);
}
._1wkr2lu {
  font-size: clamp(16px, 1vw + 0.6rem, 24px);
}
._ekb8uj {
  padding: clamp(1rem, 2.5cqi + 0.5rem, 2rem);
}

Rules

`).

Limits

cd packages/fluid && bun run test   # fixtures through the engine (output, errors), and the type test via bun run typecheck

Credits

The WCAG 1.4.4 check follows fluid-tailwind (MIT, Maxwell Barvian). The check is written here; no code is copied.