47 Tailwind CSS Toggles & Switches
05 / 47

All 47 in 47 Tailwind CSS Toggles & Switches

  1. 01Tailwind iOS-Style Toggle Switch with appearance-none
  2. 02Tailwind Dark Mode Sun / Moon Theme Switcher
  3. 03Tailwind Neumorphic Soft-UI Pill Toggle
  4. 04Tailwind Gooey Liquid Morphing Switch with SVG Filter
  5. 05Tailwind Bouncy Elastic Physics Toggle (Overshoot Cubic-Bezier)
  6. 06Tailwind ON / OFF Text Switch with Labels Inside the Track
  7. 07Tailwind SaaS Pricing Toggle — Monthly / Annually Segmented Pill
  8. 08Tailwind Mechanical Keycap Toggles with Haptic Feedback
  9. 09Tailwind Waveform Mute Toggle with Animated EQ Bars
  10. 10Tailwind Timed Auto-Off Toggle with Conic Countdown Ring
  11. 11Tailwind Press-and-Hold to Confirm Toggle (Fingerprint Scan)
  12. 12Tailwind Split-Flap Departure Board Toggle (3D Flip)
  13. 13Tailwind Permission Toggle Group with :has() Live Status Badge
  14. 14Tailwind Material Design 3 Switch with State Layer
  15. 15Tailwind Skeuomorphic Wall Light Switch with Room Relight
  16. 16Tailwind Neon Cyberpunk Toggle with Clipped Corners
  17. 17Tailwind Brutalist Snap Toggle with Hard Offset Shadow
  18. 18Tailwind Day / Night Landscape Scene Switch
  19. 19Tailwind 3D Flip Card Toggle (rotateY Switch)
  20. 20Tailwind Sliding Pill Toggle with Label Inside the Thumb
  21. 21Tailwind Glassmorphism Frosted Toggle with backdrop-blur
  22. 22Tailwind Rotary Knob Toggle with Brushed-Metal Conic Gradient
  23. 23Tailwind iOS Settings List with Grouped Toggle Rows
  24. 24Tailwind Minimal Outline Toggle Drawn in currentColor
  25. 25Tailwind Squash-and-Stretch Pebble Toggle
  26. 26Tailwind Industrial Rocker I/O Power Switch
  27. 27Tailwind Accessible role=switch Toggle with forced-colors Support
  28. 28Tailwind Macro-Pad Toggle Grid with RGB Underglow
  29. 29Tailwind Radial VU Meter Mute Toggle
  30. 30Tailwind Segmented Pip Countdown Auto-Off Toggle
  31. 31Tailwind Slide-to-Confirm Toggle Rail (Drag or Arrow Keys)
  32. 32Tailwind Odometer Roll ON / OFF Toggle
  33. 33Tailwind Master Toggle with Indeterminate Tri-State
  34. 34Tailwind iOS Control Centre Tile Toggles
  35. 35Tailwind Material 3 Connected Icon Toggle Buttons
  36. 36Tailwind Two-Gang Wall Plate with Cumulative Room Light
  37. 37Tailwind Neon Toggle with Animated Conic Border Light
  38. 38Tailwind Brutalist Rubber-Stamp Toggle
  39. 39Tailwind Aurora Night Sky Toggle Switch
  40. 40Tailwind 3D Rotating Cube Toggle
  41. 41Tailwind Three-Position Off / Auto / On Selector
  42. 42Tailwind Liquid Glass Toggle with Specular Highlight
  43. 43Tailwind Three-Detent Rotary Selector Knob
  44. 44Tailwind Hardware Slide Switch with Knurled Grip
  45. 45Tailwind Battery Saver Toggle with Live Fill Meter
  46. 46Tailwind Morphing Sun-to-Moon Icon Toggle (SVG Stroke)
  47. 47Tailwind Guarded Kill Switch Under a Flip-Up Safety Cover
Pure TailwindMIT licensed

Tailwind Bouncy Elastic Physics Toggle (Overshoot Cubic-Bezier)

Premium motion from one token: --ease-ttg05-spring in @theme mints an ease-ttg05-spring utility whose negative first control point winds the thumb backwards before it shoots across and bounces off the far wall. One transition, no keyframes, no spring library.

Live Demo
Plain CSSTailwind v4
Try it

Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time

Untitled UI React · Affiliate link

Get Untitled UI Pro

The code

<section class="ttg-05 w-full min-h-svh flex flex-col items-center justify-center gap-7 px-5 py-14 bg-ttg05-bg font-ttg05-sans" aria-label="Bouncy elastic physics toggle">
  <label for="ttg-05-sw" class="group flex items-center gap-9 px-7 py-5 rounded-3xl cursor-pointer bg-white border border-ttg05-edge shadow-[0_18px_40px_-28px_oklch(0.55_0.09_75/0.55)]">
    <span class="flex items-center gap-3">
      <span aria-hidden="true" class="w-2 h-2 rounded-full bg-ttg05-edge transition-transform duration-[550ms] ease-ttg05-spring group-has-checked:bg-ttg05-on group-has-checked:scale-150"></span>
      <span class="flex flex-col gap-0.5">
        <span class="text-[15.5px] font-semibold text-ttg05-ink">Confetti on publish</span>
        <span class="text-[12.5px] text-ttg05-mute">Because shipping should feel like something</span>
      </span>
    </span>
    <input type="checkbox" id="ttg-05-sw" role="switch" class="appearance-none shrink-0 w-[76px] h-10 rounded-full bg-ttg05-off relative cursor-pointer transition-colors duration-[450ms] before:content-[''] before:absolute before:top-1 before:left-1 before:w-8 before:h-8 before:rounded-full before:bg-white before:shadow-[0_3px_7px_oklch(0.45_0.06_75/0.3)] before:transition-transform before:duration-[550ms] before:ease-ttg05-spring checked:bg-ttg05-on checked:before:translate-x-9 active:before:scale-[0.92] checked:active:before:translate-x-9 checked:active:before:scale-[0.92] focus-visible:outline-3 focus-visible:outline-ttg05-on focus-visible:outline-offset-4 motion-reduce:before:duration-200 motion-reduce:before:ease-out">
  </label>
  <p class="font-ttg05-mono text-[11.5px] text-ttg05-mute">cubic-bezier(0.4, &minus;0.3, 0.6, 1.3)</p>
</section>
@import "tailwindcss";

@theme {
  --color-ttg05-bg: #fdf8ef;
  --color-ttg05-bg: oklch(0.98 0.015 85);
  --color-ttg05-edge: #ece0ca;
  --color-ttg05-edge: oklch(0.91 0.025 85);
  --color-ttg05-off: #e6dcc8;
  --color-ttg05-off: oklch(0.89 0.03 85);
  --color-ttg05-on: #2f9e63;
  --color-ttg05-on: oklch(0.63 0.16 155);
  --color-ttg05-ink: #453c2d;
  --color-ttg05-ink: oklch(0.38 0.025 80);
  --color-ttg05-mute: #8d8269;
  --color-ttg05-mute: oklch(0.6 0.03 85);
  --font-ttg05-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-ttg05-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --ease-ttg05-spring: cubic-bezier(0.4, -0.3, 0.6, 1.3);
}

.ttg-05 {
  width: 100%;
  min-height: 100svh;
}

.ttg-05 input[type="checkbox"] {
  -webkit-appearance: none;
}

Setup — do this once per project

Skip this if your project already runs Tailwind v4.

1Load Tailwind
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

Compiles in the browser — perfect for a CodePen or a quick test, not for production.

2Add the stylesheetRequiredthe @theme block is what makes the custom utilities exist
@import "tailwindcss";

@theme {
  --color-ttg05-bg: #fdf8ef;
  --color-ttg05-bg: oklch(0.98 0.015 85);
  --color-ttg05-edge: #ece0ca;
  --color-ttg05-edge: oklch(0.91 0.025 85);
  --color-ttg05-off: #e6dcc8;
  --color-ttg05-off: oklch(0.89 0.03 85);
  --color-ttg05-on: #2f9e63;
  --color-ttg05-on: oklch(0.63 0.16 155);
  --color-ttg05-ink: #453c2d;
  --color-ttg05-ink: oklch(0.38 0.025 80);
  --color-ttg05-mute: #8d8269;
  --color-ttg05-mute: oklch(0.6 0.03 85);
  --font-ttg05-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-ttg05-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --ease-ttg05-spring: cubic-bezier(0.4, -0.3, 0.6, 1.3);
}

.ttg-05 {
  width: 100%;
  min-height: 100svh;
}

.ttg-05 input[type="checkbox"] {
  -webkit-appearance: none;
}
3Fonts used by this demooptional — skip if you have your own type stack
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap">

What changed in the port

Which parts became utilities, which stayed CSS, and why.

  • --ease-ttg05-spring is the textbook v4 token: one @theme entry mints ease-ttg05-spring, and both the thumb and the label's status dot read it. The breadcrumb collection kept its spring as an arbitrary value because only one element used it — the rule is the second consumer.
  • group-has-checked: lets the status dot react to a checkbox it does not descend from, which the CSS version could only do with a :has() rule written far from either element.
  • The track colour was deliberately NOT given the spring curve. Two eases in one control is intentional, not an oversight.
  • UI change from the CSS original: added a scale-bouncing status dot so the spring curve is legible even when the thumb is at rest, raised the on-green contrast to oklch(0.63 0.16 155) (4.8:1 against white, from 2.9:1), and moved the caption to JetBrains Mono so the bezier reads as the code it is.
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 demo 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: Tailwind Bouncy Elastic Physics Toggle (Overshoot Cubic-Bezier)
Source: https://codefronts.com/components/tailwind-css-toggles-switches/tailwind-bouncy-elastic-physics-toggle-cubic-bezier/

Premium motion from one token: --ease-ttg05-spring in @theme mints an ease-ttg05-spring utility whose negative first control point winds the thumb backwards before it shoots across and bounces off the far wall. One transition, no keyframes, no spring library.
## HTML
```html
<section class="ttg-05 w-full min-h-svh flex flex-col items-center justify-center gap-7 px-5 py-14 bg-ttg05-bg font-ttg05-sans" aria-label="Bouncy elastic physics toggle">
  <label for="ttg-05-sw" class="group flex items-center gap-9 px-7 py-5 rounded-3xl cursor-pointer bg-white border border-ttg05-edge shadow-[0_18px_40px_-28px_oklch(0.55_0.09_75/0.55)]">
    <span class="flex items-center gap-3">
      <span aria-hidden="true" class="w-2 h-2 rounded-full bg-ttg05-edge transition-transform duration-[550ms] ease-ttg05-spring group-has-checked:bg-ttg05-on group-has-checked:scale-150"></span>
      <span class="flex flex-col gap-0.5">
        <span class="text-[15.5px] font-semibold text-ttg05-ink">Confetti on publish</span>
        <span class="text-[12.5px] text-ttg05-mute">Because shipping should feel like something</span>
      </span>
    </span>
    <input type="checkbox" id="ttg-05-sw" role="switch" class="appearance-none shrink-0 w-[76px] h-10 rounded-full bg-ttg05-off relative cursor-pointer transition-colors duration-[450ms] before:content-[''] before:absolute before:top-1 before:left-1 before:w-8 before:h-8 before:rounded-full before:bg-white before:shadow-[0_3px_7px_oklch(0.45_0.06_75/0.3)] before:transition-transform before:duration-[550ms] before:ease-ttg05-spring checked:bg-ttg05-on checked:before:translate-x-9 active:before:scale-[0.92] checked:active:before:translate-x-9 checked:active:before:scale-[0.92] focus-visible:outline-3 focus-visible:outline-ttg05-on focus-visible:outline-offset-4 motion-reduce:before:duration-200 motion-reduce:before:ease-out">
  </label>
  <p class="font-ttg05-mono text-[11.5px] text-ttg05-mute">cubic-bezier(0.4, &minus;0.3, 0.6, 1.3)</p>
</section>
```
## CSS
```css
@import "tailwindcss";

@theme {
  --color-ttg05-bg: #fdf8ef;
  --color-ttg05-bg: oklch(0.98 0.015 85);
  --color-ttg05-edge: #ece0ca;
  --color-ttg05-edge: oklch(0.91 0.025 85);
  --color-ttg05-off: #e6dcc8;
  --color-ttg05-off: oklch(0.89 0.03 85);
  --color-ttg05-on: #2f9e63;
  --color-ttg05-on: oklch(0.63 0.16 155);
  --color-ttg05-ink: #453c2d;
  --color-ttg05-ink: oklch(0.38 0.025 80);
  --color-ttg05-mute: #8d8269;
  --color-ttg05-mute: oklch(0.6 0.03 85);
  --font-ttg05-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-ttg05-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --ease-ttg05-spring: cubic-bezier(0.4, -0.3, 0.6, 1.3);
}

.ttg-05 {
  width: 100%;
  min-height: 100svh;
}

.ttg-05 input[type="checkbox"] {
  -webkit-appearance: none;
}
```

How this works

The effect is the curve. cubic-bezier(0.4, -0.3, 0.6, 1.3) takes progress below 0 at the start — the anticipation wind-up — and past 1 at the end, overshooting the target before settling. That is the whole demo. Because it is a single compositor-driven transform transition, it costs nothing on the main thread.

Why it belongs in @theme. The curve is used by the thumb and the label's accent dot. The moment a second element needs a value, it is a design token, and --ease-* is the v4 namespace that mints ease-* utilities. An arbitrary ease-[cubic-bezier(...)] repeated twice is a copy-paste bug waiting to happen.

Colour must not bounce. The track keeps transition-colors duration-[450ms] on the default curve. An overshooting colour interpolation reads as a flicker, not a spring — the same mistake as easing opacity with a bounce.

Make it yours

  • More drama: cubic-bezier(0.4,-0.6,0.5,1.6) grows both the wind-up and the bounce.
  • Stiffer spring: drop the duration to duration-[350ms] and keep the curve.
  • Give :active the same curve for a squishier press.
  • Travel scales with the track: thumb travel = width &minus; thumb &minus; 2 × inset.

Gotchas — read before shipping

  • Overshoot needs headroom. The thumb travels ~15% past its target, so keep at least 4px of inset or it visually clips the track edge.
  • Never put an overshoot curve on background-color, opacity or filter — those interpolate through invalid-looking states.
  • Keyframes are the wrong tool here: a bounce authored as @keyframes plays forwards on uncheck too, which looks broken. A transition reverses for free.

Browser support

ChromeSafariFirefoxEdge
111+16.4+128+111+

Custom cubic-bezier() with y-values outside [0,1] has been supported for over a decade; this is among the most portable demos in the collection.

Techniques used in this demo

Utilitiesfirst-class utility or variant

Search CodeFronts

Loading…