Live preview
Preview settings
Changes appear as you type. Use Tab to test keyboard focus.
β / Ctrl + S saves locally
MukulsinghRajpurohit's button
HTML, CSS or Tailwind, and a little JavaScript. One button or a group of up to six.
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 MukulsinghRajpurohit's button
MukulsinghRajpurohit's button is an animated CSS button by @MukulsinghRajpurohit. Preview the interaction, customize its HTML, styles and JavaScript, or download the files with creator credit.
- Effects and categories
- Minimal
- 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">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="container">
<button id="emojiButton">Click me!</button>
</div>
<script>
const emojis = ['π', 'π', 'π', 'π', 'π'];
const button = document.getElementById('emojiButton');
let intervalId;
button.addEventListener('click', function () {
clearInterval(intervalId);
intervalId = setInterval(displayEmoji, 100);
setTimeout(stopDisplay, 1000);
});
function displayEmoji() {
const randomCount = Math.floor(Math.random() * emojis.length) + 1;
for (let i = 0; i < randomCount; i++) {
const emojiElement = document.createElement('span');
const randomIndex = Math.floor(Math.random() * emojis.length);
const emoji = emojis[randomIndex];
emojiElement.textContent = emoji;
emojiElement.style.position = 'absolute';
emojiElement.style.left = `${getRandomPosition(button.offsetWidth)}px`;
emojiElement.style.top = `${getRandomPosition(button.offsetHeight)}px`;
emojiElement.style.transform = `translate(-50%, -50%) rotate(${getRandomAngle()}deg)`;
button.appendChild(emojiElement);
animateEmoji(emojiElement);
}
}
function getRandomPosition(dimension) {
const halfDimension = dimension / 2;
const randomOffset = Math.floor(Math.random() * halfDimension) * (Math.random() > 0.5 ? 1 : -1);
return halfDimension + randomOffset;
}
function getRandomAngle() {
return Math.floor(Math.random() * 360);
}
function animateEmoji(emojiElement) {
const destinationX = getRandomPosition(button.offsetWidth);
const destinationY = getRandomPosition(button.offsetHeight);
const duration = Math.floor(Math.random() * 1000) + 500;
const delay = Math.floor(Math.random() * 500);
emojiElement.style.transition = `transform ${duration}ms linear ${delay}ms`;
emojiElement.style.transform = `translate(${destinationX}px, ${destinationY}px) rotate(${getRandomAngle()}deg)`;
setTimeout(function () {
emojiElement.remove();
}, duration + delay);
}
function stopDisplay() {
clearInterval(intervalId);
}
</script>
</body>
</html>
CSS
#container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#emojiButton {
width: 100px;
height: 100px;
border-radius: 50%;
font-size: 1.5rem;
position: relative;
overflow: hidden;
border: 0.5px solid whitesmoke;
background-color: transparent;
color: white;
}
body{
background: black;
}