Back to buttons

Live preview

Preview settings

Changes appear as you type. Use Tab to test keyboard focus.

⌘ / Ctrl + S saves locally

Button_amrit2611

HTML, CSS or Tailwind, and a little JavaScript. One button or a group of up to six.

By @amrit2611

Remix button

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 Button_amrit2611

Button_amrit2611 is an animated CSS button by @amrit2611. 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">
    <title>Button_amrit2611</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <button id="myButton">Button</button>
      </div>
</body>
<script src="app.js"></script>
</html>

CSS


/* The display flex property and other properties used below make it possible to center the div vertically and horizontally */

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: auto;
  min-height: 100%;
}

body {
  margin: 0;
  height: 100%;
}

html {
  height: 100%;
}

/* For the code responsible for the animation, checkout the 'animation.js' file */

JavaScript

const myButton = document.querySelector("#myButton");

myButton.style.transform = "scale(2)";

// We create the smooth scaling animation using the transition property.
// Inside the transition property, we can mention all the properties that we want to be a part of the animation.
// This is a simple scaling animation in which the button changes its color and scale when hovered.

myButton.addEventListener("mouseenter", () => {
  myButton.style.boxShadow = "0px 5px 10px rgba(0, 0, 0, 0.3)";
  myButton.style.backgroundColor = "black";
  myButton.style.color = "white";
  myButton.style.transition =
    "transform 0.4s ease-in-out, background-color 0.25s ease-in-out";
  myButton.style.transform = "scale(2.5)";
});

// Below, we make the button go back to the initial state.

myButton.addEventListener("mouseleave", () => {
  myButton.style.backgroundColor = "white";
  myButton.style.color = "black";
  myButton.style.boxShadow = "none";
  myButton.style.transform = "scale(2)";
});