Trousers
Build-time CSS-in-JS

Static CSS. A better fit.

Trousers turns typed style objects into CSS at build time. Write styles beside your components, switch variants with props, and ship a stylesheet the browser already understands.

The smiling Trousers mascot

One style.
Three fits.

Define spacing once, then let a prop choose the fit. Each option becomes a CSS rule at build time.

Named variants
tsx
const box = css({ minHeight: 20 })
    .variant('inset', {
        s: { padding: 4 },
        m: { padding: 8 },
        l: { padding: 16 },
    });

const Box = styled.div(box);

<Box $inset="m">Room to breathe.</Box>