36 / 47
All 47 in 47 Tailwind CSS Toggles & Switches
- 01Tailwind iOS-Style Toggle Switch with appearance-none
- 02Tailwind Dark Mode Sun / Moon Theme Switcher
- 03Tailwind Neumorphic Soft-UI Pill Toggle
- 04Tailwind Gooey Liquid Morphing Switch with SVG Filter
- 05Tailwind Bouncy Elastic Physics Toggle (Overshoot Cubic-Bezier)
- 06Tailwind ON / OFF Text Switch with Labels Inside the Track
- 07Tailwind SaaS Pricing Toggle — Monthly / Annually Segmented Pill
- 08Tailwind Mechanical Keycap Toggles with Haptic Feedback
- 09Tailwind Waveform Mute Toggle with Animated EQ Bars
- 10Tailwind Timed Auto-Off Toggle with Conic Countdown Ring
- 11Tailwind Press-and-Hold to Confirm Toggle (Fingerprint Scan)
- 12Tailwind Split-Flap Departure Board Toggle (3D Flip)
- 13Tailwind Permission Toggle Group with :has() Live Status Badge
- 14Tailwind Material Design 3 Switch with State Layer
- 15Tailwind Skeuomorphic Wall Light Switch with Room Relight
- 16Tailwind Neon Cyberpunk Toggle with Clipped Corners
- 17Tailwind Brutalist Snap Toggle with Hard Offset Shadow
- 18Tailwind Day / Night Landscape Scene Switch
- 19Tailwind 3D Flip Card Toggle (rotateY Switch)
- 20Tailwind Sliding Pill Toggle with Label Inside the Thumb
- 21Tailwind Glassmorphism Frosted Toggle with backdrop-blur
- 22Tailwind Rotary Knob Toggle with Brushed-Metal Conic Gradient
- 23Tailwind iOS Settings List with Grouped Toggle Rows
- 24Tailwind Minimal Outline Toggle Drawn in currentColor
- 25Tailwind Squash-and-Stretch Pebble Toggle
- 26Tailwind Industrial Rocker I/O Power Switch
- 27Tailwind Accessible role=switch Toggle with forced-colors Support
- 28Tailwind Macro-Pad Toggle Grid with RGB Underglow
- 29Tailwind Radial VU Meter Mute Toggle
- 30Tailwind Segmented Pip Countdown Auto-Off Toggle
- 31Tailwind Slide-to-Confirm Toggle Rail (Drag or Arrow Keys)
- 32Tailwind Odometer Roll ON / OFF Toggle
- 33Tailwind Master Toggle with Indeterminate Tri-State
- 34Tailwind iOS Control Centre Tile Toggles
- 35Tailwind Material 3 Connected Icon Toggle Buttons
- 36Tailwind Two-Gang Wall Plate with Cumulative Room Light
- 37Tailwind Neon Toggle with Animated Conic Border Light
- 38Tailwind Brutalist Rubber-Stamp Toggle
- 39Tailwind Aurora Night Sky Toggle Switch
- 40Tailwind 3D Rotating Cube Toggle
- 41Tailwind Three-Position Off / Auto / On Selector
- 42Tailwind Liquid Glass Toggle with Specular Highlight
- 43Tailwind Three-Detent Rotary Selector Knob
- 44Tailwind Hardware Slide Switch with Knurled Grip
- 45Tailwind Battery Saver Toggle with Live Fill Meter
- 46Tailwind Morphing Sun-to-Moon Icon Toggle (SVG Stroke)
- 47Tailwind Guarded Kill Switch Under a Flip-Up Safety Cover
Tailwind Two-Gang Wall Plate with Cumulative Room Light
Two switches on one plate, and the room responds to BOTH: one on is a dim pool of light, two on floods the scene. Counting children in pure CSS is the trick — :has() can test combinations even though it cannot count.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="ttg-36 relative overflow-hidden w-full min-h-svh flex flex-col items-center justify-center gap-8 px-5 py-14 bg-ttg36-dark font-ttg36-sans transition-colors duration-700 has-[#ttg-36-a:checked]:bg-ttg36-dim has-[#ttg-36-b:checked]:bg-ttg36-dim has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:bg-ttg36-bright has-[#ttg-36-a:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-b:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:[&_.ttg36-wash]:opacity-100 motion-reduce:transition-none" aria-label="Two gang wall plate">
<span aria-hidden="true" class="ttg36-pool pointer-events-none absolute top-[10%] left-1/2 -translate-x-1/2 w-80 h-80 rounded-full opacity-0 transition-opacity duration-700 bg-radial from-ttg36-glow to-transparent to-70% motion-reduce:transition-none"></span>
<span aria-hidden="true" class="ttg36-wash pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-700 bg-radial from-ttg36-wash to-transparent to-75% motion-reduce:transition-none"></span>
<div class="relative z-10 flex gap-5 px-7 py-8 rounded-2xl bg-linear-170 from-ttg36-platehi to-ttg36-platelo shadow-[inset_0_2px_0_oklch(1_0_0/0.85),inset_0_-3px_5px_oklch(0.4_0.03_80/0.3),0_20px_38px_-16px_oklch(0_0_0/0.6)]">
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-a" role="switch" aria-label="Ceiling light" class="peer sr-only">
<label for="ttg-36-a" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">CEILING</span>
</span>
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-b" role="switch" aria-label="Lamps" class="peer sr-only">
<label for="ttg-36-b" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">LAMPS</span>
</span>
</div>
<p class="relative z-10 text-[12px] tracking-[0.12em] uppercase text-ttg36-caption transition-colors duration-700 [.ttg-36:has(:checked)_&]:text-ttg36-captionlit motion-reduce:transition-none">One on dims the room · two floods it</p>
</section><section class="ttg-36 relative overflow-hidden w-full min-h-svh flex flex-col items-center justify-center gap-8 px-5 py-14 bg-ttg36-dark font-ttg36-sans transition-colors duration-700 has-[#ttg-36-a:checked]:bg-ttg36-dim has-[#ttg-36-b:checked]:bg-ttg36-dim has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:bg-ttg36-bright has-[#ttg-36-a:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-b:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:[&_.ttg36-wash]:opacity-100 motion-reduce:transition-none" aria-label="Two gang wall plate">
<span aria-hidden="true" class="ttg36-pool pointer-events-none absolute top-[10%] left-1/2 -translate-x-1/2 w-80 h-80 rounded-full opacity-0 transition-opacity duration-700 bg-radial from-ttg36-glow to-transparent to-70% motion-reduce:transition-none"></span>
<span aria-hidden="true" class="ttg36-wash pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-700 bg-radial from-ttg36-wash to-transparent to-75% motion-reduce:transition-none"></span>
<div class="relative z-10 flex gap-5 px-7 py-8 rounded-2xl bg-linear-170 from-ttg36-platehi to-ttg36-platelo shadow-[inset_0_2px_0_oklch(1_0_0/0.85),inset_0_-3px_5px_oklch(0.4_0.03_80/0.3),0_20px_38px_-16px_oklch(0_0_0/0.6)]">
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-a" role="switch" aria-label="Ceiling light" class="peer sr-only">
<label for="ttg-36-a" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">CEILING</span>
</span>
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-b" role="switch" aria-label="Lamps" class="peer sr-only">
<label for="ttg-36-b" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">LAMPS</span>
</span>
</div>
<p class="relative z-10 text-[12px] tracking-[0.12em] uppercase text-ttg36-caption transition-colors duration-700 [.ttg-36:has(:checked)_&]:text-ttg36-captionlit motion-reduce:transition-none">One on dims the room · two floods it</p>
</section>@import "tailwindcss";
@theme {
--color-ttg36-dark: #1f232c;
--color-ttg36-dark: oklch(0.25 0.015 265);
--color-ttg36-dim: #4a4436;
--color-ttg36-dim: oklch(0.44 0.03 85);
--color-ttg36-bright: #efe1c2;
--color-ttg36-bright: oklch(0.92 0.05 88);
--color-ttg36-glow: #ffd07a;
--color-ttg36-glow: oklch(0.87 0.13 80 / 0.45);
--color-ttg36-wash: #ffe6b5;
--color-ttg36-wash: oklch(0.92 0.08 85 / 0.4);
--color-ttg36-platehi: #f5f2eb;
--color-ttg36-platehi: oklch(0.96 0.008 85);
--color-ttg36-platelo: #d9d4c8;
--color-ttg36-platelo: oklch(0.87 0.012 85);
--color-ttg36-well: #c7c1b3;
--color-ttg36-well: oklch(0.81 0.014 85);
--color-ttg36-paddlehi: #f8f5ee;
--color-ttg36-paddlehi: oklch(0.97 0.006 85);
--color-ttg36-paddlemid: #efece3;
--color-ttg36-paddlemid: oklch(0.94 0.008 85);
--color-ttg36-paddlelo: #cdc7b9;
--color-ttg36-paddlelo: oklch(0.83 0.013 85);
--color-ttg36-tag: #6e6858;
--color-ttg36-tag: oklch(0.5 0.015 85);
--color-ttg36-caption: #9ba1ae;
--color-ttg36-caption: oklch(0.7 0.014 265);
--color-ttg36-captionlit: #6b5f43;
--color-ttg36-captionlit: oklch(0.48 0.045 85);
--color-ttg36-focus: #5b8def;
--color-ttg36-focus: oklch(0.65 0.16 258);
--font-ttg36-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ttg-36 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-ttg36-dark: #1f232c;
--color-ttg36-dark: oklch(0.25 0.015 265);
--color-ttg36-dim: #4a4436;
--color-ttg36-dim: oklch(0.44 0.03 85);
--color-ttg36-bright: #efe1c2;
--color-ttg36-bright: oklch(0.92 0.05 88);
--color-ttg36-glow: #ffd07a;
--color-ttg36-glow: oklch(0.87 0.13 80 / 0.45);
--color-ttg36-wash: #ffe6b5;
--color-ttg36-wash: oklch(0.92 0.08 85 / 0.4);
--color-ttg36-platehi: #f5f2eb;
--color-ttg36-platehi: oklch(0.96 0.008 85);
--color-ttg36-platelo: #d9d4c8;
--color-ttg36-platelo: oklch(0.87 0.012 85);
--color-ttg36-well: #c7c1b3;
--color-ttg36-well: oklch(0.81 0.014 85);
--color-ttg36-paddlehi: #f8f5ee;
--color-ttg36-paddlehi: oklch(0.97 0.006 85);
--color-ttg36-paddlemid: #efece3;
--color-ttg36-paddlemid: oklch(0.94 0.008 85);
--color-ttg36-paddlelo: #cdc7b9;
--color-ttg36-paddlelo: oklch(0.83 0.013 85);
--color-ttg36-tag: #6e6858;
--color-ttg36-tag: oklch(0.5 0.015 85);
--color-ttg36-caption: #9ba1ae;
--color-ttg36-caption: oklch(0.7 0.014 265);
--color-ttg36-captionlit: #6b5f43;
--color-ttg36-captionlit: oklch(0.48 0.045 85);
--color-ttg36-focus: #5b8def;
--color-ttg36-focus: oklch(0.65 0.16 258);
--font-ttg36-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ttg-36 {
width: 100%;
min-height: 100svh;
}Setup — do this once per project
Skip this if your project already runs Tailwind v4.
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<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.
npm install tailwindcss @tailwindcss/vite
npm install tailwindcss @tailwindcss/vite// vite.config.js ("type": "module" in package.json)
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})// vite.config.js ("type": "module" in package.json)
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})Any v4 setup works — Vite, PostCSS or the CLI. Nothing in this demo is bundler-specific.
@import "tailwindcss";
@theme {
--color-ttg36-dark: #1f232c;
--color-ttg36-dark: oklch(0.25 0.015 265);
--color-ttg36-dim: #4a4436;
--color-ttg36-dim: oklch(0.44 0.03 85);
--color-ttg36-bright: #efe1c2;
--color-ttg36-bright: oklch(0.92 0.05 88);
--color-ttg36-glow: #ffd07a;
--color-ttg36-glow: oklch(0.87 0.13 80 / 0.45);
--color-ttg36-wash: #ffe6b5;
--color-ttg36-wash: oklch(0.92 0.08 85 / 0.4);
--color-ttg36-platehi: #f5f2eb;
--color-ttg36-platehi: oklch(0.96 0.008 85);
--color-ttg36-platelo: #d9d4c8;
--color-ttg36-platelo: oklch(0.87 0.012 85);
--color-ttg36-well: #c7c1b3;
--color-ttg36-well: oklch(0.81 0.014 85);
--color-ttg36-paddlehi: #f8f5ee;
--color-ttg36-paddlehi: oklch(0.97 0.006 85);
--color-ttg36-paddlemid: #efece3;
--color-ttg36-paddlemid: oklch(0.94 0.008 85);
--color-ttg36-paddlelo: #cdc7b9;
--color-ttg36-paddlelo: oklch(0.83 0.013 85);
--color-ttg36-tag: #6e6858;
--color-ttg36-tag: oklch(0.5 0.015 85);
--color-ttg36-caption: #9ba1ae;
--color-ttg36-caption: oklch(0.7 0.014 265);
--color-ttg36-captionlit: #6b5f43;
--color-ttg36-captionlit: oklch(0.48 0.045 85);
--color-ttg36-focus: #5b8def;
--color-ttg36-focus: oklch(0.65 0.16 258);
--font-ttg36-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ttg-36 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-ttg36-dark: #1f232c;
--color-ttg36-dark: oklch(0.25 0.015 265);
--color-ttg36-dim: #4a4436;
--color-ttg36-dim: oklch(0.44 0.03 85);
--color-ttg36-bright: #efe1c2;
--color-ttg36-bright: oklch(0.92 0.05 88);
--color-ttg36-glow: #ffd07a;
--color-ttg36-glow: oklch(0.87 0.13 80 / 0.45);
--color-ttg36-wash: #ffe6b5;
--color-ttg36-wash: oklch(0.92 0.08 85 / 0.4);
--color-ttg36-platehi: #f5f2eb;
--color-ttg36-platehi: oklch(0.96 0.008 85);
--color-ttg36-platelo: #d9d4c8;
--color-ttg36-platelo: oklch(0.87 0.012 85);
--color-ttg36-well: #c7c1b3;
--color-ttg36-well: oklch(0.81 0.014 85);
--color-ttg36-paddlehi: #f8f5ee;
--color-ttg36-paddlehi: oklch(0.97 0.006 85);
--color-ttg36-paddlemid: #efece3;
--color-ttg36-paddlemid: oklch(0.94 0.008 85);
--color-ttg36-paddlelo: #cdc7b9;
--color-ttg36-paddlelo: oklch(0.83 0.013 85);
--color-ttg36-tag: #6e6858;
--color-ttg36-tag: oklch(0.5 0.015 85);
--color-ttg36-caption: #9ba1ae;
--color-ttg36-caption: oklch(0.7 0.014 265);
--color-ttg36-captionlit: #6b5f43;
--color-ttg36-captionlit: oklch(0.48 0.045 85);
--color-ttg36-focus: #5b8def;
--color-ttg36-focus: oklch(0.65 0.16 258);
--font-ttg36-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ttg-36 {
width: 100%;
min-height: 100svh;
}<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&display=swap">
<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&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
- Stacked relational variants are a boolean AND:
has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:bg-ttg36-brightfires only when both gangs are on. There is no OR variant, so "either" is written as two separate rules — which is worth knowing before you try to express a third state. - The additive glow (a pool for either, a wash for both) is what makes this read as lighting rather than as theming; swapping one background for another would have been one rule and half the effect.
- Ids inside the relational selector are deliberate for a fixed plate. In a component, swap them for
has-[[data-gang=a]:checked]so the markup can be duplicated. - UI upgrade over demo 15: two gangs with a cumulative response instead of one binary room, printed gang tags so each switch says what it controls, and the dark state lifted to
oklch(0.25)withoklch(0.7)caption ink — 6.4:1 in the unlit room, where the original sat at 3.4:1.
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 Two-Gang Wall Plate with Cumulative Room Light
Source: https://codefronts.com/components/tailwind-css-toggles-switches/tailwind-two-gang-wall-plate-cumulative-room-light/
Two switches on one plate, and the room responds to BOTH: one on is a dim pool of light, two on floods the scene. Counting children in pure CSS is the trick — :has() can test combinations even though it cannot count.
## HTML
```html
<section class="ttg-36 relative overflow-hidden w-full min-h-svh flex flex-col items-center justify-center gap-8 px-5 py-14 bg-ttg36-dark font-ttg36-sans transition-colors duration-700 has-[#ttg-36-a:checked]:bg-ttg36-dim has-[#ttg-36-b:checked]:bg-ttg36-dim has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:bg-ttg36-bright has-[#ttg-36-a:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-b:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:[&_.ttg36-wash]:opacity-100 motion-reduce:transition-none" aria-label="Two gang wall plate">
<span aria-hidden="true" class="ttg36-pool pointer-events-none absolute top-[10%] left-1/2 -translate-x-1/2 w-80 h-80 rounded-full opacity-0 transition-opacity duration-700 bg-radial from-ttg36-glow to-transparent to-70% motion-reduce:transition-none"></span>
<span aria-hidden="true" class="ttg36-wash pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-700 bg-radial from-ttg36-wash to-transparent to-75% motion-reduce:transition-none"></span>
<div class="relative z-10 flex gap-5 px-7 py-8 rounded-2xl bg-linear-170 from-ttg36-platehi to-ttg36-platelo shadow-[inset_0_2px_0_oklch(1_0_0/0.85),inset_0_-3px_5px_oklch(0.4_0.03_80/0.3),0_20px_38px_-16px_oklch(0_0_0/0.6)]">
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-a" role="switch" aria-label="Ceiling light" class="peer sr-only">
<label for="ttg-36-a" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">CEILING</span>
</span>
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-b" role="switch" aria-label="Lamps" class="peer sr-only">
<label for="ttg-36-b" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">LAMPS</span>
</span>
</div>
<p class="relative z-10 text-[12px] tracking-[0.12em] uppercase text-ttg36-caption transition-colors duration-700 [.ttg-36:has(:checked)_&]:text-ttg36-captionlit motion-reduce:transition-none">One on dims the room · two floods it</p>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-ttg36-dark: #1f232c;
--color-ttg36-dark: oklch(0.25 0.015 265);
--color-ttg36-dim: #4a4436;
--color-ttg36-dim: oklch(0.44 0.03 85);
--color-ttg36-bright: #efe1c2;
--color-ttg36-bright: oklch(0.92 0.05 88);
--color-ttg36-glow: #ffd07a;
--color-ttg36-glow: oklch(0.87 0.13 80 / 0.45);
--color-ttg36-wash: #ffe6b5;
--color-ttg36-wash: oklch(0.92 0.08 85 / 0.4);
--color-ttg36-platehi: #f5f2eb;
--color-ttg36-platehi: oklch(0.96 0.008 85);
--color-ttg36-platelo: #d9d4c8;
--color-ttg36-platelo: oklch(0.87 0.012 85);
--color-ttg36-well: #c7c1b3;
--color-ttg36-well: oklch(0.81 0.014 85);
--color-ttg36-paddlehi: #f8f5ee;
--color-ttg36-paddlehi: oklch(0.97 0.006 85);
--color-ttg36-paddlemid: #efece3;
--color-ttg36-paddlemid: oklch(0.94 0.008 85);
--color-ttg36-paddlelo: #cdc7b9;
--color-ttg36-paddlelo: oklch(0.83 0.013 85);
--color-ttg36-tag: #6e6858;
--color-ttg36-tag: oklch(0.5 0.015 85);
--color-ttg36-caption: #9ba1ae;
--color-ttg36-caption: oklch(0.7 0.014 265);
--color-ttg36-captionlit: #6b5f43;
--color-ttg36-captionlit: oklch(0.48 0.045 85);
--color-ttg36-focus: #5b8def;
--color-ttg36-focus: oklch(0.65 0.16 258);
--font-ttg36-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ttg-36 {
width: 100%;
min-height: 100svh;
}
```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 Two-Gang Wall Plate with Cumulative Room Light
Source: https://codefronts.com/components/tailwind-css-toggles-switches/tailwind-two-gang-wall-plate-cumulative-room-light/
Two switches on one plate, and the room responds to BOTH: one on is a dim pool of light, two on floods the scene. Counting children in pure CSS is the trick — :has() can test combinations even though it cannot count.
## HTML
```html
<section class="ttg-36 relative overflow-hidden w-full min-h-svh flex flex-col items-center justify-center gap-8 px-5 py-14 bg-ttg36-dark font-ttg36-sans transition-colors duration-700 has-[#ttg-36-a:checked]:bg-ttg36-dim has-[#ttg-36-b:checked]:bg-ttg36-dim has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:bg-ttg36-bright has-[#ttg-36-a:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-b:checked]:[&_.ttg36-pool]:opacity-100 has-[#ttg-36-a:checked]:has-[#ttg-36-b:checked]:[&_.ttg36-wash]:opacity-100 motion-reduce:transition-none" aria-label="Two gang wall plate">
<span aria-hidden="true" class="ttg36-pool pointer-events-none absolute top-[10%] left-1/2 -translate-x-1/2 w-80 h-80 rounded-full opacity-0 transition-opacity duration-700 bg-radial from-ttg36-glow to-transparent to-70% motion-reduce:transition-none"></span>
<span aria-hidden="true" class="ttg36-wash pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-700 bg-radial from-ttg36-wash to-transparent to-75% motion-reduce:transition-none"></span>
<div class="relative z-10 flex gap-5 px-7 py-8 rounded-2xl bg-linear-170 from-ttg36-platehi to-ttg36-platelo shadow-[inset_0_2px_0_oklch(1_0_0/0.85),inset_0_-3px_5px_oklch(0.4_0.03_80/0.3),0_20px_38px_-16px_oklch(0_0_0/0.6)]">
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-a" role="switch" aria-label="Ceiling light" class="peer sr-only">
<label for="ttg-36-a" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">CEILING</span>
</span>
<span class="flex flex-col items-center gap-3">
<span class="relative block w-14 h-24 p-1 rounded-lg bg-ttg36-well shadow-[inset_0_3px_7px_oklch(0.4_0.03_80/0.5)] perspective-[320px]">
<input type="checkbox" id="ttg-36-b" role="switch" aria-label="Lamps" class="peer sr-only">
<label for="ttg-36-b" aria-hidden="true" class="block w-full h-full rounded-md cursor-pointer bg-linear-to-b from-ttg36-paddlelo via-ttg36-paddlehi via-55% to-ttg36-paddlemid shadow-[0_4px_8px_oklch(0.4_0.03_80/0.35),inset_0_1px_0_oklch(1_0_0/0.8)] origin-center rotate-x-[15deg] transition-transform duration-200 ease-[cubic-bezier(0.5,1.4,0.6,1)] peer-checked:-rotate-x-[15deg] peer-checked:bg-linear-to-t peer-focus-visible:outline-3 peer-focus-visible:outline-ttg36-focus peer-focus-visible:outline-offset-4 motion-reduce:transition-none"></label>
</span>
<span class="text-[10px] font-bold tracking-[0.2em] text-ttg36-tag">LAMPS</span>
</span>
</div>
<p class="relative z-10 text-[12px] tracking-[0.12em] uppercase text-ttg36-caption transition-colors duration-700 [.ttg-36:has(:checked)_&]:text-ttg36-captionlit motion-reduce:transition-none">One on dims the room · two floods it</p>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-ttg36-dark: #1f232c;
--color-ttg36-dark: oklch(0.25 0.015 265);
--color-ttg36-dim: #4a4436;
--color-ttg36-dim: oklch(0.44 0.03 85);
--color-ttg36-bright: #efe1c2;
--color-ttg36-bright: oklch(0.92 0.05 88);
--color-ttg36-glow: #ffd07a;
--color-ttg36-glow: oklch(0.87 0.13 80 / 0.45);
--color-ttg36-wash: #ffe6b5;
--color-ttg36-wash: oklch(0.92 0.08 85 / 0.4);
--color-ttg36-platehi: #f5f2eb;
--color-ttg36-platehi: oklch(0.96 0.008 85);
--color-ttg36-platelo: #d9d4c8;
--color-ttg36-platelo: oklch(0.87 0.012 85);
--color-ttg36-well: #c7c1b3;
--color-ttg36-well: oklch(0.81 0.014 85);
--color-ttg36-paddlehi: #f8f5ee;
--color-ttg36-paddlehi: oklch(0.97 0.006 85);
--color-ttg36-paddlemid: #efece3;
--color-ttg36-paddlemid: oklch(0.94 0.008 85);
--color-ttg36-paddlelo: #cdc7b9;
--color-ttg36-paddlelo: oklch(0.83 0.013 85);
--color-ttg36-tag: #6e6858;
--color-ttg36-tag: oklch(0.5 0.015 85);
--color-ttg36-caption: #9ba1ae;
--color-ttg36-caption: oklch(0.7 0.014 265);
--color-ttg36-captionlit: #6b5f43;
--color-ttg36-captionlit: oklch(0.48 0.045 85);
--color-ttg36-focus: #5b8def;
--color-ttg36-focus: oklch(0.65 0.16 258);
--font-ttg36-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.ttg-36 {
width: 100%;
min-height: 100svh;
}
```How this works
CSS cannot count, but it can combine. Stacking two has-[...] variants on one element is a logical AND, so three lighting states fall out of two switches: none, either (dim), both (bright). For two or three children this is cleaner than any script; past four it is combinatorial and you should reach for JavaScript.
The glow is additive, not swapped. A soft pool fades in with either switch; a second, larger wash only appears when both are on. Because they stack rather than replace, the room brightening reads as more light rather than different light.
Each gang is still an independent rocker with its own label, its own perspective tip and its own accessible name — the plate is layout, not a control.
Make it yours
- Three gangs: add a third switch and one more combination rule — but consider JavaScript at that point.
- Warm/cool: give each gang a different glow hue and let them mix in the overlap.
- Engraved labels: swap the printed tags for the inset text-shadow pair from demo 26.
- Dimmer track: add a range input under the plate and drive the glow's opacity from its value.
Gotchas — read before shipping
- Stacked
has-[...]variants are an AND, not an OR. There is noorvariant — "either on" needs two separate rules, which is exactly what the dim glow uses. - Id-based relational selectors (
has-[#ttg-36-a:checked]) are fine for a fixed plate but do not survive being turned into a component — use data attributes there. - Keep the two rockers visually identical; a gang that looks different implies it does something different.
- Full-viewport brightness changes must be disabled under
motion-reduce:.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
Entirely dependent on :has() (Firefox 121+); without it both rockers still work and the room stays at its resting light.