By Debmedia Technologies LLP · Kolkata, India · Updated
What Is It and When Do You Need It?
Fluid type changes smoothly with the screen instead of jumping at breakpoints. The CSS clamp() function does this in one line, but the numbers need a little maths. This tool does the maths and writes the line.
Enter your smallest and largest sizes and the screen widths where they apply.
How to Use This Tool
- Enter the minimum and maximum size in pixels.
- Enter the minimum and maximum screen width.
- Press Generate.
- Copy the clamp() value.
How the Calculation Works
The slope is the size change divided by the width change. The intercept makes the line pass through the minimum point. Both are converted to rem by dividing by the root font size, and the slope is multiplied by 100 for vw. The result is clamp(min rem, intercept rem + slope vw, max rem).
Worked Example
A size growing from 16 px at 360 px to 24 px at 1200 px gives clamp(1rem, 0.7857rem + 0.9524vw, 1.5rem).
Common Uses
- Responsive headings and body text.
- Fluid spacing and padding.
- Fewer media queries.
- Design system tokens.
Tips and Common Mistakes
- Keep the maximum below about 2.5 times the minimum for good zoom behaviour.
- Test with browser zoom.
- Use the same viewport range across a site.
Related Tools
Next, you may need the px to rem converter, aspect ratio calculator, box shadow generator, border radius generator.
Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.
Frequently Asked Questions
Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.