Every interface has a moment where a button needs to say: you pushed me, and it worked. Flat buttons that never change leave users guessing. The classic answer is the pressed effect: while the button is down, its surface appears to sink into the page, with the top inner edge shaded as if the material caved in under a fingertip.

That effect is not a separate property or a trick image. It is the ordinary box-shadow with one toggle flipped: inset. This guide shows how to build a pressed-button shadow with the free Box Shadow Generator on Ovatly, and how to wire the result into your CSS.

Contents

  • Quick answer
  • Why inset reads as pressed
  • The settings that make the effect
  • How to build a pressed shadow, step by step
  • Worked example: from raised button to pressed button
  • Wiring it to the active state
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

To make a button look pressed: open the Box Shadow Generator, turn the inset toggle on, keep the horizontal offset at 0px, set a small positive vertical offset of a few pixels, a modest blur, 0px spread, and black at a restrained opacity. The shadow now falls inside the border, darkening the top inner edge, which is the whole effect. Copy the declaration and apply it to the button's :active state in your own stylesheet, because the generator emits the box-shadow value only.

Why inset reads as pressed

A normal shadow falls outside the element, onto the page, and tells the eye the element floats above the surface. An inset shadow reverses the geometry: the shading appears inside the border, and the eye reads that as the surface bending inward, the top edge shaded because the material below it has dipped away from the light.

Direction matters as much as placement. With the inset toggle on, a positive vertical offset shades the top inner edge, matching a light source above the page, exactly the shading a real pressed key shows. Shade the bottom inner edge instead, with a negative offset, and the same button reads as embossed or raised. The toggle decides inside versus outside; the offsets decide which inner edge takes the shade.

The settings that make the effect

Pressed is a small effect, and the settings should stay small: the shadow is trapped inside a button that may only be forty pixels tall.

  • Inset toggle on. This is the effect. Without it you are building a drop shadow, however good.
  • Horizontal offset at or near 0px. Centered shading looks like depth. A sideways inset shadow looks like a printing error.
  • Vertical offset small and positive. A few pixels is enough to darken the top inner edge. The exact number is your call, depending on the button's height and how deep the press should feel.
  • Blur modest. A soft edge sells the illusion of yielding material. Zero blur gives a hard inner line that reads as a border, not a dent.
  • Spread at 0px. Positive spread inside a small element quickly floods it. Negative spread can tighten the shading to the edge.
  • Opacity restrained. A pressed shade usually wants black well under half opacity, tuned against the button's background color.

How to build a pressed shadow, step by step

  1. Open the Box Shadow Generator and add a layer.
  2. Turn the layer's inset toggle on. The preview shadow moves inside the box.
  3. Set the horizontal offset to 0px and the vertical offset to a small positive value, a few pixels.
  4. Set a modest blur radius, leave spread at 0px, and choose black with a restrained opacity.
  5. Check the preview: top inner edge shaded, the rest of the surface clean. If it looks like a hole, reduce the offset and opacity first.
  6. Copy the declaration. It will include the inset keyword.

Worked example: from raised button to pressed button

Start with a resting button using the generator's baseline raised shadow: 0px horizontal offset, 8px vertical offset, 24px blur, 0px spread, black at 20 percent opacity:

box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.2);

Now build the pressed version as its own layer with the inset toggle on. Small values throughout: 0px horizontal offset, 3px vertical offset, 6px blur, 0px spread, black at 25 percent opacity:

box-shadow: inset 0px 3px 6px 0px rgba(0, 0, 0, 0.25);

Read the two declarations side by side and the technique is visible. The raised version throws a wide, soft shadow 8px below the button. The pressed version puts a narrow band of shade 3px inside the top edge and nothing outside at all. Those numbers are a starting point, not a rule: a taller button can take a deeper press, and a dark button needs less opacity than a pale one. The shape of the recipe does not change: inset on, offsets small, blur modest.

Wiring it to the active state

Here is the honest boundary of the tool: the generator produces a box-shadow declaration, and nothing else. It does not style your button or know when the button is pressed. That wiring is a few lines of your own CSS:

.button {
  box-shadow: 0px 8px 24px 0px rgba(0, 0, 0, 0.2);
}

.button:active {
  box-shadow: inset 0px 3px 6px 0px rgba(0, 0, 0, 0.25);
}

At rest the button sits raised. While it is being clicked or tapped, the browser swaps in the inset shadow and the surface visibly dips. Some designs also nudge the button down by a pixel or two with a transform in the same :active rule; that is a design choice in your stylesheet, not something the shadow does. For toggle buttons and selected tabs, the same inset declaration can stay on permanently, showing a choice that is currently engaged.

Limitations and honest tradeoffs

The generator builds up to four shadow layers, each with its own inset toggle, and outputs the combined declaration. It cannot preview your actual button: your background color, border radius and label all change how the shading reads, so final judgment has to happen in your own page. A pressed shadow that looks right on a light grey button can vanish on a dark one.

There is also a usability tradeoff. The pressed state only appears while the button is held down, which on a quick click may be a fraction of a second. It confirms the press, but it is not feedback that an action succeeded. Treat the effect as polish, not as the only signal.

Common mistakes

  • Leaving the drop shadow values in place and just flipping inset. Offsets and blur sized for a wide external shadow flood the inside of the button. Rebuild small.
  • Shading the wrong edge. A negative vertical offset darkens the bottom inner edge and the button looks embossed, the opposite of pressed.
  • Too much depth. Large offsets and heavy opacity turn a button into a well.
  • Pressed at rest with no reason. A permanently inset button reads as disabled or already selected. Keep the effect for the active state, toggles and selected items.
  • Forgetting the resting state. If the pressed shadow replaces nothing, the swap is invisible. The effect lands because the raised shadow gives it something to change from.

FAQs

What does the inset keyword actually do? It moves the shadow from outside the element's border to inside it. The shading appears along the inner edges of the button itself, which is what makes the surface look pushed in.

Which edge should darken for a pressed button? The top inner edge. A positive vertical offset with the inset toggle on shades the inside top of the button, matching a light source above and a surface that dips down away from it. If the bottom edge darkens instead, the button looks raised, not pressed.

How strong should a pressed shadow be? Weaker than you first think. Small offsets of a few pixels, a modest blur and a restrained opacity are enough, because the shading is trapped inside a small element. If the button looks like a hole, the values are too big.

Do I apply the inset shadow to the button all the time? Usually not. The common pattern is a raised button at rest, with the inset version applied under the active state, so the button visibly dips while pressed. Keeping it pressed permanently suits toggles and selected states.

Can I combine an inset shadow with a regular drop shadow? Yes. Layers can be mixed: one layer with the inset toggle on for the pressed shading, and one ordinary layer outside for a faint lift. The generator builds up to four layers, and each layer has its own inset toggle, so the combination is straightforward.

Conclusion

A pressed button is one toggle and a handful of small numbers: inset on, horizontal offset at zero, a few pixels of positive vertical offset, a modest blur, and opacity kept in check. Build it in the Box Shadow Generator, then give it a home in your :active rule so the dip happens exactly when the press does. If your shadows look grubby rather than crisp, our guide to box shadow mistakes that make designs look muddy works through the fixes. More guides in our Website and Webmaster Tools guides.

References