Dark CSS

Animated Checkbox CSS | Design and Animate Custom Checkbox

Facebook
Twitter
WhatsApp

Project Demo

html code

				
					<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Custom checkbox</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <input type="checkbox" role="switch" class="custom_radio" />
</body> 
</html>
				
			

css code

				
					body {
  display: grid;
  place-items: center;
  margin: 0;
  height: 100vh;
  background: #e8e8e8;
  box-sizing: border-box;
  padding: 10vmin;
}

.custom_radio {
  background: #222;
  border-radius: 10em;
  position: relative;
  filter: blur(0.5em) contrast(12);
  box-shadow: 0 0 0 1em #fff;
  appearance: none;
  width: 10em;
  aspect-ratio: 5 / 2;
  mix-blend-mode: darken;
  transition: transform .75s cubic-bezier(.5, 1.85, .5, .75);
}

.custom_radio::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 22% 55%,
      #fff 11%, transparent 0);
  transition: transform .75s;
}

.custom_radio:checked {
  transform: rotate(180deg);
}

.custom_radio:checked::before {
  transform: rotate(-360deg);
}