Live preview
Preview settings
Changes appear as you type. Use Tab to test keyboard focus.
⌘ / Ctrl + S saves locally
Animating Buttons
HTML, CSS or Tailwind, and a little JavaScript. One button or a group of up to six.
By @adity2911
Button submission checks
Checks will appear after the preview updates.
Buttons only: no full pages, forms, cards or navigation. Put scripts in the JavaScript tab. Tailwind uses utilities from HTML and JavaScript; use complete class names. Custom CSS supports plain CSS, without @apply, imports or plugins.
Accessibility quick check
Waiting for the rendered preview…
Try Tab, Enter and Space in the preview. Check the focus ring, hover and disabled states, then enable Reduce motion. These checks are guidance, not an accessibility certification.
Explore freely here. Remix to publish your version with credit to the creator.
About Animating Buttons
Animating Buttons is an animated CSS button by @adity2911. Preview the interaction, customize its HTML, styles and JavaScript, or download the files with creator credit.
- Effects and categories
- Icon, Animated
- Using this example
- Copy the HTML or download index.html, style.css and app.js. Test keyboard focus, motion and contrast in your own project.
Usage, Tailwind and licensing questions
Read the source files
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animating Buttons</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="buttonContainer">
<svg class="effect" width="486" height="174" viewBox="0 0 486 174">
<defs>
<clipPath id="theClip">
<path d="m 102,35 h 276 c 28.808,0 52,23.192 52,52 0,28.808 -23.192,52
-52,52 H 102 C 73.192002,139 50,115.808 50,87 50,58.192 73.192002,35
102,35 Z" />
</clipPath>
</defs>
<path style="fill: #e2e0de" d="m 102,35 h 276 c 28.808,0 52,23.192 52,52 0,28.808 -23.192,52
-52,52 H 102 C 73.192002,139 50,115.808 50,87 50,58.192 73.192002,35
102,35 Z" />
<g clip-path="url(#theClip)">
<g class="sprites">
<circle class="sprite1" cx="0" cy="0" r="70" />
<circle class="sprite1" fill="none" stroke="#000" stroke-width="1" cx="0" cy="0" r="70" />
<circle class="sprite2" cx="0" cy="0" r="50" />
<circle class="sprite2" fill="none" stroke="#000" stroke-width="1" cx="0" cy="0" r="50" />
<circle class="sprite3" cx="0" cy="0" r="30" />
<circle class="sprite3" fill="none" stroke="#000" stroke-width="1" cx="0" cy="0" r="30" />
<circle class="sprite4" cx="0" cy="0" r="10" />
<circle class="sprite4" fill="none" stroke="#000" stroke-width="1" cx="0" cy="0" r="10" />
</g>
</g>
<path style="fill: #fcfdff" d="m 102,45 h 276 c 23.268,0 42,18.732 42,42 0,23.268 -18.732,42 -42,42 H 102 C 78.732002,129 60,110.268 60,87 60,63.732 78.732002,45 102,45 Z" />
</svg>
<button class="button">Click me!</button>
</div>
</body>
</html>CSS
body {
align-items: center;
background: linear-gradient(
20deg,
rgba(181, 23, 216, 0.5),
rgba(255, 0, 0, 0) 70.71%
),
linear-gradient(150deg, rgba(182, 92, 255, 0.5), rgba(0, 255, 0, 0) 70.71%),
linear-gradient(330deg, rgba(221, 44, 121, 0.5), rgba(0, 0, 255, 0) 70.71%);
display: flex;
justify-content: center;
height: 100vh;
}
.buttonContainer {
position: relative;
height: 174px;
transform: scale(0.7);
transform-origin: 50% 50%;
transition: transform 60ms;
width: 486px;
}
.buttonContainer:active {
transform: scale(0.65);
}
.button {
position: relative;
background-color: transparent;
border-radius: 50px;
border: 0;
box-shadow: 0px 2.4px 2.2px rgba(0, 0, 0, 0.042),
0px 5.1px 5.3px rgba(0, 0, 0, 0.061), 0px 8.8px 10px rgba(0, 0, 0, 0.075),
0px 15.4px 17.9px rgba(0, 0, 0, 0.089),
0px 30.6px 33.4px rgba(0, 0, 0, 0.108), 0px 100px 80px rgba(0, 0, 0, 0.15);
color: #47515e;
cursor: pointer;
font-size: 30px;
height: 104px;
left: 50px;
top: 35px;
width: 380px;
}
.effect {
position: absolute;
}
.sprites {
animation: Circut 4s linear infinite;
offset-path: path(
"m 102,40.267155 h 275.99997 c 25.89,0 46.73285,20.842849 46.73285,46.732845 0,25.89 -20.84285,46.73285 -46.73285,46.73285 H 102 C 76.110005,133.73285 55.267155,112.89 55.267155,87 55.267155,61.110004 76.110005,40.267155 102,40.267155 Z"
);
transform: rotate(90deg);
}
@keyframes Circut {
to {
motion-offset: 100%;
offset-distance: 100%;
}
}
@keyframes animateScale {
0% {
transform: scale(1.2);
}
25% {
transform: scale(0.6);
}
50% {
transform: scale(1.2);
}
75% {
transform: scale(0.6);
}
100% {
transform: scale(1.2);
}
}
.sprite1 {
animation: animateScale 5s infinite;
animation-delay: 0s;
fill: #d7d5de;
}
.sprite2 {
animation: animateScale 5s infinite;
animation-delay: 0.2s;
fill: #ebdfcf;
}
.sprite3 {
animation: animateScale 5s infinite;
animation-delay: 0.4s;
fill: #eff1f4;
}
.sprite4 {
animation: animateScale 5s infinite;
animation-delay: 0.6s;
fill: #fff;
}