05Multi-select chip tokens
Picked options stack up as chips inside the field, and clicking x or pressing Backspace really removes the last one.
Best forFor filters that allow several picks at once (tags, stacks, recipients) where the current selection must stay visible
aria-multiselectableBackspacescale

<main class="stage">
<div class="mc is-demo is-open">
<span class="mc__label" id="mc-label">Tech stack</span>
<div class="mc__field" id="mc-field" role="combobox" tabindex="0" aria-haspopup="listbox" aria-expanded="true" aria-controls="mc-list" aria-labelledby="mc-label">
<span class="mc__chips" id="mc-chips">
<span class="mc__chip" data-for="mc-o1">React<button class="mc__x" type="button" aria-label="Remove React"><svg viewBox="0 0 256 256" width="10" height="10"><g fill="currentColor"><path d="M216 56v144a16 16 0 0 1-16 16H56a16 16 0 0 1-16-16V56a16 16 0 0 1 16-16h144a16 16 0 0 1 16 16" opacity=".2"/><path d="M205.66 194.34a8 8 0 0 1-11.32 11.32L128 139.31l-66.34 66.35a8 8 0 0 1-11.32-11.32L116.69 128L50.34 61.66a8 8 0 0 1 11.32-11.32L128 116.69l66.34-66.35a8 8 0 0 1 11.32 11.32L139.31 128Z"/></g></svg></button></span>
<span class="mc__chip" data-for="mc-o2">SCSS<button class="mc__x" type="button" aria-label="Remove SCSS"><svg viewBox="0 0 256 256" width="10" height="10"><g fill="currentColor"><path d="M216 56v144a16 16 0 0 1-16 16H56a16 16 0 0 1-16-16V56a16 16 0 0 1 16-16h144a16 16 0 0 1 16 16" opacity=".2"/><path d="M205.66 194.34a8 8 0 0 1-11.32 11.32L128 139.31l-66.34 66.35a8 8 0 0 1-11.32-11.32L116.69 128L50.34 61.66a8 8 0 0 1 11.32-11.32L128 116.69l66.34-66.35a8 8 0 0 1 11.32 11.32L139.31 128Z"/></g></svg></button></span>
<span class="mc__chip mc__chip--ghost" aria-hidden="true">Vite</span>
</span>
<span class="mc__caret" aria-hidden="true"><svg viewBox="0 0 256 256" width="12" height="12"><g fill="currentColor"><path d="m208 96l-80 80l-80-80Z" opacity=".2"/><path d="M215.39 92.94A8 8 0 0 0 208 88H48a8 8 0 0 0-5.66 13.66l80 80a8 8 0 0 0 11.32 0l80-80a8 8 0 0 0 1.73-8.72M128 164.69L67.31 104h121.38Z"/></g></svg></span>
</div>
<ul class="mc__list" id="mc-list" role="listbox" aria-multiselectable="true" aria-labelledby="mc-label">
<li class="mc__opt is-on" id="mc-o1" role="option" aria-selected="true">React<span class="mc__tick" aria-hidden="true"><svg viewBox="0 0 256 256" width="13" height="13"><g fill="currentColor"><path d="M224 128a96 96 0 1 1-96-96a96 96 0 0 1 96 96" opacity=".2"/><path d="M173.66 98.34a8 8 0 0 1 0 11.32l-56 56a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L112 148.69l50.34-50.35a8 8 0 0 1 11.32 0M232 128A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88"/></g></svg></span></li>
<li class="mc__opt is-on" id="mc-o2" role="option" aria-selected="true">SCSS<span class="mc__tick" aria-hidden="true"><svg viewBox="0 0 256 256" width="13" height="13"><g fill="currentColor"><path d="M224 128a96 96 0 1 1-96-96a96 96 0 0 1 96 96" opacity=".2"/><path d="M173.66 98.34a8 8 0 0 1 0 11.32l-56 56a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L112 148.69l50.34-50.35a8 8 0 0 1 11.32 0M232 128A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88"/></g></svg></span></li>
<li class="mc__opt mc__opt--pulse" id="mc-o3" role="option" aria-selected="false">Vite<span class="mc__tick" aria-hidden="true"><svg viewBox="0 0 256 256" width="13" height="13"><g fill="currentColor"><path d="M224 128a96 96 0 1 1-96-96a96 96 0 0 1 96 96" opacity=".2"/><path d="M173.66 98.34a8 8 0 0 1 0 11.32l-56 56a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L112 148.69l50.34-50.35a8 8 0 0 1 11.32 0M232 128A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88"/></g></svg></span></li>
</ul>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-quick;
$easing: $ease-pop;
$color: $subject-blue;
@include stage($stage-ink);
.mc {
position: relative;
box-sizing: border-box;
width: min(228px, 84vw);
// 열린 목록은 absolute 라 높이에 안 잡힌다 — 그만큼 아래를 비워 둔다
padding-bottom: 96px;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
.mc__label {
display: block;
font-size: 10px; line-height: 12px; font-weight: 800;
letter-spacing: .04em;
color: rgba(255, 255, 255, .6);
margin: 0 0 $sp-1;
}
.mc__field {
box-sizing: border-box;
min-height: 36px;
display: flex; align-items: center; justify-content: space-between; gap: $sp-2;
padding: 0 $sp-2;
border: 1px solid rgba(255, 255, 255, .16);
background: rgba(255, 255, 255, .06);
border-radius: $r-control;
cursor: text;
}
.mc__field:focus-visible { outline: 2px solid $color; outline-offset: 2px; }
.mc__chips { display: flex; align-items: center; gap: $sp-1; flex-wrap: nowrap; }
.mc__chip {
box-sizing: border-box;
height: 22px;
display: inline-flex; align-items: center; gap: $sp-1;
padding: 0 $sp-1 0 $sp-2;
border-radius: $r-pill;
background: rgba(47, 109, 246, .9);
color: #fff;
font-size: 10px; font-weight: 700;
white-space: nowrap;
}
.mc__x {
display: inline-flex; align-items: center; justify-content: center;
width: 14px; height: 14px;
padding: 0;
border: 0;
border-radius: 50%;
background: rgba(255, 255, 255, .22);
color: #fff;
font: inherit;
font-size: 10px; line-height: 1;
cursor: pointer;
}
.mc__chip--ghost {
transform: scale(.5);
opacity: 0;
}
.mc__caret { display: inline-flex; color: rgba(255, 255, 255, .5); }
.mc__list {
position: absolute;
top: 60px; left: 0; right: 0;
box-sizing: border-box;
margin: 0; padding: $sp-1;
list-style: none;
background: #fff;
border-radius: $r-card;
box-shadow: $shadow-raised;
opacity: 0;
transform: translateY(-4px);
pointer-events: none;
transition: opacity $duration $easing, transform $duration $easing;
}
.mc.is-open .mc__list { opacity: 1; transform: translateY(0); pointer-events: auto; }
.mc__opt {
box-sizing: border-box;
height: 26px;
display: flex; align-items: center; justify-content: space-between; gap: $sp-2;
padding: 0 $sp-2;
border-radius: $r-sm;
color: $stage-ink;
font-size: 12px; font-weight: 600;
cursor: pointer;
}
.mc__opt.is-at, .mc__opt:hover { background: rgba(47, 109, 246, .1); }
.mc__tick { display: inline-flex; color: $color; opacity: 0; }
.mc__opt.is-on .mc__tick { opacity: 1; }
// ── 자동 루프: 세 번째 항목을 고르면 칩이 튀어나오고, 다시 빼면 칩이 줄어든다 ──
.mc.is-demo .mc__chip--ghost { animation: mc-chip $dur-loop $easing infinite; }
.mc.is-demo .mc__opt--pulse .mc__tick { animation: mc-tick $dur-loop $easing infinite; }
@keyframes mc-chip {
0%, 100% { transform: scale(.5); opacity: 0; }
24% { transform: scale(1); opacity: 1; }
76% { transform: scale(1); opacity: 1; }
}
@keyframes mc-tick {
0%, 100% { opacity: 0; }
24% { opacity: 1; }
76% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.mc.is-demo .mc__chip--ghost,
.mc.is-demo .mc__opt--pulse .mc__tick { animation: none !important; }
.mc__list { transition: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #17141a;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.mc {
position: relative;
box-sizing: border-box;
width: min(228px, 84vw);
padding-bottom: 96px;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
.mc__label {
display: block;
font-size: 10px;
line-height: 12px;
font-weight: 800;
letter-spacing: 0.04em;
color: rgba(255, 255, 255, 0.6);
margin: 0 0 4px;
}
.mc__field {
box-sizing: border-box;
min-height: 36px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 0 8px;
border: 1px solid rgba(255, 255, 255, 0.16);
background: rgba(255, 255, 255, 0.06);
border-radius: 12px;
cursor: text;
}
.mc__field:focus-visible {
outline: 2px solid #2f6df6;
outline-offset: 2px;
}
.mc__chips {
display: flex;
align-items: center;
gap: 4px;
flex-wrap: nowrap;
}
.mc__chip {
box-sizing: border-box;
height: 22px;
display: inline-flex;
align-items: center;
gap: 4px;
padding: 0 4px 0 8px;
border-radius: 999px;
background: rgba(47, 109, 246, 0.9);
color: #fff;
font-size: 10px;
font-weight: 700;
white-space: nowrap;
}
.mc__x {
display: inline-flex;
align-items: center;
justify-content: center;
width: 14px;
height: 14px;
padding: 0;
border: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.22);
color: #fff;
font: inherit;
font-size: 10px;
line-height: 1;
cursor: pointer;
}
.mc__chip--ghost {
transform: scale(0.5);
opacity: 0;
}
.mc__caret {
display: inline-flex;
color: rgba(255, 255, 255, 0.5);
}
.mc__list {
position: absolute;
top: 60px;
left: 0;
right: 0;
box-sizing: border-box;
margin: 0;
padding: 4px;
list-style: none;
background: #fff;
border-radius: 16px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
opacity: 0;
transform: translateY(-4px);
pointer-events: none;
transition: opacity 220ms cubic-bezier(0.2, 1.4, 0.4, 1), transform 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.mc.is-open .mc__list {
opacity: 1;
transform: translateY(0);
pointer-events: auto;
}
.mc__opt {
box-sizing: border-box;
height: 26px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 0 8px;
border-radius: 8px;
color: #17141a;
font-size: 12px;
font-weight: 600;
cursor: pointer;
}
.mc__opt.is-at, .mc__opt:hover {
background: rgba(47, 109, 246, 0.1);
}
.mc__tick {
display: inline-flex;
color: #2f6df6;
opacity: 0;
}
.mc__opt.is-on .mc__tick {
opacity: 1;
}
.mc.is-demo .mc__chip--ghost {
animation: mc-chip 2s cubic-bezier(0.2, 1.4, 0.4, 1) infinite;
}
.mc.is-demo .mc__opt--pulse .mc__tick {
animation: mc-tick 2s cubic-bezier(0.2, 1.4, 0.4, 1) infinite;
}
@keyframes mc-chip {
0%, 100% {
transform: scale(0.5);
opacity: 0;
}
24% {
transform: scale(1);
opacity: 1;
}
76% {
transform: scale(1);
opacity: 1;
}
}
@keyframes mc-tick {
0%, 100% {
opacity: 0;
}
24% {
opacity: 1;
}
76% {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.mc.is-demo .mc__chip--ghost,
.mc.is-demo .mc__opt--pulse .mc__tick {
animation: none !important;
}
.mc__list {
transition: none;
}
}// 실제 동작: 항목을 누르면 칩이 실제로 늘고 줄며, Backspace 는 마지막 칩을 뺀다.
var root = document.querySelector('.mc');
var field = document.getElementById('mc-field');
var chips = document.getElementById('mc-chips');
var list = document.getElementById('mc-list');
var opts = [].slice.call(list.querySelectorAll('.mc__opt'));
var ghost = chips.querySelector('.mc__chip--ghost');
var at = 0;
function label(o) { return o.firstChild.nodeValue; }
function sync(o) {
root.classList.remove('is-demo');
if (ghost) { ghost.remove(); ghost = null; }
var on = o.getAttribute('aria-selected') !== 'true';
o.setAttribute('aria-selected', String(on));
o.classList.toggle('is-on', on);
var have = chips.querySelector('[data-for="' + o.id + '"]');
if (on && !have) {
var chip = document.createElement('span');
chip.className = 'mc__chip';
chip.dataset.for = o.id;
chip.textContent = label(o);
var x = document.createElement('button');
x.type = 'button';
x.className = 'mc__x';
x.setAttribute('aria-label', label(o) + ' — remove');
x.textContent = '×';
x.addEventListener('click', function (e) { e.stopPropagation(); sync(o); });
chip.appendChild(x);
chips.appendChild(chip);
} else if (!on && have) { have.remove(); }
}
opts.forEach(function (o, i) {
o.addEventListener('click', function () { at = i; sync(o); });
});
chips.querySelectorAll('.mc__x').forEach(function (x) {
x.addEventListener('click', function (e) {
e.stopPropagation();
sync(document.getElementById(x.parentNode.dataset.for));
});
});
field.addEventListener('keydown', function (e) {
if (e.key === 'Backspace') {
var last = chips.querySelector('.mc__chip:last-child');
if (last && last.dataset.for) sync(document.getElementById(last.dataset.for));
e.preventDefault();
} else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
at = Math.max(0, Math.min(at + (e.key === 'ArrowDown' ? 1 : -1), opts.length - 1));
opts.forEach(function (o, k) { o.classList.toggle('is-at', k === at); });
field.setAttribute('aria-activedescendant', opts[at].id);
e.preventDefault();
} else if (e.key === 'Enter' || e.key === ' ') { sync(opts[at]); e.preventDefault(); }
else if (e.key === 'Escape') { root.classList.remove('is-open'); field.blur(); }
});import { useRef, useState } from "react";
import type { CSSProperties } from "react";
import styles from "./MultiChipSelect.module.scss";
export type MultiChipSelectProps = {
label?: string;
options?: string[];
initial?: string[];
removeLabel?: (name: string) => string;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
type KeyEvt = { key: string; preventDefault: () => void };
type ChangeEvt = { target: { value: string } };
type ClickEvt = { stopPropagation: () => void };
const DEFAULT_OPTIONS = ["React", "SCSS", "Vite"];
const DEFAULT_INITIAL = ["React", "SCSS"];
function XIcon() {
return (
<svg viewBox="0 0 256 256" width="10" height="10">
<g fill="currentColor">
<path d="M216 56v144a16 16 0 0 1-16 16H56a16 16 0 0 1-16-16V56a16 16 0 0 1 16-16h144a16 16 0 0 1 16 16" opacity=".2" />
<path d="M205.66 194.34a8 8 0 0 1-11.32 11.32L128 139.31l-66.34 66.35a8 8 0 0 1-11.32-11.32L116.69 128L50.34 61.66a8 8 0 0 1 11.32-11.32L128 116.69l66.34-66.35a8 8 0 0 1 11.32 11.32L139.31 128Z" />
</g>
</svg>
);
}
export default function MultiChipSelect({
label = "Tech stack",
options = DEFAULT_OPTIONS,
initial = DEFAULT_INITIAL,
removeLabel = (name: string) => `Remove ${name}`,
duration = 220,
easing = "cubic-bezier(.2,1.4,.4,1)",
color = "#2f6df6",
}: MultiChipSelectProps) {
const [open, setOpen] = useState(true);
const [chips, setChips] = useState<string[]>(initial);
const [at, setAt] = useState(0);
const fieldRef = useRef<HTMLDivElement>(null);
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
function toggle(name: string) {
setChips((cur) => (cur.includes(name) ? cur.filter((c) => c !== name) : [...cur, name]));
}
return (
<div className={`${styles.mc} ${open ? styles.isOpen : ""}`} style={vars}>
<span className={styles.label} id="mc-label">{label}</span>
<div
ref={fieldRef}
id="mc-field"
className={styles.field}
role="combobox"
tabIndex={0}
aria-haspopup="listbox"
aria-expanded={open}
aria-controls="mc-list"
aria-labelledby="mc-label"
aria-activedescendant={`mc-o${at}`}
onClick={() => setOpen(true)}
onKeyDown={(e: KeyEvt) => {
if (e.key === "Backspace") {
setChips((cur) => cur.slice(0, -1));
e.preventDefault();
} else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
setAt((a) => Math.max(0, Math.min(a + (e.key === "ArrowDown" ? 1 : -1), options.length - 1)));
setOpen(true);
e.preventDefault();
} else if (e.key === "Enter" || e.key === " ") {
toggle(options[at]);
e.preventDefault();
} else if (e.key === "Escape") {
setOpen(false);
fieldRef.current?.blur();
}
}}
>
<span className={styles.chips} id="mc-chips">
{chips.map((c) => (
<span key={c} className={styles.chip}>
{c}
<button
type="button"
className={styles.x}
aria-label={removeLabel(c)}
onClick={(e: ClickEvt) => {
e.stopPropagation();
toggle(c);
}}
>
<XIcon />
</button>
</span>
))}
</span>
<span className={styles.caret} aria-hidden="true">
<svg viewBox="0 0 256 256" width="12" height="12">
<g fill="currentColor">
<path d="m208 96l-80 80l-80-80Z" opacity=".2" />
<path d="M215.39 92.94A8 8 0 0 0 208 88H48a8 8 0 0 0-5.66 13.66l80 80a8 8 0 0 0 11.32 0l80-80a8 8 0 0 0 1.73-8.72M128 164.69L67.31 104h121.38Z" />
</g>
</svg>
</span>
</div>
<ul
id="mc-list"
className={styles.list}
role="listbox"
aria-multiselectable="true"
aria-labelledby="mc-label"
>
{options.map((o, i) => {
const on = chips.includes(o);
return (
<li
key={o}
id={`mc-o${i}`}
className={`${styles.opt} ${on ? styles.isOn : ""} ${i === at ? styles.isAt : ""}`}
role="option"
aria-selected={on}
onMouseMove={() => setAt(i)}
onClick={() => {
setAt(i);
toggle(o);
fieldRef.current?.focus({ preventScroll: true });
}}
>
{o}
<span className={styles.tick} aria-hidden="true">
<svg viewBox="0 0 256 256" width="13" height="13">
<g fill="currentColor">
<path d="M224 128a96 96 0 1 1-96-96a96 96 0 0 1 96 96" opacity=".2" />
<path d="M173.66 98.34a8 8 0 0 1 0 11.32l-56 56a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L112 148.69l50.34-50.35a8 8 0 0 1 11.32 0M232 128A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88" />
</g>
</svg>
</span>
</li>
);
})}
</ul>
</div>
);
}05 Multi-select chip tokens — Measured area 0.526% · moving frames 8/23Original by GODRICH · SCSS and React ship in the zip · 9 Select Dropdown Design Patterns That Really Open
The post this demo lives in
9 Select Dropdown Design Patterns That Really OpenA hand-built select dropdown design replaces the gray box the browser draws for <select> with a button and a list of you See all demos in this post


