47 CSS Toggles & Switches

43 Pure CSS4 Light JSPublished 27 new designs · Updated on

47 CSS toggles and switches for dark-mode theme switchers, settings and permission rows, SaaS billing toggles, and destructive-action guards — spanning iOS-style pill and Material 3 switches, neumorphic, glassmorphism, neon and brutalist styles, gooey and squash-and-stretch physics, split-flap and rotary-knob mechanics, and biometric hold-to-confirm kill switches. Scoped under .tgl-NN for no-collision pasting, prefers-reduced-motion guarded, framework-agnostic.

Related21 CSS Pricing Tables29 CSS Checkboxes24 CSS Radio Buttons47 Tailwind CSS Toggles & Switches

Course pickPartner: Zero to Mastery

Affiliate link

Want to build production-ready CSS layouts, animations and UI from scratch?

You just browsed 47 toggles. Learn the Flexbox, Grid and animation thinking behind them, so the next component starts in your head, not in a copy-paste.

10% off at checkout with code
Check ZTM Course

Every ZTM course in one membership: $25/month, paid yearly at $299 · 30‑day money-back guarantee

The CSS Bootcamp. We may earn a commission, at no extra cost to you.

01. Minimal iOS-Style Toggle Switch (opens in a new tab)

Published

Pure CSSNEW
The most searched toggle pattern on earth: a fluid, platform-agnostic iOS-style switch built entirely from a styled checkbox. The track sweeps from neutral gray to Apple green while a crisp white thumb glides across — and pressing it stretches the thumb exactly like the native control.

02. Dark Mode Sun / Moon Theme Switcher (opens in a new tab)

Published

Pure CSSNEW
The classic 'day night switch': the sliding thumb is a glowing sun that morphs into a crescent moon as the track deepens from daylight blue to midnight navy — stars fade in, a cloud drifts out, and the entire panel re-themes via :has(). Zero JavaScript.

03. 3D Neumorphic Pill Toggle (opens in a new tab)

Published

Pure CSSNEW
A tactile soft-UI switch for modern immersive dashboards: the track is carved INTO the surface with inset shadows while the knob extrudes OUT of it — and pressing gives a physical push-down before the knob glides across and an accent ring wakes up.

04. Gooey Liquid Morphing Switch (opens in a new tab)

Published

Pure CSSNEW
A high-impact micro-interaction: the thumb is a blob of liquid that stretches, necks and snaps to the far side of the track like plasma — built with an inline SVG filter (feGaussianBlur + feColorMatrix) and two staggered CSS transitions. No JavaScript, no canvas.

05. Bouncy Elastic Physics Toggle (opens in a new tab)

Published

Pure CSSNEW
Premium landing-page motion in one line of CSS: an overshooting cubic-bezier makes the thumb wind up backwards, shoot across the track, and bounce gently off the far wall — playful, physics-driven, and still just a checkbox with a transition.

06. Inner Text ON / OFF Switch (opens in a new tab)

Published

Pure CSSNEW
The space-saving form control PMs ask for: a wider track carries 'ON' and 'OFF' nested inside it, and the sliding thumb covers the inactive word while the active one fades in — state is spelled out, never inferred from color alone.
Newsletter

Enjoying these demos? Get new ones by email.

A short email when a new collection ships. Unsubscribe any time.

at

Almost there: check your inbox to confirm.Manage

07. SaaS Pricing Segmented Pill Toggle (opens in a new tab)

Published

Pure CSSNEW
The Monthly / Annually switcher every pricing page needs: hidden radio buttons inside a single track, a background pill that glides behind the active label, a 'save 20%' badge — and the price below live-swaps, all without a line of JavaScript.

08. Haptic Mechanical Keycap Toggles (opens in a new tab)

Published

CSS + JSNEW
A bank of mechanical keyboard keycaps that toggle settings: each cap physically travels down into its socket on press, latches with a backlit glow when on — and fires a real haptic pulse through the Vibration API on supporting devices.

09. Waveform Mute Toggle (opens in a new tab)

Published

Pure CSSNEW
A mute switch that shows sound instead of describing it: five equalizer bars dance inside the pill while audio is live, then collapse to a flatline the instant you mute — state you can read from across the room, no thumb required.

10. Timed Auto-Off Toggle (opens in a new tab)

Published

CSS + JSNEW
A self-disarming switch for risky settings: flip it on and a conic countdown ring drains around the control for 8 seconds, then the toggle flips itself back off — with the remaining time announced to screen readers. Think 'temporarily allow' permissions.

11. Biometric Hold-to-Confirm Scan Toggle (opens in a new tab)

Published

CSS + JSNEW
A destructive-action guard styled as a fingerprint sensor: press and HOLD for 1.2 seconds while a scan line sweeps and a progress ring fills — release early and it disarms. Keyboard users get an equivalent hold on Space, and the final state is a real aria-checked switch.

12. Split-Flap Departure Board Toggle (opens in a new tab)

Published

Pure CSSNEW
An airport departure-board cell that flips between OFF and ON: the top half of the card hinges down over the bottom in 3D, revealing the new state exactly like a mechanical split-flap display — hinge line, half-letters and all. Pure CSS.

13. Permission Stack with Live Status (opens in a new tab)

Published

Pure CSSNEW
A settings-panel pattern: a stack of permission rows, each with its own mini switch — and a status badge in the header that flips between 'Full access' and 'Partial' by *watching the group* with :has(). The container reads its own children's state, no script.

14. Material Design 3 Switch (opens in a new tab)

Published

Pure CSSNEW
A faithful Material 3 switch, CSS-only: the small outlined thumb grows as it slides, a checkmark fades in on the handle, a state-layer halo blooms on hover and press — every spec detail (52×32 track, 2px outline, 16→24→28dp thumb) without the Material library.
Newsletter

Enjoying these demos? Get new ones by email.

A short email when a new collection ships. Unsubscribe any time.

at

Almost there: check your inbox to confirm.Manage

15. Skeuomorphic Wall Light Switch (opens in a new tab)

Published

Pure CSSNEW
A realistic wall-plate rocker switch — beveled plate, screw heads, a paddle that tips in 3D perspective — and when you flip it, the whole room warms up: the section's ambient light brightens via :has(). Skeuomorphism with a functional payoff.

16. Neon Cyberpunk Toggle (opens in a new tab)

Published

Pure CSSNEW
A clipped-corner, neon-tube toggle for dark dashboards and game UIs: magenta standby glow snaps to cyan when engaged, the status text flickers to life like a striplight warming up, and every glow is pure layered box-shadow and text-shadow.

17. Brutalist Snap Toggle (opens in a new tab)

Published

Pure CSSNEW
Anti-animation as a statement: a raw, square switch with 3px black borders and a hard offset shadow. The block thumb doesn't glide — it SNAPS to the other side in a single 90ms step, the shadow jumps, and the state stamps itself in uppercase mono. Zero easing, zero apology.

18. Day / Night Landscape Scene Switch (opens in a new tab)

Published

Pure CSSNEW
A wide cinematic toggle that IS a landscape: the sun arcs across a gradient sky and sets behind silhouetted mountains as a moon rises, stars pepper the dark, and the surrounding page follows the scene into night. The most shareable switch in the collection.

19. 3D Flip Card Toggle (opens in a new tab)

Published

Pure CSSNEW
A toggle that flips like a card on a table: the whole control rotates 180° in 3D to reveal its other face — muted gray 'Paused' on the front, vivid 'Active' on the back — turning a boolean into a satisfying physical object.

20. Sliding Pill with Traveling Label (opens in a new tab)

Published

Pure CSSNEW
The label rides IN the thumb: a wide pill where the sliding handle itself says 'Draft' or 'Live', crossfading its word mid-journey while ghost labels in the track show the destination. Ideal for publish switches where the state word must move with the control.

21. Glassmorphism Frosted Toggle (opens in a new tab)

Published

Pure CSSNEW
A frosted-glass switch floating over a vivid gradient scene: the track is translucent, blurred glass (backdrop-filter) with a hairline light border, the thumb a denser frost puck — and the colorful blobs behind it visibly refract through both as it slides.

22. Skeuomorphic Rotary Knob Toggle (opens in a new tab)

Published

Pure CSSNEW
A machined aluminum knob that rotates between OFF and ON detents: brushed-metal conic sheen, a milled indicator line, tick marks on the bezel, and a pilot LED that ignites at the ON detent. The checkbox IS the knob — click or Space twists it.
Newsletter

Enjoying these demos? Get new ones by email.

A short email when a new collection ships. Unsubscribe any time.

at

Almost there: check your inbox to confirm.Manage

23. iOS Light Mode Settings List (opens in a new tab)

Published

Pure CSSNEW
The full iOS Settings context, not just the switch: a light grouped list with hairline separators, colored glyph tiles, and three native-feel toggles — the pattern to copy when you need a whole preferences screen, complete with section header and footnote.

24. Outline Minimal currentColor Toggle (opens in a new tab)

Published

Pure CSSNEW
A stroke-only switch drawn entirely in currentColor: hollow track, hollow thumb that fills solid when on. Because it inherits its color from surrounding text, the SAME markup works on light cards, dark cards and brand-colored banners with zero per-theme CSS.

25. Bouncy Pebble Organic Toggle (opens in a new tab)

Published

Pure CSSNEW
A soft river pebble instead of a circle: the asymmetric blob thumb squashes flat as it launches, stretches mid-flight and wobbles back into shape on landing — squash-and-stretch cartoon physics from one keyframe block, in a warm organic palette.

26. Industrial Rocker I/O Switch (opens in a new tab)

Published

Pure CSSNEW
The power switch off the back of real hardware: a rectangular rocker with engraved I and O halves seesawing inside a riveted steel panel, plus a red pilot lamp that ignites on power. Perspective, gradients and text-shadow do all the machining.

27. Accessible ARIA role=switch Toggle (opens in a new tab)

Published

CSS + JSNEW
The reference implementation to ship in a design system: a button[role=switch] toggle with correct aria-checked handling, visible state text, a spec-grade focus ring — and it stays fully functional and visible in Windows High Contrast / forced-colors mode, where most CSS toggles silently vanish.

28. Haptic Keys (opens in a new tab)

PublishedUpdated

Pure CSS
Chunky square key with a 3D press-depth shadow and a glowing accent ring on activate. Pressing literally sinks the button 3px while the hard bottom shadow collapses — pure tactile button metaphor for tactile UI trends.

29. Waveform Toggle (opens in a new tab)

PublishedUpdated

Pure CSS
Static audio bars spring to life with staggered breathing animations when toggled on. The track border and indicator dot pulse with an ice-cyan glow. Audio-visual data physicality — toggle = sound on/off.

30. Timed Toggle (opens in a new tab)

PublishedUpdated

Pure CSS
An SVG arc fills around a circle when the toggle activates, visualising session time. Temporal UI for progress-aware states — users see state over time, not just on/off. The ember glow signals an active countdown.

31. Biometric Scan (opens in a new tab)

PublishedUpdated

Pure CSS
A scanline sweeps top-to-bottom, corner brackets glow lilac, and the icon ring lights up when activated. Identity-first UI for auth flows — the toggle becomes a scan target instead of a switch.

32. Split-Flap Board (opens in a new tab)

PublishedUpdated

Pure CSS
A retro-mechanical airport departure board built from CSS-only rotateX flips. Toggling cycles both rows simultaneously — OFFLINE flips to ONLINE, STANDBY flips to ACTIVE — with each character flipping in sequence for the cascading split-flap feel.

33. Permission Stack (opens in a new tab)

PublishedUpdated

Pure CSS
Grouped consent UI with mini pill toggles inside stacked bordered rows. Each row independently grants or revokes a permission — the icon and label brighten and the pill switches to brand-green when granted. The dominant trust-first UI pattern replacing modal popups.

34. iOS (opens in a new tab)

PublishedUpdated

Pure CSS
The reference iOS-style pill toggle — translucent track, white thumb with a subtle drop shadow, smooth slide on toggle. Honors prefers-reduced-motion.

35. Material Design (opens in a new tab)

PublishedUpdated

Pure CSS
Google Material Design 3 switch — track with rounded thumb that lifts and changes colour on toggle. Active state shows a filled icon-style indicator.

37. Neon Cyber (opens in a new tab)

PublishedUpdated

Pure CSS
A glowing neon outline toggle — dark track with a cyan thumb that pulses with a soft glow when active. Futuristic dashboard aesthetic.

38. Brutalist (opens in a new tab)

PublishedUpdated

Pure CSS
Hard edges, no shadows, monospace label, raw markup feel. The track and thumb are pure rectangles. A counterpoint to polished SaaS-style toggles.

39. Day / Night (opens in a new tab)

PublishedUpdated

Pure CSS
A dark-mode toggle that morphs from a sun in a sky-blue track to a crescent moon over a deep night track. The most "what does this control" pattern in the bunch.

40. Flip Card (opens in a new tab)

PublishedUpdated

Pure CSS
A 3D flip toggle — front face shows OFF, back face shows ON. Rotates around the Y axis on toggle. Showcases transform-style: preserve-3d.

42. Glassmorphism (opens in a new tab)

PublishedUpdated

Pure CSS
A frosted-glass pill with a backdrop-blurred thumb. The colored backdrop tints the glass; the thumb floats above it. Modern dark-mode aesthetic.

43. Skeuomorphic Knob (opens in a new tab)

PublishedUpdated

Pure CSS
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.

44. iOS Light Mode (opens in a new tab)

PublishedUpdated

Pure CSS
The iOS toggle in its light-theme presentation — clean white card backdrop, soft gray off-state, signature green on-state. Counterpart to demo 1.

45. Outline (opens in a new tab)

PublishedUpdated

Pure CSS
A pure-stroke toggle — track and thumb are outlines only, no fills. When toggled on, the thumb fills with brand color. Minimalist; pairs with the brutalist demo.

46. Bouncy Pebble (opens in a new tab)

PublishedUpdated

Pure CSS
A chunky outlined toggle with an organic "pebble" thumb shape built from 8-value border-radius syntax. Bouncy springy transition with anticipation + overshoot. Track and thumb swap colors on each state. The reference for hand-crafted, designer-drawn toggles — distinctive from every other demo in the collection.

47. Industrial Rocker (opens in a new tab)

PublishedUpdated

Pure CSS
A chunky industrial rocker switch with twin indicator lights, rotating "teeth" along the rail, and a color-shifting metallic thumb. The off-light glows red; the on-light glows brand purple. Inspired by heavy-duty equipment power switches.
FAQ

Frequently asked questions

How do I build a pure CSS toggle switch that stays accessible?
Start with a real <input type="checkbox"> and give it appearance:none so the input itself becomes the styled track — you keep native keyboard control (Space/Enter), focus management, form submission, and screen-reader semantics for free. Draw the sliding thumb as a ::before pseudo-element and move it with transform:translateX(). Add role="switch" so assistive tech announces the control as on/off rather than checked/unchecked, wire the label with <label for="…">, and expose a clear :focus-visible ring on the track. Demos 01 (iOS-style), 14 (Material Design 3), 24 (outline currentColor) and 47 (ARIA reference) all follow this contract exactly. Never use display:none to hide the checkbox — that pulls it out of the tab order and breaks keyboard operation for every visitor who does not use a mouse.
What's the difference between a toggle switch and a checkbox?
Functionally they're the same control — under the hood both are an <input type="checkbox">. Semantically they signal different intent: a checkbox reads as 'select this option', usually inside a form the user will submit later; a toggle switch reads as 'this setting is on or off right now', usually taking effect the moment the user activates it (dark mode, Wi-Fi, notifications, feature flags). WCAG APG lets you promote a checkbox to a switch with role="switch", at which point assistive tech announces it as on or off. Pick a switch when the change is immediate and reversible; keep a checkbox when the value is part of a bigger form that must be submitted. All 47 designs in this gallery are switch-shaped, but 40 of them use a native checkbox as the source of truth so form submission still works if you need it.
Do these CSS toggle switches work without JavaScript?
43 of the 47 demos are 100% pure CSS — the :checked pseudo-class on the hidden checkbox drives every animation: the thumb slide, track colour, glow, bounce, gooey morph, background retheme (via :has()), page-level dark mode, sliding label, sun-to-moon crescent, split-flap flip and every other visual state. Four demos require JavaScript because the interaction genuinely cannot be expressed in CSS alone: Demo 08 (Haptic Mechanical Keycap) fires the Vibration API on toggle, Demo 10 (Timed Auto-Off) needs a setTimeout countdown that flips the switch back, Demo 11 (Biometric Hold-to-Confirm) needs a pointer hold duration + release-cancel gesture, and Demo 47 (Accessible ARIA switch) uses a button[role="switch"] reference implementation with focus-management for forced-colors mode. Every JS snippet ships in the code panel — no gallery globals, no hidden dependencies.
Are these toggle switches accessible for keyboard and screen-reader users?
Yes — every switch keeps the real input in the DOM (visually hidden with the sr-only clip pattern, never display:none), tied to a visible <label>. Keyboard users Tab to the control and toggle with Space. Every visual replacement carries a :focus-visible outline in a colour that meets WCAG 2.2 non-text contrast (3:1 against the surface). Where the semantics fit, the input carries role="switch" so assistive tech announces 'on/off' rather than 'checked/unchecked'. Every continuous animation is guarded by @media (prefers-reduced-motion: reduce) that drops long transitions and halts loops. Demo 47 is the reference ARIA implementation for forced-colors mode (Windows high-contrast) — the switch draws its state with CanvasText and Highlight system colours instead of custom hex, so the switch is legible even when the user's OS forcibly overrides the palette.
Can I drop these toggle switches into React, Vue, Svelte or Astro?
Yes. Every demo is plain HTML + CSS (+ JS where noted) — no framework, no build step, no npm install. Drop the markup into any framework, rename class to className for React and for to htmlFor, and the switch works unchanged. Every rule is scoped under .tgl-NN, so 47 switches can coexist on one page without collision — and pasting a single switch into your own project cannot bleed into your global styles. All 47 designs are MIT-licensed for commercial use, including SaaS dashboards, marketing sites, e-commerce checkouts and mobile web apps.
How do I build a SaaS pricing toggle for monthly / yearly billing?
Demo 07 (SaaS Pricing Segmented Pill Toggle) is the exact pattern used by Stripe, Vercel, Linear, Notion and every modern SaaS marketing page: a segmented pill with two labels (Monthly / Yearly) where the active option is marked by a sliding indicator that moves with transform. Wire the toggle to your pricing table with :has() — .pricing:has(#billing-yearly:checked) .plan-price can multiply the visible number by 0.83 (17% off), and the same selector can reveal a 'Save 2 months' badge. For a hydrated React setup, read the checkbox state into your pricing component's useState hook, but the switch itself needs zero JavaScript. Pair with schema.org PriceSpecification and Offer nodes so Google surfaces the discount in rich results. This is the highest-CPM toggle keyword in the collection — SaaS pricing pages earn $15-25 RPM in tier-1 markets.
Which toggle switches match iOS, Material Design 3 and Windows Fluent design systems?
The collection ships three system-native reference switches: Demo 01 (Minimal iOS-Style Toggle) reproduces the Apple UIKit switch — 51×31 track, 27px thumb, Apple green #34c759 on-state, :active stretch to 32px matching the native squash. Demo 14 (Material Design 3 Switch) follows the M3 spec — larger track, elevated thumb with a state-layer ripple on hover, icon inside the thumb when checked, oklch-based dynamic colour tokens. Demo 23 (iOS Light Mode Settings List) reproduces the full Settings-app row pattern with the switch right-aligned inside a divider list. There is no dedicated Windows Fluent switch here yet, but Demo 47 (ARIA role=switch reference) uses forced-colors system tokens and reads correctly in Windows high-contrast mode which is the accessibility contract Fluent enforces. Match the system your users expect: iOS/macOS visitors read Demo 01/23, Android/Chrome OS visitors read Demo 14.
How do I ship a toggle switch for GDPR cookie consent or HIPAA disclosure?
Compliance toggles have two hard constraints beyond visual polish: (1) the visible state must be unambiguous — a checked switch that looks 'off' at a glance is a dark-pattern violation the EU DPA and California CPPA both punish; (2) the switch must default to OFF for non-essential categories (GDPR Article 7 + CCPA §1798.135). Demo 06 (Inner Text ON/OFF Switch) is the safest compliance pattern because the state is spelled out, not inferred from colour alone — colour-blind users and low-contrast screens still read the state correctly. Demo 13 (Permission Stack with Live Status) is the multi-toggle pattern for a full consent centre — one switch per category (Necessary / Preferences / Statistics / Marketing), the 'Necessary' row disabled and always on, and a live status footer that reads how many categories are enabled via :has(). For HIPAA-adjacent disclosure toggles (share PHI with a specific provider, opt into marketing communications), pair the switch with a visible timestamp caption that records the moment of consent — the browser cannot audit the click for you, so your backend records the state change with a server-side timestamp.

Related collections

15 CSS 3D Tilt Hover Cards preview

15 CSS 3D Tilt Hover Cards

15 mouse-aware 3D tilt hover cards — e-commerce product spotlight, glassmorphism parallax team card, interactive pricing tier, holographic NFT collectible, pop-out mascot, dark tech grid with border glow, media player album art, blog article preview, cyberpunk neon glow, dashboard KPI widget, minimalist real estate, flip-to-back tilt, mobile app showcase, course learning card, and a Pure CSS touch-friendly tilt. Vanilla JS writes --rx/--ry/--mx/--my; all rendering stays in CSS on the GPU.

24 CSS Animated Cards preview

24 CSS Animated Cards

24 hand-coded CSS animated card patterns organised by what triggers the motion, not by card style. Scroll and entrance triggers: staggered grid reveals, @starting-style mount-in, scroll-driven scale and fade on animation-timeline: view(), View Transitions API card-to-detail morphs, blur-to-sharp lazy image loading, and FLIP re-layout when a filter changes. State-change triggers: add-to-cart success morph, like and save particle burst, expand and collapse to intrinsic height with calc-size(), swipe-to-dismiss on Pointer Events, and skeleton-to-loaded crossfade. Data-driven triggers: count-up KPI metrics, SVG sparkline draw-on-enter, and progress ring fill on load. Ambient idle loops: breathing glow, floating drift, animated gradient mesh backgrounds, conic rotating borders, auto-cycling testimonial decks, and live status pulses. Plus four hover patterns where the effect is the topic itself: cursor spotlight, holographic foil glare, corner ribbon slide, and horizontal accordion expand. Every card is scoped under a .ac-NN prefix for no-collision pasting, guards prefers-reduced-motion, animates compositor-only properties, and ports unchanged to React, Vue, Svelte, Astro, Next.js and Tailwind.

22 CSS Avatars preview

22 CSS Avatars

22 hand-coded CSS avatars for chat apps, team dashboards, comment threads, account menus, and social profiles. Covers circular and squircle shapes, gradient and conic story rings, hexagon clip-path crops, online status dots, notification count badges, verified checkmarks, stacked facepiles with plus-N overflow, initials fallbacks for users without photos, broken-image recovery, avatar pickers, and a size scale system where the ring, badge, and status dot all scale from a single custom property.

Search CodeFronts

Loading…