Open demo

CSS code

HTML
<div><span class="lbl">Topic tags · links</span>
<ul class="chips" aria-label="Article topics">
  <li><a class="tag" href="#"><b aria-hidden="true">#</b>accessibility</a></li>
  <li><a class="tag" href="#"><b aria-hidden="true">#</b>css-grid</a></li>
  <li><a class="tag" href="#"><b aria-hidden="true">#</b>design-tokens</a></li>
  <li><a class="tag" href="#"><b aria-hidden="true">#</b>typography</a></li>
  <li><a class="tag" href="#"><b aria-hidden="true">#</b>performance</a></li>
</ul></div>

<div><span class="lbl">Filter chips · toggle buttons with aria-pressed</span>
<div class="chip-group" role="group" aria-labelledby="cuisine-h">
  <span class="chip-head" id="cuisine-h">Cuisine</span>
  <div class="chips">
    <button class="chip" type="button" aria-pressed="true" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Vegetarian</button>
    <button class="chip" type="button" aria-pressed="false" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Japanese</button>
    <button class="chip" type="button" aria-pressed="true" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Under 30 minutes</button>
    <button class="chip" type="button" aria-pressed="false" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Gluten free</button>
    <button class="chip" type="button" aria-pressed="false" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Street food</button>
  </div>
</div></div>

<div><span class="lbl">Removable chips · applied filters</span>
<section class="rm-bar" data-chips aria-labelledby="applied-h">
  <h3 id="applied-h" tabindex="-1">Applied filters</h3>
  <ul class="chips">
    <li class="rm"><span>Lisbon</span><button type="button" aria-label="Remove filter: Lisbon"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
    <li class="rm"><span>Under €180</span><button type="button" aria-label="Remove filter: Under €180"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
    <li class="rm"><span>Free cancellation</span><button type="button" aria-label="Remove filter: Free cancellation"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
    <li class="rm"><span>4 stars and up</span><button type="button" aria-label="Remove filter: 4 stars and up"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
  </ul>
  <p class="rm-empty" data-empty hidden>No filters applied.</p>
  <button class="rm-clear" type="button" data-clear>Clear all</button>
  <p class="sr-only" role="status"></p>
</section></div>

<div><span class="lbl">Person and icon chips</span>
<ul class="chips">
  <li><span class="pc"><i style="--a:#6366f1;--b:#a855f7" aria-hidden="true">LV</i>Lena Vogt</span></li>
  <li><span class="pc"><i style="--a:#0d9488;--b:#0284c7" aria-hidden="true">OA</i>Omar Aziz</span></li>
  <li><span class="pc"><i style="--a:#c2410c;--b:#db2777" aria-hidden="true">JP</i>June Park</span></li>
  <li><span class="pc ic"><svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.5" y="3.5" width="11" height="10" rx="2"/><path d="M2.5 7h11M5.5 2v3M10.5 2v3"/></svg>Due Fri 14 Mar</span></li>
  <li><span class="pc ic"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 14s4.5-4 4.5-7.5a4.5 4.5 0 0 0-9 0C3.5 10 8 14 8 14z"/><circle cx="8" cy="6.5" r="1.5"/></svg>Studio B</span></li>
</ul></div>
CSS
/* Tags, filter chips and removable chips. Filter chips are <button aria-pressed>; removable chips have a labelled
   remove button, and the script moves focus to the next chip (or the heading) when one is removed. */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.chips{--chip-accent:#4f46e5;--chip-accent-soft:#eef2ff;--chip-accent-text:#3730a3;--chip-line:#cbd5e1;--chip-text:#1e293b;
  display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0;padding:0;list-style:none}
/* topic tags (links) */
.tag{display:inline-flex;align-items:center;gap:2px;padding:6px 12px;border-radius:999px;background:#eef1f5;color:#334155;
  font-size:.85rem;font-weight:500;text-decoration:none;transition:background-color .15s,color .15s}
.tag b{color:var(--chip-accent);font-weight:700}
.tag:hover{background:#e0e7ff;color:var(--chip-accent-text)}
.tag:focus-visible{outline:2px solid var(--chip-accent);outline-offset:2px}
/* filter chips (toggle buttons) */
.chip{display:inline-flex;align-items:center;gap:6px;height:34px;padding:0 14px;border:1px solid var(--chip-line);border-radius:999px;
  background:#fff;color:var(--chip-text);font:inherit;font-size:.85rem;font-weight:500;cursor:pointer;
  transition:background-color .15s,border-color .15s,color .15s}
.chip:hover{border-color:#94a3b8;background:#f8fafc}
.chip:focus-visible{outline:2px solid var(--chip-accent);outline-offset:2px}
.chip svg{width:14px;height:14px;flex:none;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round;display:none}
.chip[aria-pressed="true"]{border-color:var(--chip-accent);background:var(--chip-accent-soft);color:var(--chip-accent-text);font-weight:600;padding-left:10px}
.chip[aria-pressed="true"] svg{display:block}
.chip-group{border:0;min-width:0}
.chip-head{display:block;margin-bottom:10px;font-size:.9rem;font-weight:700;color:#0f172a}
/* removable chips */
.rm-bar{display:flex;flex-wrap:wrap;align-items:center;gap:10px 12px;padding:14px;border:1px solid #e2e8f0;border-radius:14px;background:#fff}
.rm-bar h3{font-size:.85rem;font-weight:700;color:#0f172a;border-radius:4px}
.rm-bar h3:focus-visible{outline:2px solid var(--chip-accent);outline-offset:3px}
.rm{display:inline-flex;align-items:center;gap:4px;height:30px;padding:0 4px 0 12px;border-radius:999px;background:#eef2ff;
  color:#3730a3;font-size:.82rem;font-weight:600}
.rm button{display:grid;place-items:center;width:22px;height:22px;border:0;border-radius:50%;background:transparent;color:#3730a3;cursor:pointer;
  transition:background-color .15s}
.rm button:hover{background:#c7d2fe}
.rm button:focus-visible{outline:2px solid var(--chip-accent);outline-offset:1px}
.rm button svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round}
.rm-clear{margin-left:auto;border:0;background:none;color:#4338ca;font:inherit;font-size:.82rem;font-weight:600;text-decoration:underline;
  text-underline-offset:3px;cursor:pointer;border-radius:4px}
.rm-clear:focus-visible{outline:2px solid var(--chip-accent);outline-offset:2px}
.rm-empty{font-size:.82rem;color:#526072}
/* person and icon chips */
.pc{display:inline-flex;align-items:center;gap:8px;height:32px;padding:0 12px 0 4px;border:1px solid #e2e8f0;border-radius:999px;background:#fff;
  color:#1e293b;font-size:.82rem;font-weight:600}
.pc i{display:grid;place-items:center;width:24px;height:24px;border-radius:50%;color:#fff;font-size:.62rem;font-style:normal;font-weight:700;
  background:linear-gradient(135deg,var(--a),var(--b))}
.pc.ic{padding-left:10px;gap:6px;color:#334155}
.pc.ic svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;color:#526072}
@media (prefers-reduced-motion:reduce){.tag,.chip,.rm button{transition:none}}
JavaScript
/* Filter chips flip aria-pressed. Removable chips: remove the chip, announce it, move focus to the next
   chip's remove button, the previous one, or the heading when none are left. */
document.querySelectorAll('[data-chip-toggle]').forEach(function (btn) {
  btn.addEventListener('click', function () {
    btn.setAttribute('aria-pressed', String(btn.getAttribute('aria-pressed') !== 'true'));
  });
});
document.querySelectorAll('[data-chips]').forEach(function (root) {
  var list = root.querySelector('ul'), head = root.querySelector('[tabindex="-1"]');
  var status = root.querySelector('[role="status"]'), clear = root.querySelector('[data-clear]'), empty = root.querySelector('[data-empty]');
  var sync = function () { var n = list.children.length; clear.hidden = !n; empty.hidden = !!n; };
  list.addEventListener('click', function (e) {
    var btn = e.target.closest('button'); if (!btn) return;
    var li = btn.closest('li'), next = li.nextElementSibling || li.previousElementSibling;
    status.textContent = li.firstElementChild.textContent + ' removed';
    li.remove(); sync();
    (next ? next.querySelector('button') : head).focus();
  });
  clear.addEventListener('click', function () {
    list.replaceChildren(); status.textContent = 'All filters cleared'; sync(); head.focus();
  });
});

Bootstrap 5 code

Requires: Bootstrap 5.3.8 CSS

HTML
<div><span class="lbl">Topic tags · links</span>
<ul class="chips list-unstyled d-flex flex-wrap align-items-center m-0" aria-label="Article topics">
  <li><a class="badge rounded-pill tag text-decoration-none" href="#"><b aria-hidden="true">#</b>accessibility</a></li>
  <li><a class="badge rounded-pill tag text-decoration-none" href="#"><b aria-hidden="true">#</b>css-grid</a></li>
  <li><a class="badge rounded-pill tag text-decoration-none" href="#"><b aria-hidden="true">#</b>design-tokens</a></li>
  <li><a class="badge rounded-pill tag text-decoration-none" href="#"><b aria-hidden="true">#</b>typography</a></li>
  <li><a class="badge rounded-pill tag text-decoration-none" href="#"><b aria-hidden="true">#</b>performance</a></li>
</ul></div>

<div><span class="lbl">Filter chips · toggle buttons with aria-pressed</span>
<div role="group" aria-labelledby="cuisine-h">
  <span class="chip-head d-block" id="cuisine-h">Cuisine</span>
  <div class="chips d-flex flex-wrap align-items-center">
    <button class="btn rounded-pill chip" type="button" aria-pressed="true" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Vegetarian</button>
    <button class="btn rounded-pill chip" type="button" aria-pressed="false" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Japanese</button>
    <button class="btn rounded-pill chip" type="button" aria-pressed="true" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Under 30 minutes</button>
    <button class="btn rounded-pill chip" type="button" aria-pressed="false" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Gluten free</button>
    <button class="btn rounded-pill chip" type="button" aria-pressed="false" data-chip-toggle><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Street food</button>
  </div>
</div></div>

<div><span class="lbl">Removable chips · applied filters</span>
<section class="card rm-card" data-chips aria-labelledby="applied-h">
  <div class="card-body d-flex flex-wrap align-items-center rm-bar">
  <h3 class="m-0" id="applied-h" tabindex="-1">Applied filters</h3>
  <ul class="chips list-unstyled d-flex flex-wrap align-items-center m-0">
    <li class="badge rounded-pill rm"><span>Lisbon</span><button class="btn-close" type="button" aria-label="Remove filter: Lisbon"></button></li>
    <li class="badge rounded-pill rm"><span>Under €180</span><button class="btn-close" type="button" aria-label="Remove filter: Under €180"></button></li>
    <li class="badge rounded-pill rm"><span>Free cancellation</span><button class="btn-close" type="button" aria-label="Remove filter: Free cancellation"></button></li>
    <li class="badge rounded-pill rm"><span>4 stars and up</span><button class="btn-close" type="button" aria-label="Remove filter: 4 stars and up"></button></li>
  </ul>
  <p class="rm-empty m-0" data-empty hidden>No filters applied.</p>
  <button class="btn btn-link rm-clear ms-auto" type="button" data-clear>Clear all</button>
  <p class="visually-hidden" role="status"></p>
  </div>
</section></div>

<div><span class="lbl">Person and icon chips</span>
<ul class="chips list-unstyled d-flex flex-wrap align-items-center m-0">
  <li><span class="badge rounded-pill pc"><i style="--a:#6366f1;--b:#a855f7" aria-hidden="true">LV</i>Lena Vogt</span></li>
  <li><span class="badge rounded-pill pc"><i style="--a:#0d9488;--b:#0284c7" aria-hidden="true">OA</i>Omar Aziz</span></li>
  <li><span class="badge rounded-pill pc"><i style="--a:#c2410c;--b:#db2777" aria-hidden="true">JP</i>June Park</span></li>
  <li><span class="badge rounded-pill pc ic"><svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.5" y="3.5" width="11" height="10" rx="2"/><path d="M2.5 7h11M5.5 2v3M10.5 2v3"/></svg>Due Fri 14 Mar</span></li>
  <li><span class="badge rounded-pill pc ic"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 14s4.5-4 4.5-7.5a4.5 4.5 0 0 0-9 0C3.5 10 8 14 8 14z"/><circle cx="8" cy="6.5" r="1.5"/></svg>Studio B</span></li>
</ul></div>
CSS
/* Tags and chips on Bootstrap's .badge, .btn and .btn-close, restyled through --bs-badge-*, --bs-btn-* and --bs-btn-close-* variables.
   Filter chips are .btn with aria-pressed; the script below flips it and manages focus when a chip is removed. */
.chips{--chip-accent:#4f46e5;--chip-accent-soft:#eef2ff;--chip-accent-text:#3730a3;gap:8px}
.tag{--bs-badge-padding-x:12px;--bs-badge-padding-y:6px;--bs-badge-font-size:.85rem;--bs-badge-font-weight:500;--bs-badge-color:#334155;
  display:inline-flex;align-items:center;gap:2px;line-height:1.2;background:#eef1f5;transition:background-color .15s,color .15s}
.tag b{color:#4f46e5;font-weight:700}
.tag:hover{background:#e0e7ff;color:#3730a3}
.tag:focus-visible,.chip:focus-visible,.rm .btn-close:focus-visible,.rm-clear:focus-visible{outline:2px solid #4f46e5;outline-offset:2px;box-shadow:none}
.chip{--bs-btn-padding-x:14px;--bs-btn-padding-y:0;--bs-btn-font-size:.85rem;--bs-btn-font-weight:500;--bs-btn-color:#1e293b;--bs-btn-bg:#fff;--bs-btn-border-color:#cbd5e1;
  --bs-btn-hover-color:#1e293b;--bs-btn-hover-bg:#f8fafc;--bs-btn-hover-border-color:#94a3b8;--bs-btn-active-color:#1e293b;--bs-btn-active-bg:#f1f5f9;--bs-btn-active-border-color:#94a3b8;
  display:inline-flex;align-items:center;gap:6px;height:34px;transition:background-color .15s,border-color .15s,color .15s}
.chip svg{width:14px;height:14px;flex:none;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round;display:none}
.chip[aria-pressed="true"]{--bs-btn-color:#3730a3;--bs-btn-bg:#eef2ff;--bs-btn-border-color:#4f46e5;--bs-btn-hover-color:#3730a3;--bs-btn-hover-bg:#e0e7ff;--bs-btn-hover-border-color:#4f46e5;
  --bs-btn-active-color:#3730a3;--bs-btn-active-bg:#e0e7ff;--bs-btn-active-border-color:#4f46e5;font-weight:600;padding-left:10px}
.chip[aria-pressed="true"] svg{display:block}
.chip-head{margin-bottom:10px;font-size:.9rem;font-weight:700;color:#0f172a}
.rm-card{--bs-card-border-color:#e2e8f0;--bs-card-border-radius:14px;--bs-card-spacer-y:14px;--bs-card-spacer-x:14px}
.rm-bar{gap:10px 12px}
.rm-bar h3{font-size:.85rem;font-weight:700;color:#0f172a;border-radius:4px}
.rm-bar h3:focus-visible{outline:2px solid #4f46e5;outline-offset:3px}
.rm{--bs-badge-padding-x:0;--bs-badge-padding-y:0;--bs-badge-font-size:.82rem;--bs-badge-font-weight:600;--bs-badge-color:#3730a3;
  display:inline-flex;align-items:center;gap:4px;height:30px;padding:0 4px 0 12px;background:#eef2ff;line-height:1.2}
.rm .btn-close{--bs-btn-close-bg:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3e%3cpath d='M3 3l6 6M9 3l-6 6' stroke='%233730a3' stroke-width='2.4' stroke-linecap='round'/%3e%3c/svg%3e");
  --bs-btn-close-opacity:1;--bs-btn-close-hover-opacity:1;--bs-btn-close-focus-opacity:1;--bs-btn-close-focus-shadow:none;
  width:12px;height:12px;padding:5px;border-radius:50%;background-size:12px;transition:background-color .15s}
.rm .btn-close:hover{background-color:#c7d2fe}
.rm-clear{--bs-btn-padding-x:0;--bs-btn-padding-y:0;--bs-btn-font-size:.82rem;--bs-btn-font-weight:600;--bs-btn-color:#4338ca;--bs-btn-hover-color:#3730a3;--bs-btn-active-color:#3730a3;
  text-underline-offset:3px;border-radius:4px}
.rm-empty{font-size:.82rem;color:#526072}
.pc{--bs-badge-padding-x:0;--bs-badge-padding-y:0;--bs-badge-font-size:.82rem;--bs-badge-font-weight:600;--bs-badge-color:#1e293b;
  display:inline-flex;align-items:center;gap:8px;height:32px;padding:0 12px 0 4px;border:1px solid #e2e8f0;background:#fff;line-height:1.2}
.pc i{display:grid;place-items:center;width:24px;height:24px;border-radius:50%;color:#fff;font-size:.62rem;font-style:normal;font-weight:700;
  background:linear-gradient(135deg,var(--a),var(--b))}
.pc.ic{--bs-badge-color:#334155;padding-left:10px;gap:6px}
.pc.ic svg{width:15px;height:15px;fill:none;stroke:#526072;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
@media (prefers-reduced-motion:reduce){.tag,.chip,.rm .btn-close{transition:none}}
JavaScript
/* Filter chips flip aria-pressed. Removable chips: remove the chip, announce it, move focus to the next
   chip's remove button, the previous one, or the heading when none are left. */
document.querySelectorAll('[data-chip-toggle]').forEach(function (btn) {
  btn.addEventListener('click', function () {
    btn.setAttribute('aria-pressed', String(btn.getAttribute('aria-pressed') !== 'true'));
  });
});
document.querySelectorAll('[data-chips]').forEach(function (root) {
  var list = root.querySelector('ul'), head = root.querySelector('[tabindex="-1"]');
  var status = root.querySelector('[role="status"]'), clear = root.querySelector('[data-clear]'), empty = root.querySelector('[data-empty]');
  var sync = function () { var n = list.children.length; clear.hidden = !n; empty.hidden = !!n; };
  list.addEventListener('click', function (e) {
    var btn = e.target.closest('button'); if (!btn) return;
    var li = btn.closest('li'), next = li.nextElementSibling || li.previousElementSibling;
    status.textContent = li.firstElementChild.textContent + ' removed';
    li.remove(); sync();
    (next ? next.querySelector('button') : head).focus();
  });
  clear.addEventListener('click', function () {
    list.replaceChildren(); status.textContent = 'All filters cleared'; sync(); head.focus();
  });
});

Tailwind 4 code

Requires: Tailwind CSS 4

HTML
<div><span class="mb-4 block text-[.72rem] tracking-[.12em] text-[#526072] uppercase">Topic tags · links</span>
<ul class="flex flex-wrap items-center gap-2" aria-label="Article topics">
  <li><a class="inline-flex items-center gap-0.5 rounded-full bg-[#eef1f5] px-3 py-1.5 text-[.85rem] font-medium text-[#334155] transition-[background-color,color] duration-150 hover:bg-[#e0e7ff] hover:text-[#3730a3] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" href="#"><b class="font-bold text-[#4f46e5]" aria-hidden="true">#</b>accessibility</a></li>
  <li><a class="inline-flex items-center gap-0.5 rounded-full bg-[#eef1f5] px-3 py-1.5 text-[.85rem] font-medium text-[#334155] transition-[background-color,color] duration-150 hover:bg-[#e0e7ff] hover:text-[#3730a3] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" href="#"><b class="font-bold text-[#4f46e5]" aria-hidden="true">#</b>css-grid</a></li>
  <li><a class="inline-flex items-center gap-0.5 rounded-full bg-[#eef1f5] px-3 py-1.5 text-[.85rem] font-medium text-[#334155] transition-[background-color,color] duration-150 hover:bg-[#e0e7ff] hover:text-[#3730a3] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" href="#"><b class="font-bold text-[#4f46e5]" aria-hidden="true">#</b>design-tokens</a></li>
  <li><a class="inline-flex items-center gap-0.5 rounded-full bg-[#eef1f5] px-3 py-1.5 text-[.85rem] font-medium text-[#334155] transition-[background-color,color] duration-150 hover:bg-[#e0e7ff] hover:text-[#3730a3] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" href="#"><b class="font-bold text-[#4f46e5]" aria-hidden="true">#</b>typography</a></li>
  <li><a class="inline-flex items-center gap-0.5 rounded-full bg-[#eef1f5] px-3 py-1.5 text-[.85rem] font-medium text-[#334155] transition-[background-color,color] duration-150 hover:bg-[#e0e7ff] hover:text-[#3730a3] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" href="#"><b class="font-bold text-[#4f46e5]" aria-hidden="true">#</b>performance</a></li>
</ul></div>

<div><span class="mb-4 block text-[.72rem] tracking-[.12em] text-[#526072] uppercase">Filter chips · toggle buttons with aria-pressed</span>
<div role="group" aria-labelledby="cuisine-h">
  <span class="mb-2.5 block text-[.9rem] font-bold text-[#0f172a]" id="cuisine-h">Cuisine</span>
  <div class="flex flex-wrap items-center gap-2">
    <button class="group inline-flex h-[34px] cursor-pointer items-center gap-1.5 rounded-full border border-[#cbd5e1] bg-white px-3.5 text-[.85rem] font-medium text-[#1e293b] transition-[background-color,border-color,color] duration-150 hover:border-[#94a3b8] hover:bg-[#f8fafc] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] aria-pressed:border-[#4f46e5] aria-pressed:bg-[#eef2ff] aria-pressed:pl-2.5 aria-pressed:font-semibold aria-pressed:text-[#3730a3] motion-reduce:transition-none" type="button" aria-pressed="true" data-chip-toggle><svg class="hidden size-3.5 flex-none group-aria-pressed:block" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Vegetarian</button>
    <button class="group inline-flex h-[34px] cursor-pointer items-center gap-1.5 rounded-full border border-[#cbd5e1] bg-white px-3.5 text-[.85rem] font-medium text-[#1e293b] transition-[background-color,border-color,color] duration-150 hover:border-[#94a3b8] hover:bg-[#f8fafc] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] aria-pressed:border-[#4f46e5] aria-pressed:bg-[#eef2ff] aria-pressed:pl-2.5 aria-pressed:font-semibold aria-pressed:text-[#3730a3] motion-reduce:transition-none" type="button" aria-pressed="false" data-chip-toggle><svg class="hidden size-3.5 flex-none group-aria-pressed:block" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Japanese</button>
    <button class="group inline-flex h-[34px] cursor-pointer items-center gap-1.5 rounded-full border border-[#cbd5e1] bg-white px-3.5 text-[.85rem] font-medium text-[#1e293b] transition-[background-color,border-color,color] duration-150 hover:border-[#94a3b8] hover:bg-[#f8fafc] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] aria-pressed:border-[#4f46e5] aria-pressed:bg-[#eef2ff] aria-pressed:pl-2.5 aria-pressed:font-semibold aria-pressed:text-[#3730a3] motion-reduce:transition-none" type="button" aria-pressed="true" data-chip-toggle><svg class="hidden size-3.5 flex-none group-aria-pressed:block" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Under 30 minutes</button>
    <button class="group inline-flex h-[34px] cursor-pointer items-center gap-1.5 rounded-full border border-[#cbd5e1] bg-white px-3.5 text-[.85rem] font-medium text-[#1e293b] transition-[background-color,border-color,color] duration-150 hover:border-[#94a3b8] hover:bg-[#f8fafc] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] aria-pressed:border-[#4f46e5] aria-pressed:bg-[#eef2ff] aria-pressed:pl-2.5 aria-pressed:font-semibold aria-pressed:text-[#3730a3] motion-reduce:transition-none" type="button" aria-pressed="false" data-chip-toggle><svg class="hidden size-3.5 flex-none group-aria-pressed:block" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Gluten free</button>
    <button class="group inline-flex h-[34px] cursor-pointer items-center gap-1.5 rounded-full border border-[#cbd5e1] bg-white px-3.5 text-[.85rem] font-medium text-[#1e293b] transition-[background-color,border-color,color] duration-150 hover:border-[#94a3b8] hover:bg-[#f8fafc] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5] aria-pressed:border-[#4f46e5] aria-pressed:bg-[#eef2ff] aria-pressed:pl-2.5 aria-pressed:font-semibold aria-pressed:text-[#3730a3] motion-reduce:transition-none" type="button" aria-pressed="false" data-chip-toggle><svg class="hidden size-3.5 flex-none group-aria-pressed:block" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8.5l3 3 7-7"/></svg>Street food</button>
  </div>
</div></div>

<div><span class="mb-4 block text-[.72rem] tracking-[.12em] text-[#526072] uppercase">Removable chips · applied filters</span>
<section class="flex flex-wrap items-center gap-x-3 gap-y-2.5 rounded-[14px] border border-[#e2e8f0] bg-white p-3.5" data-chips aria-labelledby="applied-h">
  <h3 class="rounded text-[.85rem] font-bold text-[#0f172a] focus-visible:outline-2 focus-visible:outline-offset-[3px] focus-visible:outline-[#4f46e5]" id="applied-h" tabindex="-1">Applied filters</h3>
  <ul class="flex flex-wrap items-center gap-2">
    <li class="inline-flex h-[30px] items-center gap-1 rounded-full bg-[#eef2ff] pr-1 pl-3 text-[.82rem] font-semibold text-[#3730a3]"><span>Lisbon</span><button class="grid size-[22px] cursor-pointer place-items-center rounded-full text-[#3730a3] transition-[background-color] duration-150 hover:bg-[#c7d2fe] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" type="button" aria-label="Remove filter: Lisbon"><svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
    <li class="inline-flex h-[30px] items-center gap-1 rounded-full bg-[#eef2ff] pr-1 pl-3 text-[.82rem] font-semibold text-[#3730a3]"><span>Under €180</span><button class="grid size-[22px] cursor-pointer place-items-center rounded-full text-[#3730a3] transition-[background-color] duration-150 hover:bg-[#c7d2fe] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" type="button" aria-label="Remove filter: Under €180"><svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
    <li class="inline-flex h-[30px] items-center gap-1 rounded-full bg-[#eef2ff] pr-1 pl-3 text-[.82rem] font-semibold text-[#3730a3]"><span>Free cancellation</span><button class="grid size-[22px] cursor-pointer place-items-center rounded-full text-[#3730a3] transition-[background-color] duration-150 hover:bg-[#c7d2fe] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" type="button" aria-label="Remove filter: Free cancellation"><svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
    <li class="inline-flex h-[30px] items-center gap-1 rounded-full bg-[#eef2ff] pr-1 pl-3 text-[.82rem] font-semibold text-[#3730a3]"><span>4 stars and up</span><button class="grid size-[22px] cursor-pointer place-items-center rounded-full text-[#3730a3] transition-[background-color] duration-150 hover:bg-[#c7d2fe] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#4f46e5] motion-reduce:transition-none" type="button" aria-label="Remove filter: 4 stars and up"><svg class="size-3" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M3 3l6 6M9 3l-6 6"/></svg></button></li>
  </ul>
  <p class="text-[.82rem] text-[#526072]" data-empty hidden>No filters applied.</p>
  <button class="ml-auto cursor-pointer rounded text-[.82rem] font-semibold text-[#4338ca] underline underline-offset-[3px] hover:text-[#3730a3] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#4f46e5]" type="button" data-clear>Clear all</button>
  <p class="sr-only" role="status"></p>
</section></div>

<div><span class="mb-4 block text-[.72rem] tracking-[.12em] text-[#526072] uppercase">Person and icon chips</span>
<ul class="flex flex-wrap items-center gap-2">
  <li><span class="inline-flex h-8 items-center gap-2 rounded-full border border-[#e2e8f0] bg-white pr-3 pl-1 text-[.82rem] font-semibold text-[#1e293b]"><i class="grid size-6 place-items-center rounded-full bg-linear-135 from-[#6366f1] to-[#a855f7] text-[.62rem] font-bold text-white not-italic" aria-hidden="true">LV</i>Lena Vogt</span></li>
  <li><span class="inline-flex h-8 items-center gap-2 rounded-full border border-[#e2e8f0] bg-white pr-3 pl-1 text-[.82rem] font-semibold text-[#1e293b]"><i class="grid size-6 place-items-center rounded-full bg-linear-135 from-[#0d9488] to-[#0284c7] text-[.62rem] font-bold text-white not-italic" aria-hidden="true">OA</i>Omar Aziz</span></li>
  <li><span class="inline-flex h-8 items-center gap-2 rounded-full border border-[#e2e8f0] bg-white pr-3 pl-1 text-[.82rem] font-semibold text-[#1e293b]"><i class="grid size-6 place-items-center rounded-full bg-linear-135 from-[#c2410c] to-[#db2777] text-[.62rem] font-bold text-white not-italic" aria-hidden="true">JP</i>June Park</span></li>
  <li><span class="inline-flex h-8 items-center gap-1.5 rounded-full border border-[#e2e8f0] bg-white px-3 pl-2.5 text-[.82rem] font-semibold text-[#334155]"><svg class="size-[15px] text-[#526072]" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="3.5" width="11" height="10" rx="2"/><path d="M2.5 7h11M5.5 2v3M10.5 2v3"/></svg>Due Fri 14 Mar</span></li>
  <li><span class="inline-flex h-8 items-center gap-1.5 rounded-full border border-[#e2e8f0] bg-white px-3 pl-2.5 text-[.82rem] font-semibold text-[#334155]"><svg class="size-[15px] text-[#526072]" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 14s4.5-4 4.5-7.5a4.5 4.5 0 0 0-9 0C3.5 10 8 14 8 14z"/><circle cx="8" cy="6.5" r="1.5"/></svg>Studio B</span></li>
</ul></div>
JavaScript
/* Filter chips flip aria-pressed. Removable chips: remove the chip, announce it, move focus to the next
   chip's remove button, the previous one, or the heading when none are left. */
document.querySelectorAll('[data-chip-toggle]').forEach(function (btn) {
  btn.addEventListener('click', function () {
    btn.setAttribute('aria-pressed', String(btn.getAttribute('aria-pressed') !== 'true'));
  });
});
document.querySelectorAll('[data-chips]').forEach(function (root) {
  var list = root.querySelector('ul'), head = root.querySelector('[tabindex="-1"]');
  var status = root.querySelector('[role="status"]'), clear = root.querySelector('[data-clear]'), empty = root.querySelector('[data-empty]');
  var sync = function () { var n = list.children.length; clear.hidden = !n; empty.hidden = !!n; };
  list.addEventListener('click', function (e) {
    var btn = e.target.closest('button'); if (!btn) return;
    var li = btn.closest('li'), next = li.nextElementSibling || li.previousElementSibling;
    status.textContent = li.firstElementChild.textContent + ' removed';
    li.remove(); sync();
    (next ? next.querySelector('button') : head).focus();
  });
  clear.addEventListener('click', function () {
    list.replaceChildren(); status.textContent = 'All filters cleared'; sync(); head.focus();
  });
});

About this set

Four kinds of chip for content and filtering. Topic tags are links in a labelled list, styled as rounded hashtags such as accessibility and css-grid. Filter chips for a recipe search are real buttons with aria-pressed: pressing one fills it with an indigo tint and shows a tick, so the state is visible without relying on colour. Removable chips show the filters applied to a hotel search, such as Lisbon and Under 180 euros, each with its own remove button and a Clear all link. Person and icon chips pair a small initials avatar or an icon with a name, date or place. Use link tags for taxonomy, filter chips where several options can be on at once, and removable chips to summarise what is applied. A short vanilla script flips aria-pressed and handles removal: it announces the removed filter through a status region and moves keyboard focus to the next chip, the previous one, or the section heading when none remain, so focus is never lost on the page.

What’s included

  • Filter chips as buttons with aria-pressed and a visible tick
  • Removable chips with labelled remove buttons such as Remove filter: Lisbon
  • Focus moves to the next chip or the heading after a removal
  • Removals are announced through a role="status" region
  • Link tags in a labelled list and static person and icon chips

Accessibility

Filter chips are native buttons whose aria-pressed state is announced as pressed or not pressed, and the tick gives a non-colour cue. Each remove button is named, for example Remove filter: Free cancellation, and after a removal the script announces it and moves focus to a neighbouring chip or the heading. All links and buttons show a 2px indigo focus outline, and hover transitions switch off under prefers-reduced-motion.

Customise it

Set --chip-accent, --chip-accent-soft and --chip-accent-text on .chips in plain CSS for the pressed colours. Bootstrap restyles .btn and .btn-close through --bs-btn-* and --bs-btn-close-bg; in Tailwind edit the aria-pressed: and hover: colour utilities.