25 Tailwind CSS Button Groups
05 / 25

All 25 in 25 Tailwind CSS Button Groups

  1. 01Tailwind Split Button with Anchor-Positioned Popover Dropdown (No JS)
  2. 02Tailwind Segmented Control with Motion-Path Comet Indicator
  3. 03Tailwind Toggle Button Group with View Transitions Morphing Highlight
  4. 04Tailwind Pricing Toggle — Monthly / Yearly Billing Switch (No JS)
  5. 05Tailwind Segmented Control with Sliding Thumb (iOS Style)
  6. 06Tailwind Split Button Dropdown with Native Details Menu (Save Options)
  7. 07Tailwind Icon Button Group Toolbar with Tooltips (Rich Text Editor)
  8. 08Tailwind Pill Filter Button Group with Sliding Indicator (Anchor Positioning)
  9. 09Tailwind Toggle Button Group for Text Alignment (Radio Inputs, Live Preview)
  10. 10Tailwind Web3 Connect Wallet Button Grid (Wallet Sign-In Modal)
  11. 11Tailwind AI Model Selector Button Group (LLM Model Picker with Badges)
  12. 12Tailwind Liquid Metal Segmented Control (Animated Chrome Thumb)
  13. 13Tailwind Tab Button Group with Subgrid Underline Indicator
  14. 14Tailwind Multi-Select Chip Buttons (Tag Filter Checkboxes with Count)
  15. 15Tailwind Animated Split Button Deploy Menu (Staggered Dropdown Reveal)
  16. 16Tailwind Radio Button Group with Conic Fill Animation (Export Format Picker)
  17. 17Tailwind Retro LED Pixel Button Group (Dot-Matrix Display Buttons)
  18. 18Tailwind Hold-to-Confirm Button Group with Gradient Progress (Press and Hold)
  19. 19Tailwind Holographic Icon Segmented Control (Grid / List View Switcher)
  20. 20Tailwind 3D Vertical Button Group with Hover Depth (Perspective Stack)
  21. 21Tailwind Floating Action Button with Radial Speed Dial Menu (No JS)
  22. 22Tailwind Glitch Effect Button Group (Cyberpunk RGB-Split Audio Filter)
  23. 23Tailwind Animated Gradient Border Pill Buttons (Rotating Conic Ring)
  24. 24Tailwind Button Group with Ripple Click Effect (Radar Shockwave Feedback)
  25. 25Tailwind Button Group with Cursor-Following Spotlight Glow (Date Range Presets)
Pure TailwindMIT licensed

Tailwind Segmented Control with Sliding Thumb (iOS Style)

The most-searched button-group pattern: an iOS-style segmented control whose thumb springs between options. Radios carry state and keyboard support; the thumb slides with group-has-[#tbg05-3:checked]/seg:translate-x-[200%] on a spring curve written with v4's ease-[linear(…)]. Each segment shows a sub-value, and the whole control is pure Tailwind.

Live Demo
Plain CSSTailwind v4
Try it

Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time

Untitled UI React · Affiliate link

Get Untitled UI Pro

The code

<section class="tbg-05 w-full min-h-svh grid place-items-center bg-tbg05-bg bg-linear-135 from-tbg05-bg via-tbg05-bg2 to-tbg05-bg3 px-5 py-14 font-tbg05-sans text-tbg05-ink" aria-label="iOS style segmented control demo">
  <div class="grid w-full max-w-[32rem] gap-3">
    <p id="tbg05-label" class="ml-1 text-xs font-bold uppercase tracking-[0.14em] text-tbg05-acc">Timeframe</p>
    <div role="radiogroup" aria-labelledby="tbg05-label" class="group/seg relative grid grid-cols-4 rounded-2xl border border-tbg05-line bg-white p-1.5 shadow-tbg05-lift">
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-1" class="sr-only" checked>Day<span class="text-[11px] font-medium opacity-75">+2.4%</span></label>
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-2" class="sr-only">Week<span class="text-[11px] font-medium opacity-75">+6.1%</span></label>
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-3" class="sr-only">Month<span class="text-[11px] font-medium opacity-75">−1.8%</span></label>
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-4" class="sr-only">Year<span class="text-[11px] font-medium opacity-75">+31%</span></label>
      <span aria-hidden="true" class="pointer-events-none absolute top-1.5 bottom-1.5 left-1.5 z-0 w-[calc((100%-0.75rem)/4)] rounded-xl bg-tbg05-acc shadow-[0_6px_16px_-6px_var(--color-tbg05-acc)] transition-transform duration-500 ease-tbg05-spring group-has-[#tbg05-2:checked]/seg:translate-x-full group-has-[#tbg05-3:checked]/seg:translate-x-[200%] group-has-[#tbg05-4:checked]/seg:translate-x-[300%] motion-reduce:transition-none"></span>
    </div>
  </div>
</section>
@import "tailwindcss";

@theme {
  --color-tbg05-bg: #f5f2ff;
  --color-tbg05-bg2: #efeaff;
  --color-tbg05-bg3: #e7dfff;
  --color-tbg05-line: #e6def9;
  --color-tbg05-ink: #24173f;
  --color-tbg05-mut: #5b4b86;
  --color-tbg05-mut: oklch(0.45 0.09 290);
  --color-tbg05-acc: #6a3fe0;
  --color-tbg05-acc: oklch(0.52 0.22 288);
  --shadow-tbg05-lift: 0 18px 44px -30px rgb(60 20 120 / 0.6);
  --ease-tbg05-spring: linear(0, 0.18 7%, 0.6 18%, 0.96 30%, 1.08 40%, 1.06 48%, 1 60%, 0.99 75%, 1);
  --font-tbg05-sans: 'Onest', system-ui, sans-serif;
}
/* Root rule: the full-bleed contract, restated so the stage is sized before the browser build compiles. */

.tbg-05 {
  width: 100%;
  min-height: 100svh;
}

Setup — do this once per project

Skip this if your project already runs Tailwind v4.

1Load Tailwind
<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.

2Add the stylesheetRequiredthe @theme block is what makes the custom utilities exist
@import "tailwindcss";

@theme {
  --color-tbg05-bg: #f5f2ff;
  --color-tbg05-bg2: #efeaff;
  --color-tbg05-bg3: #e7dfff;
  --color-tbg05-line: #e6def9;
  --color-tbg05-ink: #24173f;
  --color-tbg05-mut: #5b4b86;
  --color-tbg05-mut: oklch(0.45 0.09 290);
  --color-tbg05-acc: #6a3fe0;
  --color-tbg05-acc: oklch(0.52 0.22 288);
  --shadow-tbg05-lift: 0 18px 44px -30px rgb(60 20 120 / 0.6);
  --ease-tbg05-spring: linear(0, 0.18 7%, 0.6 18%, 0.96 30%, 1.08 40%, 1.06 48%, 1 60%, 0.99 75%, 1);
  --font-tbg05-sans: 'Onest', system-ui, sans-serif;
}
/* Root rule: the full-bleed contract, restated so the stage is sized before the browser build compiles. */

.tbg-05 {
  width: 100%;
  min-height: 100svh;
}
3Fonts used by this demooptional — skip if you have your own type stack
<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=Onest:wght@400..800&display=swap">

What changed in the port

Which parts became utilities, which stayed CSS, and why.

  • .btn-05__seg:has(#btn-05-N:checked) .btn-05__thumb{translate:…} became three group-has-[…]/seg: utilities on the thumb.
  • The overshooting cubic-bezier(.34,1.4,.5,1) became a tokenised linear() spring that settles naturally.
  • UI upgrade: each segment now shows its change for the period, so the control carries information instead of bare labels.
  • Accessibility fix: role="group" became role="radiogroup" with a real aria-labelledby; muted text darkened to 7:1.
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
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 Segmented Control with Sliding Thumb (iOS Style)
Source: https://codefronts.com/components/tailwind-css-button-groups/tailwind-segmented-control-sliding-thumb/

The most-searched button-group pattern: an iOS-style segmented control whose thumb springs between options. Radios carry state and keyboard support; the thumb slides with group-has-[#tbg05-3:checked]/seg:translate-x-[200%] on a spring curve written with v4's ease-[linear(…)]. Each segment shows a sub-value, and the whole control is pure Tailwind.
## HTML
```html
<section class="tbg-05 w-full min-h-svh grid place-items-center bg-tbg05-bg bg-linear-135 from-tbg05-bg via-tbg05-bg2 to-tbg05-bg3 px-5 py-14 font-tbg05-sans text-tbg05-ink" aria-label="iOS style segmented control demo">
  <div class="grid w-full max-w-[32rem] gap-3">
    <p id="tbg05-label" class="ml-1 text-xs font-bold uppercase tracking-[0.14em] text-tbg05-acc">Timeframe</p>
    <div role="radiogroup" aria-labelledby="tbg05-label" class="group/seg relative grid grid-cols-4 rounded-2xl border border-tbg05-line bg-white p-1.5 shadow-tbg05-lift">
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-1" class="sr-only" checked>Day<span class="text-[11px] font-medium opacity-75">+2.4%</span></label>
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-2" class="sr-only">Week<span class="text-[11px] font-medium opacity-75">+6.1%</span></label>
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-3" class="sr-only">Month<span class="text-[11px] font-medium opacity-75">−1.8%</span></label>
      <label class="relative z-1 grid min-h-14 cursor-pointer place-content-center justify-items-center rounded-xl text-[15px] font-semibold text-tbg05-mut transition-colors duration-250 hover:text-tbg05-ink has-checked:text-white has-focus-visible:outline-3 has-focus-visible:outline-offset-2 has-focus-visible:outline-tbg05-acc"><input type="radio" name="tbg05" id="tbg05-4" class="sr-only">Year<span class="text-[11px] font-medium opacity-75">+31%</span></label>
      <span aria-hidden="true" class="pointer-events-none absolute top-1.5 bottom-1.5 left-1.5 z-0 w-[calc((100%-0.75rem)/4)] rounded-xl bg-tbg05-acc shadow-[0_6px_16px_-6px_var(--color-tbg05-acc)] transition-transform duration-500 ease-tbg05-spring group-has-[#tbg05-2:checked]/seg:translate-x-full group-has-[#tbg05-3:checked]/seg:translate-x-[200%] group-has-[#tbg05-4:checked]/seg:translate-x-[300%] motion-reduce:transition-none"></span>
    </div>
  </div>
</section>
```
## CSS
```css
@import "tailwindcss";

@theme {
  --color-tbg05-bg: #f5f2ff;
  --color-tbg05-bg2: #efeaff;
  --color-tbg05-bg3: #e7dfff;
  --color-tbg05-line: #e6def9;
  --color-tbg05-ink: #24173f;
  --color-tbg05-mut: #5b4b86;
  --color-tbg05-mut: oklch(0.45 0.09 290);
  --color-tbg05-acc: #6a3fe0;
  --color-tbg05-acc: oklch(0.52 0.22 288);
  --shadow-tbg05-lift: 0 18px 44px -30px rgb(60 20 120 / 0.6);
  --ease-tbg05-spring: linear(0, 0.18 7%, 0.6 18%, 0.96 30%, 1.08 40%, 1.06 48%, 1 60%, 0.99 75%, 1);
  --font-tbg05-sans: 'Onest', system-ui, sans-serif;
}
/* Root rule: the full-bleed contract, restated so the stage is sized before the browser build compiles. */

.tbg-05 {
  width: 100%;
  min-height: 100svh;
}
```

How this works

Translate by its own width. The thumb is exactly one segment wide, so percentage translates move it one segment at a time:

<span class="w-[calc((100%-0.75rem)/4)]
  group-has-[#tbg05-2:checked]/seg:translate-x-full
  group-has-[#tbg05-3:checked]/seg:translate-x-[200%]">

The spring. linear() easing samples a spring curve into a list of points, giving an overshoot-and-settle that cubic-bezier cannot. It's a token: --ease-tbg05-spring mints ease-tbg05-spring.

Make it yours

  • Three segments: grid-cols-3 and w-[calc((100%-0.75rem)/3)].
  • Calmer motion: swap ease-tbg05-spring for ease-out.
  • Drop the sub-values for a compact one-line control (min-h-11 keeps the target size).

Gotchas — read before shipping

  • Segments must be equal width (grid-cols-4), or the translate steps won't land.
  • The thumb sits behind the labels (z-0 vs z-1) — keep it last in the DOM or set z-index explicitly.
  • Older browsers without linear() ignore the easing and fall back to the default curve.

Browser support

ChromeSafariFirefoxEdge
113+17.2+128+113+

linear() easing is Baseline 2023; Tailwind v4 sets the floor.

Techniques used in this demo

Utilitiesfirst-class utility or variant

Search CodeFronts

Loading…