The Material ripple without JavaScript: pressing grows a soft circle from the center of the button, releasing fades it out. The circle is a pseudo-element that only transitions while :active.
Also known as: css button ripple effect, material ripple button, click ripple effect css.
<button class="btn-ripple-click" type="button">Click me</button>
.btn-ripple-click {
--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;
position: relative;
isolation: isolate;
overflow: hidden;
background: var(--c);
color: #fff;
box-shadow: 0 0.35em 0.8em -0.3em var(--c);
transition: box-shadow 0.25s ease, transform 0.25s ease;}
.btn-ripple-click::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
width: 160%;
aspect-ratio: 1;
border-radius: 50%;
background: radial-gradient(closest-side, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.16));
transform: translate(-50%, -50%) scale(0);
opacity: 0;
pointer-events: none;
transition: transform 0s 0.5s, opacity 0.5s ease;
}
.btn-ripple-click:active {
transform: scale(0.98);
box-shadow: 0 0.15em 0.35em -0.15em var(--c);
}
.btn-ripple-click:active::after {
transform: translate(-50%, -50%) scale(1);
opacity: 1;
transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0s;
}
.btn-ripple-click:focus-visible {
outline: 2px solid var(--c);
outline-offset: 0.2em;
}
@media (prefers-reduced-motion: reduce) {
.btn-ripple-click, .btn-ripple-click *, .btn-ripple-click::before, .btn-ripple-click::after, .btn-ripple-click *::before, .btn-ripple-click *::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="relative overflow-hidden rounded-lg bg-blue-500 px-6 py-3 font-semibold text-white shadow-md transition active:scale-[.98] after:pointer-events-none after:absolute after:left-1/2 after:top-1/2 after:aspect-square after:w-[160%] after:-translate-x-1/2 after:-translate-y-1/2 after:scale-0 after:rounded-full after:bg-white/30 after:opacity-0 after:transition-[transform,opacity] after:duration-[0s,500ms] after:delay-[500ms,0s] active:after:scale-100 active:after:opacity-100 active:after:duration-[600ms,0s] active:after:delay-0 active:after:ease-out"> Click 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.