
A CSS clamp() generator builds a single clamp(minimum, preferred, maximum) declaration that scales a value smoothly between two screen widths. Instead of writing several media queries to step a heading from 24px on phones to 48px on desktops, you set a minimum size, a maximum size, and the viewport range they map to, and the generator returns one line of CSS that interpolates every size in between.
The clamp() function takes three arguments: a lower bound, a preferred value, and an upper bound. The browser uses the preferred value unless it falls below the minimum or above the maximum, in which case it locks to that bound. This generator computes the preferred value as a linear function of the viewport, combining a fixed rem term with a vw term, so the result grows in step with the window while never dropping below your minimum or exceeding your maximum. This technique is often called fluid typography, though it works equally well for margins, padding, gaps, and widths.
Everything is calculated in your browser with client-side JavaScript, so nothing you enter is uploaded and the tool works offline once loaded. You can enter sizes in pixels or rem, set a custom root font size, and read a preview table showing the computed value at common viewport widths, so you can confirm the curve behaves before pasting the clamp() into your stylesheet.
Fluid sizing has one accessibility trap worth avoiding deliberately. A clamp expression whose middle term is expressed purely in viewport units ignores the reader's font-size setting, because vw does not respond to it, and text that cannot grow fails WCAG 1.4.4. Keeping a rem component in the preferred value, which is what the generated output does, means the size still responds to browser zoom and to a larger default font. Always set both bounds: without them the value scales without limit in either direction.
Enter the size the value should hold on the smallest screens and the size it should reach on the largest, in px or rem.
Enter the minimum viewport where the small size applies and the maximum viewport where the large size applies, for example 320px to 1280px.
Check the preview table to confirm the computed value at each viewport width scales the way you expect between the two bounds.
Copy the generated clamp() declaration and paste it into any CSS property, such as font-size, margin, padding, or width.
Replace stacks of media queries with a single clamp() declaration that scales continuously across the viewport range.
Enter sizes in pixels or rem and set a custom root font size; the output rem values respect it.
See the computed px and rem value at common widths so you can verify the scaling curve before you ship it.
Use the result for font-size, line-height, margins, padding, gaps, and widths, not just typography.
Round any corner with a live preview and per-corner sliders, switch between px, %, em, and rem, and copy the shortest valid CSS border-radius.
Design layered CSS box-shadows with a live preview and sliders for offset, blur, spread, color, opacity, and inset - then copy production-ready CSS.
Convert between CSS units - px, rem, em, pt and % - with a configurable root font size, instant all-units output, and a px-to-rem reference table for responsive typography.
Create beautiful CSS gradients with live preview
0 comments
No comments yet. Be the first to share your thoughts!