About this tool
Set a minimum and maximum value and the viewport widths where each should apply, and get a clamp() that grows linearly in between. It works for any property, including padding, gaps and font sizes. Test the result at any screen width with the slider.
How to use CSS clamp() Generator
- Enter the CSS property and the min and max values.
- Set the min and max viewport widths.
- Choose rem or px output.
- Copy the declaration.
Frequently asked questions
How does the clamp() formula work?
The middle value is a straight line through your two points: a fixed part plus a vw part. clamp() keeps the result between your minimum and maximum.
Can the value shrink as the screen gets wider?
Yes. Make the minimum-width value larger than the maximum-width one and the generated vw term becomes negative.