A raised button that sinks on click: the drop shadow collapses into an inner shadow, the face dips and shrinks a touch, then springs back on release. Both shadow lists have four layers so they tween.
Also known as: css button pressed effect, css button active animation, press down button css.
<button class="btn-pressed-sink" type="button">Press me</button>
.btn-pressed-sink {
--c: var(--btn-color, #3b82f6);
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5em;
padding: 0.75em 1.6em;
border: 0;
border-radius: 0.6em;
font: 600 var(--btn-size, 18px)/1.1 system-ui, sans-serif;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
background: linear-gradient(color-mix(in srgb, var(--c) 82%, #fff), var(--c));
color: #fff;
text-shadow: 0 1px 0 color-mix(in srgb, var(--c) 70%, #000);
box-shadow:
0 0.1em 0.15em rgba(0, 0, 0, 0.15),
0 0.5em 1em -0.35em color-mix(in srgb, var(--c) 75%, #000),
inset 0 1px 0 rgba(255, 255, 255, 0.35),
inset 0 0 0 transparent;
transition:
transform 0.4s cubic-bezier(0.3, 1.8, 0.6, 1),
box-shadow 0.3s ease,
filter 0.3s ease;}
.btn-pressed-sink:active {
transform: translateY(0.12em) scale(0.97);
filter: brightness(0.94);
box-shadow:
0 0 0 transparent,
0 0.1em 0.2em -0.1em color-mix(in srgb, var(--c) 75%, #000),
inset 0 1px 0 transparent,
inset 0 0.2em 0.45em rgba(0, 0, 0, 0.35);
transition-duration: 0.08s;
transition-timing-function: ease-out;
}
.btn-pressed-sink:focus-visible {
outline: 2px solid var(--c);
outline-offset: 0.2em;
}
@media (prefers-reduced-motion: reduce) {
.btn-pressed-sink, .btn-pressed-sink *, .btn-pressed-sink::before, .btn-pressed-sink::after, .btn-pressed-sink *::before, .btn-pressed-sink *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<button class="rounded-lg bg-gradient-to-b from-blue-400 to-blue-500 px-6 py-3 font-semibold text-white shadow-[0_2px_3px_rgba(0,0,0,.15),0_8px_16px_-6px_#1e40af,inset_0_1px_0_rgba(255,255,255,.35)] transition duration-300 ease-[cubic-bezier(.3,1.8,.6,1)] active:translate-y-0.5 active:scale-[.97] active:shadow-[inset_0_3px_7px_rgba(0,0,0,.35)] active:brightness-95 active:duration-75 active:ease-out"> Press me </button>
--btn-color on the element or a parent.
Currently previewing #3b82f6.--btn-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 18px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.