07 / 29
All 29 in 29 Tailwind CSS Checkboxes
- 01Tailwind CSS Toggle Switch — iOS-Style SaaS Settings
- 02Tailwind Filter Chip Checkbox — Style Checkbox as Button
- 03Tailwind Pricing Plan Card Select — Checkbox-Style Selectable Cards
- 04Pure Tailwind CSS Accordion with Checkbox — No JavaScript
- 05Tailwind Indeterminate Checkbox — Select All with Tri-State
- 06Accessible Custom Checkbox in Tailwind CSS — WCAG Focus Ring
- 07Tailwind Slide Toggle with ON/OFF Labels — GPU translate3d
- 08Neon Glow Checkbox in Tailwind CSS — Dark Mode Gaming UI
- 09Animated SVG Checkmark in Tailwind CSS — stroke-dashoffset Draw
- 10Bouncy Checkbox Animation in Tailwind CSS — Spring cubic-bezier
- 11Glassmorphism Checkbox in Tailwind CSS — backdrop-blur Frosted Glass
- 12Neumorphism Checkbox in Tailwind CSS — Soft UI
- 13Liquid Fill Checkbox Animation in Tailwind CSS — Water Wave
- 14Rotating Ring Checkbox in Tailwind CSS — Spin-to-Check
- 15Brutalist Checkbox in Tailwind CSS — Neo-Brutalism Hard Shadow
- 16Animated Gradient Checkbox in Tailwind CSS — Rainbow Sweep
- 173D Flip Checkbox in Tailwind CSS — perspective & backface-hidden
- 18Material Ripple Checkbox in Tailwind CSS — State Layer & Wave
- 19Retro Pixel Art Checkbox in Tailwind CSS — 8-Bit Arcade Menu
- 20Tailwind CSS To-Do List Checkbox with Animated Strikethrough
- 21Gooey Blob Checkbox in Tailwind CSS — blur + contrast Filter
- 22Tailwind Dark Mode Toggle Switch — Sun & Moon, No JavaScript
- 23Pulse Ring Checkbox in Tailwind CSS — Live Status Indicator
- 24Tailwind CSS Dash-to-Check SVG Morph Checkbox
- 25Tri-State Checkbox in Tailwind CSS + JavaScript — Done / N/A / Unset
- 26Magnetic Hover Checkbox in Tailwind CSS + JavaScript
- 27Confetti Checkbox Animation in Tailwind CSS — Pure CSS Particle Burst
- 28Slide-In Label Checkbox in Tailwind CSS — Saved Tag Reveal
- 29Aurora Gradient Toggle Switch in Tailwind CSS — Premium Dark UI
Tailwind Slide Toggle with ON/OFF Labels — GPU translate3d
A wider switch that prints ON and OFF inside its own track via before:content-['ON'] / after:content-['OFF'], cross-fading on group-has-checked:. The thumb glides on transform-gpu with will-change-transform, and each row card picks up an accent edge when on.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="tcb-07 w-full min-h-svh grid place-items-center bg-tcb07-bg px-5 py-14 font-tcb07-sans text-tcb07-ink selection:bg-tcb07-acc selection:text-white" aria-label="Smooth slide toggles">
<div class="flex w-full max-w-[25rem] flex-col gap-3.5">
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Auto-save drafts</span>
<input type="checkbox" class="peer sr-only" checked>
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Compact density</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Beta features</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
</div>
</section><section class="tcb-07 w-full min-h-svh grid place-items-center bg-tcb07-bg px-5 py-14 font-tcb07-sans text-tcb07-ink selection:bg-tcb07-acc selection:text-white" aria-label="Smooth slide toggles">
<div class="flex w-full max-w-[25rem] flex-col gap-3.5">
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Auto-save drafts</span>
<input type="checkbox" class="peer sr-only" checked>
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Compact density</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Beta features</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
</div>
</section>@import "tailwindcss";
@theme {
--color-tcb07-bg: #eef2f3;
--color-tcb07-bg: oklch(0.957 0.005 210);
--color-tcb07-ink: #28323a;
--color-tcb07-ink: oklch(0.3 0.02 230);
--color-tcb07-line: #dde3e5;
--color-tcb07-line: oklch(0.9 0.008 210);
--color-tcb07-off: #cdd5d8;
--color-tcb07-off: oklch(0.86 0.01 210);
--color-tcb07-offink: #3f4c52;
--color-tcb07-offink: oklch(0.41 0.02 220);
--color-tcb07-acc: #137f8f;
--color-tcb07-acc: oklch(0.54 0.1 205);
--font-tcb07-sans: 'Space Grotesk', system-ui, sans-serif;
--font-tcb07-mono: 'JetBrains Mono', ui-monospace, monospace;
--shadow-tcb07-thumb: 0 2px 6px rgb(20 30 40 / 0.4);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-07 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb07-bg: #eef2f3;
--color-tcb07-bg: oklch(0.957 0.005 210);
--color-tcb07-ink: #28323a;
--color-tcb07-ink: oklch(0.3 0.02 230);
--color-tcb07-line: #dde3e5;
--color-tcb07-line: oklch(0.9 0.008 210);
--color-tcb07-off: #cdd5d8;
--color-tcb07-off: oklch(0.86 0.01 210);
--color-tcb07-offink: #3f4c52;
--color-tcb07-offink: oklch(0.41 0.02 220);
--color-tcb07-acc: #137f8f;
--color-tcb07-acc: oklch(0.54 0.1 205);
--font-tcb07-sans: 'Space Grotesk', system-ui, sans-serif;
--font-tcb07-mono: 'JetBrains Mono', ui-monospace, monospace;
--shadow-tcb07-thumb: 0 2px 6px rgb(20 30 40 / 0.4);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-07 {
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-tcb07-bg: #eef2f3;
--color-tcb07-bg: oklch(0.957 0.005 210);
--color-tcb07-ink: #28323a;
--color-tcb07-ink: oklch(0.3 0.02 230);
--color-tcb07-line: #dde3e5;
--color-tcb07-line: oklch(0.9 0.008 210);
--color-tcb07-off: #cdd5d8;
--color-tcb07-off: oklch(0.86 0.01 210);
--color-tcb07-offink: #3f4c52;
--color-tcb07-offink: oklch(0.41 0.02 220);
--color-tcb07-acc: #137f8f;
--color-tcb07-acc: oklch(0.54 0.1 205);
--font-tcb07-sans: 'Space Grotesk', system-ui, sans-serif;
--font-tcb07-mono: 'JetBrains Mono', ui-monospace, monospace;
--shadow-tcb07-thumb: 0 2px 6px rgb(20 30 40 / 0.4);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-07 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb07-bg: #eef2f3;
--color-tcb07-bg: oklch(0.957 0.005 210);
--color-tcb07-ink: #28323a;
--color-tcb07-ink: oklch(0.3 0.02 230);
--color-tcb07-line: #dde3e5;
--color-tcb07-line: oklch(0.9 0.008 210);
--color-tcb07-off: #cdd5d8;
--color-tcb07-off: oklch(0.86 0.01 210);
--color-tcb07-offink: #3f4c52;
--color-tcb07-offink: oklch(0.41 0.02 220);
--color-tcb07-acc: #137f8f;
--color-tcb07-acc: oklch(0.54 0.1 205);
--font-tcb07-sans: 'Space Grotesk', system-ui, sans-serif;
--font-tcb07-mono: 'JetBrains Mono', ui-monospace, monospace;
--shadow-tcb07-thumb: 0 2px 6px rgb(20 30 40 / 0.4);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-07 {
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=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono: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=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
.track::before{content:attr(data-on)}becamebefore:content-['ON']— thedata-on/data-offattributes are no longer needed.translate3d(calc(var(--w) - var(--h)),0,0)becametransform-gpu group-has-checked:translate-x-9.- UI upgrade from the CSS original: the row card now carries state (accent-tinted border when on) and rows are 60px tall.
- UI upgrade: the OFF label went from
#5b6a70on#c3ccd0(3.2:1) to 4.8:1, and the ON label from white-on-oklch(0.58)(3.9:1) to 4.9:1 on the darker accent.
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 Slide Toggle with ON/OFF Labels — GPU translate3d
Source: https://codefronts.com/components/tailwind-css-checkboxes/tailwind-slide-toggle-on-off-labels/
A wider switch that prints ON and OFF inside its own track via before:content-['ON'] / after:content-['OFF'], cross-fading on group-has-checked:. The thumb glides on transform-gpu with will-change-transform, and each row card picks up an accent edge when on.
## HTML
```html
<section class="tcb-07 w-full min-h-svh grid place-items-center bg-tcb07-bg px-5 py-14 font-tcb07-sans text-tcb07-ink selection:bg-tcb07-acc selection:text-white" aria-label="Smooth slide toggles">
<div class="flex w-full max-w-[25rem] flex-col gap-3.5">
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Auto-save drafts</span>
<input type="checkbox" class="peer sr-only" checked>
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Compact density</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Beta features</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb07-bg: #eef2f3;
--color-tcb07-bg: oklch(0.957 0.005 210);
--color-tcb07-ink: #28323a;
--color-tcb07-ink: oklch(0.3 0.02 230);
--color-tcb07-line: #dde3e5;
--color-tcb07-line: oklch(0.9 0.008 210);
--color-tcb07-off: #cdd5d8;
--color-tcb07-off: oklch(0.86 0.01 210);
--color-tcb07-offink: #3f4c52;
--color-tcb07-offink: oklch(0.41 0.02 220);
--color-tcb07-acc: #137f8f;
--color-tcb07-acc: oklch(0.54 0.1 205);
--font-tcb07-sans: 'Space Grotesk', system-ui, sans-serif;
--font-tcb07-mono: 'JetBrains Mono', ui-monospace, monospace;
--shadow-tcb07-thumb: 0 2px 6px rgb(20 30 40 / 0.4);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-07 {
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 Slide Toggle with ON/OFF Labels — GPU translate3d
Source: https://codefronts.com/components/tailwind-css-checkboxes/tailwind-slide-toggle-on-off-labels/
A wider switch that prints ON and OFF inside its own track via before:content-['ON'] / after:content-['OFF'], cross-fading on group-has-checked:. The thumb glides on transform-gpu with will-change-transform, and each row card picks up an accent edge when on.
## HTML
```html
<section class="tcb-07 w-full min-h-svh grid place-items-center bg-tcb07-bg px-5 py-14 font-tcb07-sans text-tcb07-ink selection:bg-tcb07-acc selection:text-white" aria-label="Smooth slide toggles">
<div class="flex w-full max-w-[25rem] flex-col gap-3.5">
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Auto-save drafts</span>
<input type="checkbox" class="peer sr-only" checked>
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Compact density</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
<label class="group flex min-h-15 cursor-pointer items-center justify-between gap-4 rounded-xl border border-tcb07-line bg-white px-4.5 py-3.5 transition-colors duration-300 has-checked:border-tcb07-acc/40"><span class="text-[15px] font-semibold">Beta features</span>
<input type="checkbox" class="peer sr-only">
<span aria-hidden="true" class="relative h-[30px] w-[66px] flex-none overflow-hidden rounded-full bg-tcb07-off font-tcb07-mono text-[10px] font-bold tracking-[0.1em] transition-colors duration-300 peer-checked:bg-tcb07-acc peer-focus-visible:outline-3 peer-focus-visible:outline-offset-3 peer-focus-visible:outline-tcb07-acc before:absolute before:left-[11px] before:top-0 before:flex before:h-full before:items-center before:text-white before:opacity-0 before:transition-opacity before:content-['ON'] after:absolute after:right-[10px] after:top-0 after:flex after:h-full after:items-center after:text-tcb07-offink after:transition-opacity after:content-['OFF'] group-has-checked:before:opacity-100 group-has-checked:after:opacity-0 motion-reduce:transition-none">
<span class="absolute left-[3px] top-[3px] size-6 transform-gpu rounded-full bg-white shadow-tcb07-thumb transition-transform duration-300 ease-[cubic-bezier(.4,.9,.3,1)] will-change-transform group-has-checked:translate-x-9 motion-reduce:transition-none"></span>
</span>
</label>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb07-bg: #eef2f3;
--color-tcb07-bg: oklch(0.957 0.005 210);
--color-tcb07-ink: #28323a;
--color-tcb07-ink: oklch(0.3 0.02 230);
--color-tcb07-line: #dde3e5;
--color-tcb07-line: oklch(0.9 0.008 210);
--color-tcb07-off: #cdd5d8;
--color-tcb07-off: oklch(0.86 0.01 210);
--color-tcb07-offink: #3f4c52;
--color-tcb07-offink: oklch(0.41 0.02 220);
--color-tcb07-acc: #137f8f;
--color-tcb07-acc: oklch(0.54 0.1 205);
--font-tcb07-sans: 'Space Grotesk', system-ui, sans-serif;
--font-tcb07-mono: 'JetBrains Mono', ui-monospace, monospace;
--shadow-tcb07-thumb: 0 2px 6px rgb(20 30 40 / 0.4);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-07 {
width: 100%;
min-height: 100svh;
}
```How this works
The text is decoration. Generated content isn't reliably announced, which is what we want: the checkbox already reports its state, so ON/OFF is visual reinforcement only.
GPU hint. transform-gpu forces a 3D translate, promoting the thumb to its own layer — the Tailwind equivalent of the original's translate3d(…,0,0).
Travel. 66px track − 24px thumb − 2×3px inset = 36px = translate-x-9.
Make it yours
- I/O glyphs:
before:content-['I'] after:content-['O']for a hardware look. - Localise: swap the arbitrary content strings (keep them short — the track is 66px).
- Accent:
--color-tcb07-accdrives the track, ring and row edge. - Remove the row card for inline use: keep only the label's flex utilities.
Gotchas — read before shipping
- Spaces inside
content-['…']must be written as underscores:content-['ON_AIR']. - Don't rely on the ON/OFF text for meaning — colour-blind users still need the thumb position.
will-changecosts memory; keep it on small elements only.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
Generated content and 3D transforms are universal.