47 CSS Toggles & Switches43 / 47

Pure CSSMIT licensed

Skeuomorphic Knob

A brushed-metal rotary knob that physically rotates 90 degrees on toggle. Different motion type from the sliding switches — rotation as the state signal. Tick marks anchor the dial.

Published Updated

Live Demo
Try it

The code

<label class="tgl-43">
  <input class="tgl-43__input" type="checkbox" checked>
  <span class="tgl-43__stage" aria-hidden="true">
    <span class="tgl-43__tick tgl-43__t-off">OFF</span>
    <span class="tgl-43__tick tgl-43__t-on">ON</span>
    <span class="tgl-43__dial">
      <span class="tgl-43__indicator"></span>
    </span>
  </span>
  <span class="tgl-43__label">Power</span>
</label>
.tgl-43 {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #d8d4dc;
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 48px 20px;
  background: #14141e;
  box-sizing: border-box;
}

.tgl-43__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.tgl-43__stage {
  position: relative;
  width: 60px;
  height: 60px;
}

.tgl-43__tick {
  position: absolute;
  font-family: ui-monospace, "Fira Code", monospace;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: #6a6a7a;
}

.tgl-43__t-off {
  top: 4px;
  left: 0;
}

.tgl-43__t-on {
  top: 4px;
  right: 0;
}

.tgl-43__dial {
  position: absolute;
  top: 12px;
  left: 6px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f0e8d8 0%, #6a5a30 90%);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), inset 0 -2px 4px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.4);
  transform: rotate(-45deg);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tgl-43__indicator {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 3px;
  height: 14px;
  background: #2a1d0e;
  border-radius: 2px;
  transform: translateX(-50%);
}

.tgl-43__input:checked ~ .tgl-43__stage .tgl-43__dial {
  transform: rotate(45deg);
}

.tgl-43__input:checked ~ .tgl-43__stage .tgl-43__t-on {
  color: #d8b66e;
}

.tgl-43__input:not(:checked) ~ .tgl-43__stage .tgl-43__t-off {
  color: #d8b66e;
}

.tgl-43__input:focus-visible ~ .tgl-43__stage .tgl-43__dial {
  outline: 2px solid #d8b66e;
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .tgl-43__dial {
    transition: none;
  }
}
/* No JavaScript — the brass dial rotates a 90° throw (−45°→45°) between OFF/ON ticks, its indicator riding the same transform. */
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS Toggles & Switche from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Skeuomorphic Knob
Source: https://codefronts.com/components/css-toggles-switches/skeuomorphic-knob/

A brushed-metal rotary knob that physically rotates 90 degrees on toggle. Different motion type from the sliding switches — rotation as the state signal. Tick marks anchor the dial.
## HTML
```html
<label class="tgl-43">
  <input class="tgl-43__input" type="checkbox" checked>
  <span class="tgl-43__stage" aria-hidden="true">
    <span class="tgl-43__tick tgl-43__t-off">OFF</span>
    <span class="tgl-43__tick tgl-43__t-on">ON</span>
    <span class="tgl-43__dial">
      <span class="tgl-43__indicator"></span>
    </span>
  </span>
  <span class="tgl-43__label">Power</span>
</label>
```
## CSS
```css
.tgl-43 {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #d8d4dc;
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 48px 20px;
  background: #14141e;
  box-sizing: border-box;
}

.tgl-43__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.tgl-43__stage {
  position: relative;
  width: 60px;
  height: 60px;
}

.tgl-43__tick {
  position: absolute;
  font-family: ui-monospace, "Fira Code", monospace;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: #6a6a7a;
}

.tgl-43__t-off {
  top: 4px;
  left: 0;
}

.tgl-43__t-on {
  top: 4px;
  right: 0;
}

.tgl-43__dial {
  position: absolute;
  top: 12px;
  left: 6px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f0e8d8 0%, #6a5a30 90%);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), inset 0 -2px 4px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.4);
  transform: rotate(-45deg);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tgl-43__indicator {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 3px;
  height: 14px;
  background: #2a1d0e;
  border-radius: 2px;
  transform: translateX(-50%);
}

.tgl-43__input:checked ~ .tgl-43__stage .tgl-43__dial {
  transform: rotate(45deg);
}

.tgl-43__input:checked ~ .tgl-43__stage .tgl-43__t-on {
  color: #d8b66e;
}

.tgl-43__input:not(:checked) ~ .tgl-43__stage .tgl-43__t-off {
  color: #d8b66e;
}

.tgl-43__input:focus-visible ~ .tgl-43__stage .tgl-43__dial {
  outline: 2px solid #d8b66e;
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .tgl-43__dial {
    transition: none;
  }
}
```

## JavaScript
```js
/* No JavaScript — the brass dial rotates a 90° throw (−45°→45°) between OFF/ON ticks, its indicator riding the same transform. */
```

How this works

A 48px brass dial (warm radial gradient lit from upper-left, with inset rim highlights and a cast shadow) rotates -45deg → 45deg on check — a true 90° throw between the OFF and ON tick labels parked at the stage's top corners. The indicator bar is a child of the dial, so it simply inherits the rotation.

The active tick label brightens to brass via :checked/:not(:checked) rules, giving a second, position-independent state cue. Focus draws directly on the dial circle. Rotation-as-state is the differentiator here — a deliberate contrast to every sliding pattern in the collection.

Make it yours

  • Widen the throw to ±60° for a more dramatic twist.
  • Swap the brass radial for cool aluminum (see demo 22's conic-brushed variant).
  • Add detent ticks around the dial rim as small positioned spans.
  • Put an LED dot beside the ON tick lit by :checked.

Gotchas — read before shipping

  • Rotate the dial, not the indicator alone — a moving line on a static texture breaks the physical illusion.
  • Tick labels must live outside the rotating element or they'd turn with it.
  • Keep the full dial clickable; the 60px stage ensures a ≥44px hit target.

Browser support

ChromeSafariFirefoxEdge
26+9+16+26+

Transforms + radial gradients; universal in modern browsers.

Techniques used in this demo

Search CodeFronts

Loading…