02 / 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 Filter Chip Checkbox — Style Checkbox as Button
The e-commerce facet bar in a single class list per chip: has-checked:bg-tcb02-acc repaints the whole <label>, a leading tick unfolds, and a pure-CSS counter tallies the active filters live — has-checked:[counter-increment:tcb02] plus after:content-[counter(tcb02)]. Zero JavaScript.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="tcb-02 w-full min-h-svh grid place-items-center bg-tcb02-bg px-5 py-14 font-tcb02-sans text-tcb02-ink selection:bg-tcb02-acc selection:text-white" aria-label="Filter tag pills">
<fieldset class="flex w-full max-w-[30rem] flex-wrap gap-2.5 [counter-reset:tcb02]">
<legend class="mb-3.5 text-xs font-bold uppercase tracking-[0.12em] text-tcb02-mut">Filter by category</legend>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Design</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Engineering</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Marketing</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Remote</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Full-time</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Contract</label>
<p aria-hidden="true" class="mt-3 flex basis-full items-center gap-2 text-[13px] font-semibold text-tcb02-mut after:grid after:h-6 after:min-w-6 after:place-items-center after:rounded-full after:bg-tcb02-ink after:px-2 after:text-xs after:text-white after:content-[counter(tcb02)]">Active filters</p>
</fieldset>
</section><section class="tcb-02 w-full min-h-svh grid place-items-center bg-tcb02-bg px-5 py-14 font-tcb02-sans text-tcb02-ink selection:bg-tcb02-acc selection:text-white" aria-label="Filter tag pills">
<fieldset class="flex w-full max-w-[30rem] flex-wrap gap-2.5 [counter-reset:tcb02]">
<legend class="mb-3.5 text-xs font-bold uppercase tracking-[0.12em] text-tcb02-mut">Filter by category</legend>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Design</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Engineering</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Marketing</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Remote</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Full-time</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Contract</label>
<p aria-hidden="true" class="mt-3 flex basis-full items-center gap-2 text-[13px] font-semibold text-tcb02-mut after:grid after:h-6 after:min-w-6 after:place-items-center after:rounded-full after:bg-tcb02-ink after:px-2 after:text-xs after:text-white after:content-[counter(tcb02)]">Active filters</p>
</fieldset>
</section>@import "tailwindcss";
@theme {
--color-tcb02-bg: #f4f6f5;
--color-tcb02-bg: oklch(0.97 0.004 160);
--color-tcb02-ink: #2f3538;
--color-tcb02-ink: oklch(0.32 0.01 220);
--color-tcb02-mut: #5f6763;
--color-tcb02-mut: oklch(0.5 0.01 160);
--color-tcb02-line: #d6dcd9;
--color-tcb02-line: oklch(0.89 0.008 160);
--color-tcb02-acc: #1f7a57;
--color-tcb02-acc: oklch(0.5 0.11 160);
--font-tcb02-sans: 'Manrope', 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. */
.tcb-02 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb02-bg: #f4f6f5;
--color-tcb02-bg: oklch(0.97 0.004 160);
--color-tcb02-ink: #2f3538;
--color-tcb02-ink: oklch(0.32 0.01 220);
--color-tcb02-mut: #5f6763;
--color-tcb02-mut: oklch(0.5 0.01 160);
--color-tcb02-line: #d6dcd9;
--color-tcb02-line: oklch(0.89 0.008 160);
--color-tcb02-acc: #1f7a57;
--color-tcb02-acc: oklch(0.5 0.11 160);
--font-tcb02-sans: 'Manrope', 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. */
.tcb-02 {
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-tcb02-bg: #f4f6f5;
--color-tcb02-bg: oklch(0.97 0.004 160);
--color-tcb02-ink: #2f3538;
--color-tcb02-ink: oklch(0.32 0.01 220);
--color-tcb02-mut: #5f6763;
--color-tcb02-mut: oklch(0.5 0.01 160);
--color-tcb02-line: #d6dcd9;
--color-tcb02-line: oklch(0.89 0.008 160);
--color-tcb02-acc: #1f7a57;
--color-tcb02-acc: oklch(0.5 0.11 160);
--font-tcb02-sans: 'Manrope', 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. */
.tcb-02 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb02-bg: #f4f6f5;
--color-tcb02-bg: oklch(0.97 0.004 160);
--color-tcb02-ink: #2f3538;
--color-tcb02-ink: oklch(0.32 0.01 220);
--color-tcb02-mut: #5f6763;
--color-tcb02-mut: oklch(0.5 0.01 160);
--color-tcb02-line: #d6dcd9;
--color-tcb02-line: oklch(0.89 0.008 160);
--color-tcb02-acc: #1f7a57;
--color-tcb02-acc: oklch(0.5 0.11 160);
--font-tcb02-sans: 'Manrope', 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. */
.tcb-02 {
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=Manrope:wght@400;500;600;700;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=Manrope:wght@400;500;600;700;800&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
.cb-02__pill:has(:checked)becamehas-checked:on the label, and the separate:has(:focus-visible)rule becamehas-focus-visible:.- The CSS mask-image check (a 400-character data URI, declared twice with
-webkit-) became a 1-line inline SVG that inheritscurrentColor. - UI upgrade from the CSS original: a live, zero-JS "Active filters" tally built from CSS counters, so users see the effect of each chip.
- UI upgrade: the accent darkened from
oklch(0.55)to0.5so white chip text passes 4.5:1, the legend rose to 5.8:1, and every chip is 44px tall (was ~38px).
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 Filter Chip Checkbox — Style Checkbox as Button
Source: https://codefronts.com/components/tailwind-css-checkboxes/tailwind-filter-chip-checkbox-button/
The e-commerce facet bar in a single class list per chip: has-checked:bg-tcb02-acc repaints the whole <label>, a leading tick unfolds, and a pure-CSS counter tallies the active filters live — has-checked:[counter-increment:tcb02] plus after:content-[counter(tcb02)]. Zero JavaScript.
## HTML
```html
<section class="tcb-02 w-full min-h-svh grid place-items-center bg-tcb02-bg px-5 py-14 font-tcb02-sans text-tcb02-ink selection:bg-tcb02-acc selection:text-white" aria-label="Filter tag pills">
<fieldset class="flex w-full max-w-[30rem] flex-wrap gap-2.5 [counter-reset:tcb02]">
<legend class="mb-3.5 text-xs font-bold uppercase tracking-[0.12em] text-tcb02-mut">Filter by category</legend>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Design</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Engineering</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Marketing</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Remote</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Full-time</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Contract</label>
<p aria-hidden="true" class="mt-3 flex basis-full items-center gap-2 text-[13px] font-semibold text-tcb02-mut after:grid after:h-6 after:min-w-6 after:place-items-center after:rounded-full after:bg-tcb02-ink after:px-2 after:text-xs after:text-white after:content-[counter(tcb02)]">Active filters</p>
</fieldset>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb02-bg: #f4f6f5;
--color-tcb02-bg: oklch(0.97 0.004 160);
--color-tcb02-ink: #2f3538;
--color-tcb02-ink: oklch(0.32 0.01 220);
--color-tcb02-mut: #5f6763;
--color-tcb02-mut: oklch(0.5 0.01 160);
--color-tcb02-line: #d6dcd9;
--color-tcb02-line: oklch(0.89 0.008 160);
--color-tcb02-acc: #1f7a57;
--color-tcb02-acc: oklch(0.5 0.11 160);
--font-tcb02-sans: 'Manrope', 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. */
.tcb-02 {
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 Filter Chip Checkbox — Style Checkbox as Button
Source: https://codefronts.com/components/tailwind-css-checkboxes/tailwind-filter-chip-checkbox-button/
The e-commerce facet bar in a single class list per chip: has-checked:bg-tcb02-acc repaints the whole <label>, a leading tick unfolds, and a pure-CSS counter tallies the active filters live — has-checked:[counter-increment:tcb02] plus after:content-[counter(tcb02)]. Zero JavaScript.
## HTML
```html
<section class="tcb-02 w-full min-h-svh grid place-items-center bg-tcb02-bg px-5 py-14 font-tcb02-sans text-tcb02-ink selection:bg-tcb02-acc selection:text-white" aria-label="Filter tag pills">
<fieldset class="flex w-full max-w-[30rem] flex-wrap gap-2.5 [counter-reset:tcb02]">
<legend class="mb-3.5 text-xs font-bold uppercase tracking-[0.12em] text-tcb02-mut">Filter by category</legend>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Design</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Engineering</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Marketing</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Remote</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only"><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Full-time</label>
<label class="group inline-flex min-h-11 cursor-pointer select-none items-center rounded-full border-[1.5px] border-tcb02-line bg-white px-4 text-sm font-semibold transition-colors duration-200 hover:border-tcb02-acc has-checked:border-tcb02-acc has-checked:bg-tcb02-acc has-checked:text-white has-checked:[counter-increment:tcb02] has-focus-visible:outline-3 has-focus-visible:outline-offset-3 has-focus-visible:outline-tcb02-acc motion-reduce:transition-none"><input type="checkbox" class="sr-only" checked><span aria-hidden="true" class="inline-flex w-0 scale-50 overflow-hidden opacity-0 transition-all duration-200 group-has-checked:mr-1.5 group-has-checked:w-3.5 group-has-checked:scale-100 group-has-checked:opacity-100 motion-reduce:transition-none"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" class="size-3.5 flex-none"><path d="M20 6 9 17l-5-5"/></svg></span>Contract</label>
<p aria-hidden="true" class="mt-3 flex basis-full items-center gap-2 text-[13px] font-semibold text-tcb02-mut after:grid after:h-6 after:min-w-6 after:place-items-center after:rounded-full after:bg-tcb02-ink after:px-2 after:text-xs after:text-white after:content-[counter(tcb02)]">Active filters</p>
</fieldset>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb02-bg: #f4f6f5;
--color-tcb02-bg: oklch(0.97 0.004 160);
--color-tcb02-ink: #2f3538;
--color-tcb02-ink: oklch(0.32 0.01 220);
--color-tcb02-mut: #5f6763;
--color-tcb02-mut: oklch(0.5 0.01 160);
--color-tcb02-line: #d6dcd9;
--color-tcb02-line: oklch(0.89 0.008 160);
--color-tcb02-acc: #1f7a57;
--color-tcb02-acc: oklch(0.5 0.11 160);
--font-tcb02-sans: 'Manrope', 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. */
.tcb-02 {
width: 100%;
min-height: 100svh;
}
```How this works
The label is the control. Each chip wraps a sr-only checkbox, so the state lives on the parent and has-checked: can repaint border, fill and ink together.
The counter is CSS. The fieldset resets tcb02; every checked chip increments it; a footer after the chips prints counter(tcb02) through after:content-[…]. Counters only count elements before the reader in document order, which is why the tally sits below the chips.
The tick unfolds from w-0 to w-3.5 with scale and opacity, so unselected chips carry no dead space.
Make it yours
- Per-category colour: give a chip
has-checked:bg-emerald-600to override the token. - Remove affordance: swap the tick for an ✕ glyph and move it after the text.
- Density:
min-h-9 px-3 text-[13px]for toolbars (keep the 44px target on touch withpointer-coarse:min-h-11). - Hide the tally at zero: wrap it in a
group-has-checked/field:reveal.
Gotchas — read before shipping
- Generated counter text isn't reliably announced — the tally is
aria-hidden; the checkboxes themselves carry the state. - Underscores inside arbitrary values become spaces;
counter(tcb02)needs none. - Animating
widthis a small reflow; for dense toolbars keep the tick in layout and only fade it.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
CSS counters are universal; :has() needs Firefox 121+.