CSS Power Toggle Button

A round power button that lights up with a cyan glow when switched on, using a hidden checkbox.

  • on off
  • glow
  • checkbox
  • switch
  • dark
HTML
<label class="btn-power">
  <input type="checkbox" aria-label="Power">
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v8"/><path d="M6.3 6.8a8 8 0 1 0 11.4 0"/></svg>
</label>
CSS
.btn-power {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1f2937, #111827);
  color: #4b5563;
  box-shadow:
    inset 0 1px 0 #374151,
    0 10px 24px #00000099;
  cursor: pointer;
  transition: color 0.3s ease, box-shadow 0.3s ease;
}

.btn-power input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.btn-power svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  pointer-events: none;
  transition: filter 0.3s ease;
}

.btn-power:hover {
  color: #6b7280;
}

.btn-power:has(input:checked) {
  color: #22d3ee;
  box-shadow:
    inset 0 1px 0 #374151,
    0 0 0 2px #22d3ee66,
    0 0 32px #22d3ee66;
}

.btn-power:has(input:checked) svg {
  filter: drop-shadow(0 0 6px #22d3ee);
}

.btn-power:has(input:focus-visible) {
  outline: 2px solid #67e8f9;
  outline-offset: 5px;
}

About this CSS Power Toggle Button

This CSS Power Toggle Button is 55 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses transitions, linear gradients, box shadows and filters. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #1f2937
  • #111827
  • #4b5563
  • #374151
  • #00000099
  • #6b7280
  • #22d3ee
  • #22d3ee66
  • #67e8f9

How to use this power toggle button

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .btn-power class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback