Live preview
Preview settings
Changes appear as you type. Use Tab to test keyboard focus.
⌘ / Ctrl + S saves locally
riddhitech's button
HTML, CSS or Tailwind, and a little JavaScript. One button or a group of up to six.
By @riddhitech
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 riddhitech's button
riddhitech's button is an animated CSS button by @riddhitech. Preview the interaction, customize its HTML, styles and JavaScript, or download the files with creator credit.
- Effects and categories
- Hover effects, Loading, 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 name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<button class="btn">
<i class='bx bx-send'></i>
<span class="text">
Send Message
</span>
<span class="loading-animate"></span>
</button>
</body>
<script type="text/javascript" src="app.js"></script>
</html>CSS
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background: #F1F3F6;
overflow: hidden;
}
.btn {
background: #49D75C;
border: 0px solid #49D75C;
border-radius: 35px;
font-size: 1rem;
font-weight: bold;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
outline: none;
transition: all .25s ease;
width: 210px;
position: relative;
height: 60px;
overflow: hidden;
}
.btn:not(.loading):hover {
box-shadow: 0px 10px 25px 0px rgba(73, 215, 92,.4);
}
.btn:not(.loading):hover i {
transform: translate(7px);
}
.btn i {
font-size: 1.45rem;
position: absolute;
left: 0px;
pointer-events: none;
z-index: 10;
background: inherit;
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
transition: all .25s ease;
}
.btn .text {
width: 130px;
display: block;
position: relative;
pointer-events: none;
transition: all .25s ease;
position: absolute;
left: 60px;
}
.loading-animate {
position: absolute;
width: 60px;
height: 60px;
z-index: 100;
border-radius: 50%;
top: 0px;
left: 0px;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
opacity: 0;
transition: all .25s ease;
}
.loading-animate:after {
content: '';
width: 44px;
height: 44px;
border-radius: 50%;
border: 3px solid transparent;
border-left: 3px solid #fff;
animation: loading infinite .8s ease .05s;
position: absolute;
}
.loading-animate:before {
content: '';
width: 44px;
height: 44px;
border-radius: 50%;
border: 3px solid transparent;
border-left: 3px solid #fff;
animation: loading infinite .8s linear;
position: absolute;
opacity: .6;
}
.btn.loading {
width: 60px;
}
.btn.loading i {
transform: rotate(-90deg);
padding-bottom: 4px;
padding-left: 3px;
}
.btn.loading .text {
transform: translate(-140px);
}
.btn.loading .loading-animate {
opacity: 1;
}
@keyframes loading {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}JavaScript
document.querySelector('.btn').addEventListener('click', (evt) => {
evt.target.classList.add('loading')
setTimeout(() => {
evt.target.classList.remove('loading')
}, 3000);
})