Hover each button to see it move, then hit Copy CSS and paste it straight into your own project. Every example is pure HTML + CSS — no libraries, no build step — so you can read exactly how the effect works and tweak it.
New to this? Each snippet includes the button's HTML and its CSS together.
Paste the CSS into your stylesheet (or a <style> tag) and drop the
HTML wherever you want the button. Change the colours, radius, and timing to make it yours.
A stacked box-shadow gives the button real height, then it presses down into that shadow when clicked. Tactile and playful — great for bold, game-like interfaces.
The gradient background pans on a continuous loop with a keyframe animation, so the button subtly moves even at rest. A lively option for hero and landing-page CTAs.
The current label rolls up out of view while a new one rolls in from below, clipped by the button's edges. A fun touch for confirmations and downloads.
<button class="btn-swap">
<span class="swap-out">Download</span>
<span class="swap-in">Let's go!</span>
</button>
.btn-swap {
position: relative; overflow: hidden; /* clips the labels as they roll */
display: inline-grid; /* stack both labels in one cell */
border: 0; border-radius: 8px;
background: #091315; color: #fff;
font: 600 15px/1 'DM Sans', sans-serif; cursor: pointer;
transition: background .35s ease; /* darkens to green on hover */
}
.btn-swap:hover { background: #54734e; }
/* Padding lives on the LABEL so each one is the full button height —
translateY(100%) then moves it completely out of view (no overlap). */
.btn-swap span {
grid-area: 1 / 1;
display: grid; place-items: center;
padding: 14px 30px;
transition: transform .35s cubic-bezier(.65,0,.35,1);
}
.btn-swap .swap-in { transform: translateY(100%); } /* waits fully below */
.btn-swap:hover .swap-out { transform: translateY(-100%); }
.btn-swap:hover .swap-in { transform: translateY(0); }
Copy the CSS for the button you like and paste it into your stylesheet (or a <style> tag), then add the matching HTML button element where you want it to appear. Every example on this page includes both the HTML and the CSS together, so it works as a drop-in with no extra setup.
Do these animated buttons need JavaScript?
No. All ten buttons are built with pure HTML and CSS. The animations use CSS transitions, transforms, pseudo-elements and keyframes, so they run in every modern browser without any JavaScript or libraries.
Are these CSS buttons free to use?
Yes. You're free to copy, paste, edit and use every snippet in personal and commercial projects. No attribution is required.
How do I change a button's colour or size?
Edit the values in the CSS: change the background and color for colours, padding for size, border-radius for roundness, and the transition or animation duration to speed the effect up or slow it down.
Do CSS hover effects work on mobile?
Hover doesn't exist on touchscreens, so hover-triggered effects generally fire on tap instead. Effects that animate on their own (like the animated gradient) work everywhere. For key actions, pair a hover effect with an :active or :focus state so touch users get feedback too.