CSS Checkbox Chips

Toggleable filter chips made from checkboxes, with a check icon when selected.

  • chips
  • tags
  • filter
  • checkbox
  • multi-select
HTML
<fieldset class="chips">
  <legend>Topics</legend>
  <label><input type="checkbox" checked>Design</label>
  <label><input type="checkbox">Code</label>
  <label><input type="checkbox" checked>Motion</label>
  <label><input type="checkbox">Audio</label>
</fieldset>
CSS
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 280px;
  margin: 0;
  padding: 0;
  border: 0;
  font: 500 14px/1 system-ui, sans-serif;
}

.chips legend {
  width: 100%;
  margin-bottom: 10px;
  color: #3f3f46;
  font-weight: 700;
}

.chips label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid #e4e4e7;
  border-radius: 999px;
  color: #3f3f46;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chips input {
  flex: none;
  color: inherit;
  width: 0;
  height: 14px;
  margin: 0 -6px 0 0; /* hides the gap while unchecked */
  border: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  appearance: none;
  transition: width 0.15s ease, margin 0.15s ease;
}

.chips label:has(:checked) {
  border-color: #18181b;
  background: #18181b;
  color: #fff;
}

.chips input:checked {
  width: 14px;
  margin-right: 0;
}

.chips label:has(:focus-visible) {
  outline: 2px solid #18181b;
  outline-offset: 2px;
}

About this CSS Checkbox Chips

This CSS Checkbox Chips is 59 lines of pure CSS (1.5 KB) with no JavaScript and no dependencies. It uses transitions, masks, Flexbox and the :has() selector. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #3f3f46
  • #e4e4e7
  • #18181b
  • #fff

How to use this checkbox chips

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .chips class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback