08 / 24
All 24 in 24 Tailwind CSS Radio Buttons
- 01Tailwind Radio Button Cards (Selectable Cards)
- 02Tailwind Pill Radio Toggle (Segmented Control)
- 03Tailwind Radio Button with Icon and Description
- 04Tailwind Dark Mode Glowing Radio Button
- 05Accessible Tailwind Radio Button (appearance-none)
- 06Tailwind Radio Group with Badges
- 07Tailwind Animated Radio Button (Concentric Ripple)
- 08Tailwind Sliding Pill Radio Switch
- 09Tailwind 3D Sphere Radio Buttons
- 10Tailwind Ink Splash Radio Animation
- 11Tailwind Star Rating Radio Buttons
- 12Tailwind 3D Tilt Card Radio Selector
- 13Minimal Checkmark Radio Button in Tailwind
- 14Tailwind Color Swatch Radio Picker
- 15Tailwind Segmented Control Bar (View Switcher)
- 16Tailwind Neon Cyberpunk Radio Buttons
- 17Tailwind Pricing Plan Radio Cards
- 18Tailwind Liquid Wave Fill Radio Button
- 19Tailwind Image Radio Button Selector (Arch Mask)
- 20Tailwind Animated Gradient Border Radio Cards
- 21Tailwind Avatar Radio Picker (Profile Selector)
- 22Tailwind Stacked Radio List (Payment Method)
- 23Tailwind 3D Push Button Radio (Tactile Keys)
- 24Tailwind Pulsing Glow Radio Button (Status Picker)
Tailwind Sliding Pill Radio Switch
A three-way pill where the thumb glides between options and changes colour as it lands — Pickup amber, Delivery green, Dine-in violet. Position and hue come from one custom property per state: has-[label:nth-child(2)_input:checked]:[--thumb:…] on the track, read by before:bg-(--thumb).
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="trb-08 w-full min-h-svh grid place-items-center bg-trb08-bg px-6 py-14 font-trb08-sans text-trb08-ink" aria-label="Sliding pill toggle switch demo">
<fieldset class="group/how grid justify-items-center gap-5">
<legend class="mb-1 text-center text-[26px] font-extrabold tracking-[-0.025em]">How do you want it?</legend>
<div class="relative isolate grid grid-cols-3 rounded-full bg-trb08-track p-[5px] shadow-[inset_0_1px_3px_oklch(0.3_0.04_70/0.14)] [--thumb:var(--color-trb08-amber)] before:absolute before:top-[5px] before:left-[5px] before:-z-10 before:h-[calc(100%-10px)] before:w-[calc(33.333%-3.33px)] before:rounded-full before:bg-(--thumb) before:shadow-trb08-thumb before:transition-[translate,background-color] before:duration-400 before:ease-trb08-glide before:content-[''] has-[label:nth-child(2)_input:checked]:[--thumb:var(--color-trb08-green)] has-[label:nth-child(2)_input:checked]:before:translate-x-full has-[label:nth-child(3)_input:checked]:[--thumb:var(--color-trb08-violet)] has-[label:nth-child(3)_input:checked]:before:translate-x-[200%] motion-reduce:before:transition-[background-color]">
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="pickup" class="sr-only" checked><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-trb08-ink">Pickup</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="delivery" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Delivery</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="dinein" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Dine-in</span></label>
</div>
<p class="text-center text-sm text-trb08-mut">
<span class="hidden group-has-[[value=pickup]:checked]/how:inline">Ready in <strong class="font-bold text-trb08-ink">15 min</strong> at 214 Bleecker St.</span>
<span class="hidden group-has-[[value=delivery]:checked]/how:inline">At your door in <strong class="font-bold text-trb08-ink">30–40 min</strong> · $3.99 fee</span>
<span class="hidden group-has-[[value=dinein]:checked]/how:inline">Table for two held until <strong class="font-bold text-trb08-ink">7:30 pm</strong></span>
</p>
</fieldset>
</section><section class="trb-08 w-full min-h-svh grid place-items-center bg-trb08-bg px-6 py-14 font-trb08-sans text-trb08-ink" aria-label="Sliding pill toggle switch demo">
<fieldset class="group/how grid justify-items-center gap-5">
<legend class="mb-1 text-center text-[26px] font-extrabold tracking-[-0.025em]">How do you want it?</legend>
<div class="relative isolate grid grid-cols-3 rounded-full bg-trb08-track p-[5px] shadow-[inset_0_1px_3px_oklch(0.3_0.04_70/0.14)] [--thumb:var(--color-trb08-amber)] before:absolute before:top-[5px] before:left-[5px] before:-z-10 before:h-[calc(100%-10px)] before:w-[calc(33.333%-3.33px)] before:rounded-full before:bg-(--thumb) before:shadow-trb08-thumb before:transition-[translate,background-color] before:duration-400 before:ease-trb08-glide before:content-[''] has-[label:nth-child(2)_input:checked]:[--thumb:var(--color-trb08-green)] has-[label:nth-child(2)_input:checked]:before:translate-x-full has-[label:nth-child(3)_input:checked]:[--thumb:var(--color-trb08-violet)] has-[label:nth-child(3)_input:checked]:before:translate-x-[200%] motion-reduce:before:transition-[background-color]">
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="pickup" class="sr-only" checked><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-trb08-ink">Pickup</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="delivery" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Delivery</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="dinein" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Dine-in</span></label>
</div>
<p class="text-center text-sm text-trb08-mut">
<span class="hidden group-has-[[value=pickup]:checked]/how:inline">Ready in <strong class="font-bold text-trb08-ink">15 min</strong> at 214 Bleecker St.</span>
<span class="hidden group-has-[[value=delivery]:checked]/how:inline">At your door in <strong class="font-bold text-trb08-ink">30–40 min</strong> · $3.99 fee</span>
<span class="hidden group-has-[[value=dinein]:checked]/how:inline">Table for two held until <strong class="font-bold text-trb08-ink">7:30 pm</strong></span>
</p>
</fieldset>
</section>@import "tailwindcss";
@theme {
--color-trb08-bg: #faf7f2;
--color-trb08-bg: oklch(0.978 0.008 80);
--color-trb08-track: #efe9df;
--color-trb08-track: oklch(0.935 0.015 80);
--color-trb08-ink: #221d16;
--color-trb08-ink: oklch(0.23 0.015 70);
--color-trb08-mut: #6b6252;
--color-trb08-mut: oklch(0.5 0.025 80);
--color-trb08-amber: #f0b43c;
--color-trb08-amber: oklch(0.8 0.15 78);
--color-trb08-green: #17864f;
--color-trb08-green: oklch(0.55 0.14 155);
--color-trb08-violet: #7a3fc8;
--color-trb08-violet: oklch(0.5 0.2 300);
--shadow-trb08-thumb: 0 3px 10px oklch(0.3 0.05 70 / 0.22);
--ease-trb08-glide: cubic-bezier(0.22, 1, 0.36, 1);
--font-trb08-sans: 'Bricolage Grotesque', system-ui, sans-serif;
}
/* 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. */
.trb-08 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-trb08-bg: #faf7f2;
--color-trb08-bg: oklch(0.978 0.008 80);
--color-trb08-track: #efe9df;
--color-trb08-track: oklch(0.935 0.015 80);
--color-trb08-ink: #221d16;
--color-trb08-ink: oklch(0.23 0.015 70);
--color-trb08-mut: #6b6252;
--color-trb08-mut: oklch(0.5 0.025 80);
--color-trb08-amber: #f0b43c;
--color-trb08-amber: oklch(0.8 0.15 78);
--color-trb08-green: #17864f;
--color-trb08-green: oklch(0.55 0.14 155);
--color-trb08-violet: #7a3fc8;
--color-trb08-violet: oklch(0.5 0.2 300);
--shadow-trb08-thumb: 0 3px 10px oklch(0.3 0.05 70 / 0.22);
--ease-trb08-glide: cubic-bezier(0.22, 1, 0.36, 1);
--font-trb08-sans: 'Bricolage Grotesque', system-ui, sans-serif;
}
/* 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. */
.trb-08 {
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-trb08-bg: #faf7f2;
--color-trb08-bg: oklch(0.978 0.008 80);
--color-trb08-track: #efe9df;
--color-trb08-track: oklch(0.935 0.015 80);
--color-trb08-ink: #221d16;
--color-trb08-ink: oklch(0.23 0.015 70);
--color-trb08-mut: #6b6252;
--color-trb08-mut: oklch(0.5 0.025 80);
--color-trb08-amber: #f0b43c;
--color-trb08-amber: oklch(0.8 0.15 78);
--color-trb08-green: #17864f;
--color-trb08-green: oklch(0.55 0.14 155);
--color-trb08-violet: #7a3fc8;
--color-trb08-violet: oklch(0.5 0.2 300);
--shadow-trb08-thumb: 0 3px 10px oklch(0.3 0.05 70 / 0.22);
--ease-trb08-glide: cubic-bezier(0.22, 1, 0.36, 1);
--font-trb08-sans: 'Bricolage Grotesque', system-ui, sans-serif;
}
/* 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. */
.trb-08 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-trb08-bg: #faf7f2;
--color-trb08-bg: oklch(0.978 0.008 80);
--color-trb08-track: #efe9df;
--color-trb08-track: oklch(0.935 0.015 80);
--color-trb08-ink: #221d16;
--color-trb08-ink: oklch(0.23 0.015 70);
--color-trb08-mut: #6b6252;
--color-trb08-mut: oklch(0.5 0.025 80);
--color-trb08-amber: #f0b43c;
--color-trb08-amber: oklch(0.8 0.15 78);
--color-trb08-green: #17864f;
--color-trb08-green: oklch(0.55 0.14 155);
--color-trb08-violet: #7a3fc8;
--color-trb08-violet: oklch(0.5 0.2 300);
--shadow-trb08-thumb: 0 3px 10px oklch(0.3 0.05 70 / 0.22);
--ease-trb08-glide: cubic-bezier(0.22, 1, 0.36, 1);
--font-trb08-sans: 'Bricolage Grotesque', system-ui, sans-serif;
}
/* 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. */
.trb-08 {
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=Bricolage+Grotesque:opsz,wght@12..96,400..800&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=Bricolage+Grotesque:opsz,wght@12..96,400..800&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
- The four
:has(nth-child)rules became four arbitrary variants on the track — two writetranslate, two write--thumb. background:var(--thumb)became v4's parenthesis shorthandbefore:bg-(--thumb).- UI upgrade from the CSS original: Pickup now inks dark on the amber thumb — white on amber was 2.1:1, now 11:1 — and the green/violet stops were deepened so white text clears 4.5:1.
- UI upgrade: a live caption answers what each mode means (ready time, fee, table hold), switched by
group-has-[[value=…]:checked]/how:, and segments hold 48px.
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 Sliding Pill Radio Switch
Source: https://codefronts.com/components/tailwind-css-radio-buttons/tailwind-sliding-pill-radio-switch/
A three-way pill where the thumb glides between options and changes colour as it lands — Pickup amber, Delivery green, Dine-in violet. Position and hue come from one custom property per state: has-[label:nth-child(2)_input:checked]:[--thumb:…] on the track, read by before:bg-(--thumb).
## HTML
```html
<section class="trb-08 w-full min-h-svh grid place-items-center bg-trb08-bg px-6 py-14 font-trb08-sans text-trb08-ink" aria-label="Sliding pill toggle switch demo">
<fieldset class="group/how grid justify-items-center gap-5">
<legend class="mb-1 text-center text-[26px] font-extrabold tracking-[-0.025em]">How do you want it?</legend>
<div class="relative isolate grid grid-cols-3 rounded-full bg-trb08-track p-[5px] shadow-[inset_0_1px_3px_oklch(0.3_0.04_70/0.14)] [--thumb:var(--color-trb08-amber)] before:absolute before:top-[5px] before:left-[5px] before:-z-10 before:h-[calc(100%-10px)] before:w-[calc(33.333%-3.33px)] before:rounded-full before:bg-(--thumb) before:shadow-trb08-thumb before:transition-[translate,background-color] before:duration-400 before:ease-trb08-glide before:content-[''] has-[label:nth-child(2)_input:checked]:[--thumb:var(--color-trb08-green)] has-[label:nth-child(2)_input:checked]:before:translate-x-full has-[label:nth-child(3)_input:checked]:[--thumb:var(--color-trb08-violet)] has-[label:nth-child(3)_input:checked]:before:translate-x-[200%] motion-reduce:before:transition-[background-color]">
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="pickup" class="sr-only" checked><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-trb08-ink">Pickup</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="delivery" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Delivery</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="dinein" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Dine-in</span></label>
</div>
<p class="text-center text-sm text-trb08-mut">
<span class="hidden group-has-[[value=pickup]:checked]/how:inline">Ready in <strong class="font-bold text-trb08-ink">15 min</strong> at 214 Bleecker St.</span>
<span class="hidden group-has-[[value=delivery]:checked]/how:inline">At your door in <strong class="font-bold text-trb08-ink">30–40 min</strong> · $3.99 fee</span>
<span class="hidden group-has-[[value=dinein]:checked]/how:inline">Table for two held until <strong class="font-bold text-trb08-ink">7:30 pm</strong></span>
</p>
</fieldset>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-trb08-bg: #faf7f2;
--color-trb08-bg: oklch(0.978 0.008 80);
--color-trb08-track: #efe9df;
--color-trb08-track: oklch(0.935 0.015 80);
--color-trb08-ink: #221d16;
--color-trb08-ink: oklch(0.23 0.015 70);
--color-trb08-mut: #6b6252;
--color-trb08-mut: oklch(0.5 0.025 80);
--color-trb08-amber: #f0b43c;
--color-trb08-amber: oklch(0.8 0.15 78);
--color-trb08-green: #17864f;
--color-trb08-green: oklch(0.55 0.14 155);
--color-trb08-violet: #7a3fc8;
--color-trb08-violet: oklch(0.5 0.2 300);
--shadow-trb08-thumb: 0 3px 10px oklch(0.3 0.05 70 / 0.22);
--ease-trb08-glide: cubic-bezier(0.22, 1, 0.36, 1);
--font-trb08-sans: 'Bricolage Grotesque', system-ui, sans-serif;
}
/* 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. */
.trb-08 {
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 Sliding Pill Radio Switch
Source: https://codefronts.com/components/tailwind-css-radio-buttons/tailwind-sliding-pill-radio-switch/
A three-way pill where the thumb glides between options and changes colour as it lands — Pickup amber, Delivery green, Dine-in violet. Position and hue come from one custom property per state: has-[label:nth-child(2)_input:checked]:[--thumb:…] on the track, read by before:bg-(--thumb).
## HTML
```html
<section class="trb-08 w-full min-h-svh grid place-items-center bg-trb08-bg px-6 py-14 font-trb08-sans text-trb08-ink" aria-label="Sliding pill toggle switch demo">
<fieldset class="group/how grid justify-items-center gap-5">
<legend class="mb-1 text-center text-[26px] font-extrabold tracking-[-0.025em]">How do you want it?</legend>
<div class="relative isolate grid grid-cols-3 rounded-full bg-trb08-track p-[5px] shadow-[inset_0_1px_3px_oklch(0.3_0.04_70/0.14)] [--thumb:var(--color-trb08-amber)] before:absolute before:top-[5px] before:left-[5px] before:-z-10 before:h-[calc(100%-10px)] before:w-[calc(33.333%-3.33px)] before:rounded-full before:bg-(--thumb) before:shadow-trb08-thumb before:transition-[translate,background-color] before:duration-400 before:ease-trb08-glide before:content-[''] has-[label:nth-child(2)_input:checked]:[--thumb:var(--color-trb08-green)] has-[label:nth-child(2)_input:checked]:before:translate-x-full has-[label:nth-child(3)_input:checked]:[--thumb:var(--color-trb08-violet)] has-[label:nth-child(3)_input:checked]:before:translate-x-[200%] motion-reduce:before:transition-[background-color]">
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="pickup" class="sr-only" checked><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-trb08-ink">Pickup</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="delivery" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Delivery</span></label>
<label class="group relative grid min-h-12 min-w-[6.5rem] cursor-pointer place-items-center rounded-full px-4 has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-trb08-ink sm:min-w-[7.5rem]"><input type="radio" name="trb-08" value="dinein" class="sr-only"><span class="text-[15px] font-bold text-trb08-mut transition-colors duration-300 group-has-checked:text-white">Dine-in</span></label>
</div>
<p class="text-center text-sm text-trb08-mut">
<span class="hidden group-has-[[value=pickup]:checked]/how:inline">Ready in <strong class="font-bold text-trb08-ink">15 min</strong> at 214 Bleecker St.</span>
<span class="hidden group-has-[[value=delivery]:checked]/how:inline">At your door in <strong class="font-bold text-trb08-ink">30–40 min</strong> · $3.99 fee</span>
<span class="hidden group-has-[[value=dinein]:checked]/how:inline">Table for two held until <strong class="font-bold text-trb08-ink">7:30 pm</strong></span>
</p>
</fieldset>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-trb08-bg: #faf7f2;
--color-trb08-bg: oklch(0.978 0.008 80);
--color-trb08-track: #efe9df;
--color-trb08-track: oklch(0.935 0.015 80);
--color-trb08-ink: #221d16;
--color-trb08-ink: oklch(0.23 0.015 70);
--color-trb08-mut: #6b6252;
--color-trb08-mut: oklch(0.5 0.025 80);
--color-trb08-amber: #f0b43c;
--color-trb08-amber: oklch(0.8 0.15 78);
--color-trb08-green: #17864f;
--color-trb08-green: oklch(0.55 0.14 155);
--color-trb08-violet: #7a3fc8;
--color-trb08-violet: oklch(0.5 0.2 300);
--shadow-trb08-thumb: 0 3px 10px oklch(0.3 0.05 70 / 0.22);
--ease-trb08-glide: cubic-bezier(0.22, 1, 0.36, 1);
--font-trb08-sans: 'Bricolage Grotesque', system-ui, sans-serif;
}
/* 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. */
.trb-08 {
width: 100%;
min-height: 100svh;
}
```How this works
State writes a variable, paint reads it. The track holds two arbitrary-variant classes per position — one for translate, one for --thumb. The thumb pseudo-element never changes class; it just reads --thumb.
Contrast per stop. White text passes on green and violet but fails on amber (2.1:1), so the first segment inks dark when checked. One variant, per label, where the colour is known.
Make it yours
- Per-stop colours: edit the three
--color-trb08-*tokens. - Four stops: thumb
w-[calc(25%-2.5px)]plus a fourth translate/colour pair. - Caption copy lives in three spans below the track.
Gotchas — read before shipping
- All translate rules must share the same transition, or the thumb teleports between states.
- Test label contrast against every thumb colour, not just the default.
translate-x-fullis relative to the thumb's own width, so its width must equal one segment exactly.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
Without :has() options still select; the pill loses its slide.