Presets

3D press button

A chunky button with a solid edge that sinks into the page when you press it.

CSSTailwindReactGIFMP4
00.000 / 0.120s
timing
style
content
20 max

npm i motion · the component uses motion/react

How it works

The 3D press button has a solid colored edge under it, so it looks like a physical key standing off the page. When you press it, it moves down by exactly that edge height and the edge disappears, as if you pushed it flat.

The edge is a box-shadow with no blur: 0 Depth px 0 0 in Edge color. In the pressed state (:active in CSS, whileTap in the React version) the button gets transform: translateY(Depth px) and the shadow offset drops to 0. Both properties transition together over a very short Duration (0.12s by default), so the top of the button and the bottom of the edge meet at the same moment.

It suits playful products, games, kids' apps and big touch targets on mobile where tactile feedback matters. Parameters: Label, Button color, Edge color, Text color, Depth, Corner radius, Duration and Easing. Pick Edge color as a darker shade of Button color; about 30 to 40% darker reads as a side face. Depth between 4 and 8px is convincing. Keep Duration under 0.15s, because a slow press feels laggy; ease-out makes the button hit the bottom quickly.

The visible face moves down while the layout box stays put, so surrounding elements do not jump. Mobile Safari only applies :active when the page has a touch listener, so if presses look dead on iOS, add an empty touchstart handler to the body or use the React version.

How do I make the button look deeper?

Increase Depth. It controls both the edge height in the resting state and how far the button travels when pressed, so they always match. Values above 10px look cartoonish but work for game interfaces. If you increase Depth, add the same amount of bottom margin so the edge does not touch content below.

Does the press work with the keyboard?

In most browsers :active applies while the Space key is held on a focused button, so keyboard users see the same press. Enter activates the button instantly without a visible press. Add a clear :focus-visible outline as well, since the default button outline may be hidden by your reset.

Why animate box-shadow and transform together?

The transform moves the button face down, and the shadow shrink removes the edge below it. If only the transform ran, the edge would stay visible under the moved button and look detached. Running both with the same duration and easing keeps the illusion of a single solid object sinking into the page.

relatedMore like this

all buttons →
01 Loading button loop
02 Shine sweep button loop
03 Pulse glow button loop
04 Border draw button hover
05 Gradient shift button loop

Export

format
height

480p max · small watermark · 3 per day · remove limits