29 / 32
All 32 in 32 Tailwind CSS Tabs
- 01Tailwind CSS Tabs with Sliding Underline Indicator
- 02Neon Glow Tailwind Tabs with Per-Tab Accent Colors
- 03Neo-Brutalist Tailwind Tabs with Press Effect
- 04Color-Coded Tailwind CSS Tabs Component
- 05VS Code Style File Tabs in Tailwind CSS
- 06iOS Segmented Control in Tailwind CSS
- 07Bento Grid Card Tabs in Tailwind CSS
- 08Vertical Tabs with Timeline Progress in Tailwind CSS
- 09Terminal Window Tabs in Tailwind CSS (Retro CRT)
- 10Expanding Icon Tabs in Tailwind CSS
- 11Typewriter Animation Tabs in Tailwind CSS
- 12Tailwind Tabs with Particle Burst Animation
- 13Animated Counter Tabs in Tailwind CSS (Type Specimen)
- 14Oversized Cropped Text Tabs in Tailwind CSS
- 15Tailwind Sidebar Navigation with Sliding Indicator
- 16Tailwind Bottom Navigation Bar with Expanding Labels
- 17Variable Font Weight Tabs in Tailwind CSS
- 18Uppercase Tabs with Thick Sliding Bar in Tailwind CSS
- 19Drop Cap Initial Letter Tabs in Tailwind CSS
- 20Industrial Stencil Tabs in Tailwind CSS
- 21Bracket Selection Tabs in Tailwind CSS
- 22Bauhaus Color Block Tabs in Tailwind CSS
- 23Inverted Rubber Stamp Tabs in Tailwind CSS
- 24Outlined Tabs with Corner Markers in Tailwind CSS
- 25Tailwind Pill Tab Bar with Icons
- 26Risograph Print Effect Tabs in Tailwind CSS
- 27Animated SVG Underline Tabs in Tailwind CSS
- 28Font Specimen Glyph Tabs in Tailwind CSS
- 29Sliding Pill Tabs with Icons in Tailwind CSS
- 30Folded Corner Tabs in Tailwind CSS (clip-path)
- 31Bookmark Ribbon Navigation in Tailwind CSS
- 32Neumorphic Inset Tabs in Tailwind CSS
Sliding Pill Tabs with Icons in Tailwind CSS
Grid / List / Cards: a solid indigo pill glides under icon-and-label tabs on cream stock, and the label inverts as the pill arrives. The original measured the pill in JavaScript; the port slides it with the index trick and turns each panel into a live layout preview of the view you chose.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="ttb-29 group/tabs grid min-h-svh w-full place-items-center bg-ttb29-bg px-5 py-14 font-ttb29-sans text-ttb29-indigo" aria-label="Sliding pill tabs with icons demo">
<div class="grid w-full max-w-md justify-items-center gap-7">
<div class="w-full">
<div role="radiogroup" aria-label="View" class="relative flex rounded-full bg-ttb29-indigo/7 p-1.5 [--i:0] has-[#ttb29-r2:checked]:[--i:1] has-[#ttb29-r3:checked]:[--i:2]">
<span aria-hidden="true" class="pointer-events-none absolute inset-y-1.5 left-1.5 w-[calc((100%-12px)/3)] translate-x-[calc(var(--i)*100%)] rounded-full bg-ttb29-indigo shadow-[0_6px_16px_-6px_color-mix(in_oklab,var(--color-ttb29-indigo)_60%,transparent)] transition-transform duration-500 ease-[cubic-bezier(0.65,0,0.35,1)] motion-reduce:transition-none"></span>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r1" checked><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>Grid</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r2"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M9 6h12M9 12h12M9 18h12"/><circle cx="4" cy="6" r="1"/><circle cx="4" cy="12" r="1"/><circle cx="4" cy="18" r="1"/></svg>List</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r3"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/></svg>Cards</label>
</div>
<div aria-hidden="true" class="mt-4 rounded-2xl bg-white p-4 ring-1 ring-ttb29-indigo/8">
<div class="hidden grid-cols-3 gap-2 group-has-[#ttb29-r1:checked]/tabs:grid"><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r2:checked]/tabs:flex"><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/3 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-1/2 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-3/4 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/5 rounded-full bg-ttb29-indigo/10"></b></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r3:checked]/tabs:flex"><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i></div>
</div>
</div>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-ttb29-mono text-[11.5px] text-ttb29-mut">CSS pill · label delay-75 · live layout preview</p>
</div>
</section><section class="ttb-29 group/tabs grid min-h-svh w-full place-items-center bg-ttb29-bg px-5 py-14 font-ttb29-sans text-ttb29-indigo" aria-label="Sliding pill tabs with icons demo">
<div class="grid w-full max-w-md justify-items-center gap-7">
<div class="w-full">
<div role="radiogroup" aria-label="View" class="relative flex rounded-full bg-ttb29-indigo/7 p-1.5 [--i:0] has-[#ttb29-r2:checked]:[--i:1] has-[#ttb29-r3:checked]:[--i:2]">
<span aria-hidden="true" class="pointer-events-none absolute inset-y-1.5 left-1.5 w-[calc((100%-12px)/3)] translate-x-[calc(var(--i)*100%)] rounded-full bg-ttb29-indigo shadow-[0_6px_16px_-6px_color-mix(in_oklab,var(--color-ttb29-indigo)_60%,transparent)] transition-transform duration-500 ease-[cubic-bezier(0.65,0,0.35,1)] motion-reduce:transition-none"></span>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r1" checked><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>Grid</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r2"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M9 6h12M9 12h12M9 18h12"/><circle cx="4" cy="6" r="1"/><circle cx="4" cy="12" r="1"/><circle cx="4" cy="18" r="1"/></svg>List</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r3"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/></svg>Cards</label>
</div>
<div aria-hidden="true" class="mt-4 rounded-2xl bg-white p-4 ring-1 ring-ttb29-indigo/8">
<div class="hidden grid-cols-3 gap-2 group-has-[#ttb29-r1:checked]/tabs:grid"><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r2:checked]/tabs:flex"><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/3 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-1/2 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-3/4 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/5 rounded-full bg-ttb29-indigo/10"></b></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r3:checked]/tabs:flex"><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i></div>
</div>
</div>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-ttb29-mono text-[11.5px] text-ttb29-mut">CSS pill · label delay-75 · live layout preview</p>
</div>
</section>@import "tailwindcss";
@theme {
--color-ttb29-bg: #f4f3ee;
--color-ttb29-bg: oklch(0.964 0.007 97.4);
--color-ttb29-indigo: #3b3a8c;
--color-ttb29-indigo: oklch(0.398 0.133 279.1);
--color-ttb29-mut: #5d5c94;
--color-ttb29-mut: oklch(0.500 0.088 283.5);
--font-ttb29-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
--font-ttb29-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* 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. */
.ttb-29 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-ttb29-bg: #f4f3ee;
--color-ttb29-bg: oklch(0.964 0.007 97.4);
--color-ttb29-indigo: #3b3a8c;
--color-ttb29-indigo: oklch(0.398 0.133 279.1);
--color-ttb29-mut: #5d5c94;
--color-ttb29-mut: oklch(0.500 0.088 283.5);
--font-ttb29-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
--font-ttb29-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* 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. */
.ttb-29 {
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-ttb29-bg: #f4f3ee;
--color-ttb29-bg: oklch(0.964 0.007 97.4);
--color-ttb29-indigo: #3b3a8c;
--color-ttb29-indigo: oklch(0.398 0.133 279.1);
--color-ttb29-mut: #5d5c94;
--color-ttb29-mut: oklch(0.500 0.088 283.5);
--font-ttb29-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
--font-ttb29-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* 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. */
.ttb-29 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-ttb29-bg: #f4f3ee;
--color-ttb29-bg: oklch(0.964 0.007 97.4);
--color-ttb29-indigo: #3b3a8c;
--color-ttb29-indigo: oklch(0.398 0.133 279.1);
--color-ttb29-mut: #5d5c94;
--color-ttb29-mut: oklch(0.500 0.088 283.5);
--font-ttb29-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
--font-ttb29-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* 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. */
.ttb-29 {
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&family=JetBrains+Mono:wght@400;500&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&family=JetBrains+Mono:wght@400;500&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
- The measuring controller became
w-[calc((100%-12px)/3)] translate-x-[calc(var(--i)*100%)]; the pill animatestransforminstead ofleftandwidth. transition: color 0.3s 0.05scarried over asduration-300 delay-75on the label.- UI upgrade from the CSS original: a preview card under the switcher redraws as a grid, list or stack of cards, so the tabs show what they do.
- UI upgrade: inactive labels moved from 65% indigo (≈4.6:1) to a 5.5:1 token, the pill gained an indigo bloom, and a focus ring was added.
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: Sliding Pill Tabs with Icons in Tailwind CSS
Source: https://codefronts.com/navigation/tailwind-css-tabs/sliding-pill-tabs-icons-tailwind-css/
Grid / List / Cards: a solid indigo pill glides under icon-and-label tabs on cream stock, and the label inverts as the pill arrives. The original measured the pill in JavaScript; the port slides it with the index trick and turns each panel into a live layout preview of the view you chose.
## HTML
```html
<section class="ttb-29 group/tabs grid min-h-svh w-full place-items-center bg-ttb29-bg px-5 py-14 font-ttb29-sans text-ttb29-indigo" aria-label="Sliding pill tabs with icons demo">
<div class="grid w-full max-w-md justify-items-center gap-7">
<div class="w-full">
<div role="radiogroup" aria-label="View" class="relative flex rounded-full bg-ttb29-indigo/7 p-1.5 [--i:0] has-[#ttb29-r2:checked]:[--i:1] has-[#ttb29-r3:checked]:[--i:2]">
<span aria-hidden="true" class="pointer-events-none absolute inset-y-1.5 left-1.5 w-[calc((100%-12px)/3)] translate-x-[calc(var(--i)*100%)] rounded-full bg-ttb29-indigo shadow-[0_6px_16px_-6px_color-mix(in_oklab,var(--color-ttb29-indigo)_60%,transparent)] transition-transform duration-500 ease-[cubic-bezier(0.65,0,0.35,1)] motion-reduce:transition-none"></span>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r1" checked><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>Grid</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r2"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M9 6h12M9 12h12M9 18h12"/><circle cx="4" cy="6" r="1"/><circle cx="4" cy="12" r="1"/><circle cx="4" cy="18" r="1"/></svg>List</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r3"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/></svg>Cards</label>
</div>
<div aria-hidden="true" class="mt-4 rounded-2xl bg-white p-4 ring-1 ring-ttb29-indigo/8">
<div class="hidden grid-cols-3 gap-2 group-has-[#ttb29-r1:checked]/tabs:grid"><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r2:checked]/tabs:flex"><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/3 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-1/2 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-3/4 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/5 rounded-full bg-ttb29-indigo/10"></b></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r3:checked]/tabs:flex"><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i></div>
</div>
</div>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-ttb29-mono text-[11.5px] text-ttb29-mut">CSS pill · label delay-75 · live layout preview</p>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-ttb29-bg: #f4f3ee;
--color-ttb29-bg: oklch(0.964 0.007 97.4);
--color-ttb29-indigo: #3b3a8c;
--color-ttb29-indigo: oklch(0.398 0.133 279.1);
--color-ttb29-mut: #5d5c94;
--color-ttb29-mut: oklch(0.500 0.088 283.5);
--font-ttb29-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
--font-ttb29-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* 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. */
.ttb-29 {
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: Sliding Pill Tabs with Icons in Tailwind CSS
Source: https://codefronts.com/navigation/tailwind-css-tabs/sliding-pill-tabs-icons-tailwind-css/
Grid / List / Cards: a solid indigo pill glides under icon-and-label tabs on cream stock, and the label inverts as the pill arrives. The original measured the pill in JavaScript; the port slides it with the index trick and turns each panel into a live layout preview of the view you chose.
## HTML
```html
<section class="ttb-29 group/tabs grid min-h-svh w-full place-items-center bg-ttb29-bg px-5 py-14 font-ttb29-sans text-ttb29-indigo" aria-label="Sliding pill tabs with icons demo">
<div class="grid w-full max-w-md justify-items-center gap-7">
<div class="w-full">
<div role="radiogroup" aria-label="View" class="relative flex rounded-full bg-ttb29-indigo/7 p-1.5 [--i:0] has-[#ttb29-r2:checked]:[--i:1] has-[#ttb29-r3:checked]:[--i:2]">
<span aria-hidden="true" class="pointer-events-none absolute inset-y-1.5 left-1.5 w-[calc((100%-12px)/3)] translate-x-[calc(var(--i)*100%)] rounded-full bg-ttb29-indigo shadow-[0_6px_16px_-6px_color-mix(in_oklab,var(--color-ttb29-indigo)_60%,transparent)] transition-transform duration-500 ease-[cubic-bezier(0.65,0,0.35,1)] motion-reduce:transition-none"></span>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r1" checked><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>Grid</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r2"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M9 6h12M9 12h12M9 18h12"/><circle cx="4" cy="6" r="1"/><circle cx="4" cy="12" r="1"/><circle cx="4" cy="18" r="1"/></svg>List</label>
<label class="relative z-10 flex min-h-11 flex-1 cursor-pointer items-center justify-center gap-2 rounded-full text-[13px] font-semibold text-ttb29-mut transition-colors delay-75 duration-300 hover:text-ttb29-indigo has-checked:text-ttb29-bg has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ttb29-indigo"><input class="sr-only" type="radio" name="ttb29" id="ttb29-r3"><svg aria-hidden="true" class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9"><rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/></svg>Cards</label>
</div>
<div aria-hidden="true" class="mt-4 rounded-2xl bg-white p-4 ring-1 ring-ttb29-indigo/8">
<div class="hidden grid-cols-3 gap-2 group-has-[#ttb29-r1:checked]/tabs:grid"><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i><i class="aspect-square rounded-lg bg-ttb29-indigo/10"></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r2:checked]/tabs:flex"><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/3 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-1/2 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-3/4 rounded-full bg-ttb29-indigo/10"></b></i><i class="flex h-6 items-center gap-2.5"><b class="size-6 rounded-md bg-ttb29-indigo/15"></b><b class="h-2 w-2/5 rounded-full bg-ttb29-indigo/10"></b></i></div>
<div class="hidden flex-col gap-2.5 group-has-[#ttb29-r3:checked]/tabs:flex"><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i><i class="h-[58px] rounded-xl bg-ttb29-indigo/10"></i></div>
</div>
</div>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-ttb29-mono text-[11.5px] text-ttb29-mut">CSS pill · label delay-75 · live layout preview</p>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-ttb29-bg: #f4f3ee;
--color-ttb29-bg: oklch(0.964 0.007 97.4);
--color-ttb29-indigo: #3b3a8c;
--color-ttb29-indigo: oklch(0.398 0.133 279.1);
--color-ttb29-mut: #5d5c94;
--color-ttb29-mut: oklch(0.500 0.088 283.5);
--font-ttb29-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
--font-ttb29-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* 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. */
.ttb-29 {
width: 100%;
min-height: 100svh;
}
```How this works
Same index trick, padded track. The track has 6px padding, so each tab is a third of 100% - 12px:
<span class="absolute inset-y-1.5 left-1.5 w-[calc((100%-12px)/3)]
translate-x-[calc(var(--i)*100%)] rounded-full bg-ttb29-indigo
transition-transform duration-500"></span>The label colour transitions with a 75ms delay, so the pill arrives under the word just before the word turns cream — the detail that made the original feel physical, kept without the script.
Make it yours
- Dark mode: stock
#111114, trackwhite/6, pill#818cf8. - Faster:
duration-300for snappier toggles. - Hide labels below
smfor an icon-only switcher.
Gotchas — read before shipping
- Labels sit above the pill with
relative z-10. - If labels differ wildly in length, equal columns leave some padding — acceptable for a view switcher.
- The previews are decorative; give real content its own accessible structure.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
:has() drives the index.