CSS box-shadow and clamp()
Build a layered box-shadow with a live preview, or work out a clamp() value for a font size that grows with the screen.
Shadow
Preview and CSS
What it does
This tool has two parts. The box-shadow generator builds up to four stacked shadow layers with horizontal and vertical offset, blur, spread, colour, opacity and an inset switch, and shows them on a card as you move the sliders. The clamp() calculator makes fluid typography: enter the smallest and largest font size and the screen widths where each should apply, in pixels or rem, and get a clamp() value that grows smoothly between them, with a table of the computed size at common widths. Copy the CSS with one click. It all runs in your browser.
How to use it
- 1Box shadow: set the sliders for each layer and check the preview.
- 2Clamp: enter the smallest and largest size and the two screen widths.
- 3Copy the CSS into your stylesheet.
Common uses
- Make a soft, layered card shadow like the ones in modern design systems.
- Add an inner shadow (inset) to an input or a pressed button.
- Set a heading that is 24 px on phones and 48 px on desktops, with no media query.
- Convert a design spec in pixels into a rem-based clamp() value.
- Check what size your fluid text has at 768 px or 1440 px.
Questions
Why use several shadow layers?
Real shadows are soft and have a sharp part close to the object and a wide, faint part far away. Two or three layers look much more natural than one.
What does inset do?
It draws the shadow inside the box instead of outside, which is how pressed or sunken elements are made.
What does clamp() do?
clamp(min, preferred, max) picks the preferred value but never goes below min or above max. With a vw unit in the preferred value the size follows the screen width.
How is the middle value calculated?
A straight line is drawn through your two points (smallest size at the smallest width, largest size at the largest width). Its slope becomes the vw part and its offset the fixed part.
Should I use px or rem for font sizes?
rem respects the font size a person sets in their browser, so it is better for accessibility. The tool converts between the two with the pixels per rem you give (16 by default).
Why does the size stop growing?
Below the smallest width the size stays at the minimum, above the largest width it stays at the maximum. That is the point of clamp().
Is anything uploaded?
No. The CSS is made in your browser.