Live preview
Preview settings
Changes appear as you type. Use Tab to test keyboard focus.
⌘ / Ctrl + S saves locally
Animated Buttons
HTML, CSS or Tailwind, and a little JavaScript. One button or a group of up to six.
By @AFPedreros
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 Animated Buttons
Animated Buttons is an animated CSS button by @AFPedreros. Preview the interaction, customize its HTML, styles and JavaScript, or download the files with creator credit.
- Effects and categories
- Hover effects, 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" dir="ltr">
<head>
<meta charset="utf-8" />
<title>Animated Buttons</title>
<link rel="stylesheet" href="style.css" />
<link
href="https://fonts.googleapis.com/css2?family=Heebo:wght@400;700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<button id="wallet-btn">Click Me</button>
<script type="module" src="app.js"></script>
</body>
</html>
CSS
@import url("https://fonts.googleapis.com/css2?family=Heebo:wght@400;700&display=swap");
* {
margin: 0;
padding: 0;
}
body {
font-family: "Heebo", sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
background-color: #141414;
}
button {
background-color: purple;
color: white;
border: none;
border-radius: 30px;
text-transform: uppercase;
letter-spacing: 1.5px;
padding: 15px 25px;
overflow: hidden;
margin: 10px 0;
position: relative;
cursor: pointer;
font-weight: 700;
}
button:hover {
outline: none;
border: 2px purple solid;
}
button .circle {
position: absolute;
background-color: white;
width: 100px;
height: 100px;
border-radius: 50%;
transform: translate(-50%, -50%) scale(0);
animation: scale 0.75s ease-out;
}
button .dark-circle {
position: absolute;
background-color: black;
width: 100px;
height: 100px;
border-radius: 50%;
transform: translate(-50%, -50%) scale(0);
animation: scale 0.75s ease-out;
}
@keyframes scale {
to {
transform: translate(-50%, -50%) scale(3);
opacity: 0;
}
}
JavaScript
const walletBtn = document.getElementById("wallet-btn")
const circle = document.createElement("span")
walletBtn.addEventListener("click", (e) => {
const x = e.clientX
const y = e.clientY
const buttonTop = e.target.offsetTop
const buttonLeft = e.target.offsetLeft
const xInside = x - buttonLeft
const yInside = y - buttonTop
circle.classList.add("circle")
circle.style.top = yInside + "px"
circle.style.left = xInside + "px"
e.target.appendChild(circle)
setTimeout(() => {
circle.remove()
}, 10000)
})