Chips
Small pills that each hold one value — tags you typed, filters that are on, people you picked. Unlike a badge, you can remove, toggle or type them.
<div class="chip-group">
<span class="chip">Design</span>
<span class="chip chip-green"><i class="mi mi-check"></i>Paid</span>
<span class="chip chip-amber"><i class="mi mi-clock"></i>Pending</span>
<span class="chip"><span class="avatar">AK</span>Ana Kim</span>
<span class="chip chip-pill">Pill</span>
</div>
Removable
Add a .chip-remove button and the × just works — moey.js removes the chip, tells screen readers, and moves focus to the next chip so keyboard users don't get lost. Wrap long text in .chip-label and it cuts off with “…” instead of pushing the layout. On touch screens the × reaches further than it looks, so it's easy to hit.
<div class="chip-group">
<span class="chip">
<span class="chip-label">marketing</span>
<button class="chip-remove" aria-label="Remove marketing"></button>
</span>
<span class="chip">
<span class="chip-label">q4-launch</span>
<button class="chip-remove" aria-label="Remove q4-launch"></button>
</span>
<span class="chip">
<span class="avatar">MR</span>
<span class="chip-label">Marco Rossi</span>
<button class="chip-remove" aria-label="Remove Marco Rossi"></button>
</span>
<span class="chip chip-blue max-w-48">
<span class="chip-label">a-very-long-tag-that-would-not-fit</span>
<button class="chip-remove" aria-label="Remove long tag"></button>
</span>
</div>
Active filters
Above a table or list: what's filtered right now, each one removable, plus Clear all. .chip-key names the filter. The clear button hides itself once nothing is left. Listen for the events to update your results.
Remove a filter or clear them all.
<div class="chip-group">
<span class="chip" data-value="status"><span class="chip-key">Status</span>Paid<button class="chip-remove" aria-label="Remove filter Status: Paid"></button></span>
<span class="chip" data-value="date"><span class="chip-key">Date</span>Last 30 days<button class="chip-remove" aria-label="Remove filter Date: Last 30 days"></button></span>
<span class="chip" data-value="customer">
<span class="chip-key">Customer</span>
<span class="chip-label">Ana Kim</span>
<button class="chip-remove" aria-label="Remove filter Customer: Ana Kim"></button>
</span>
<button class="chip-clear" data-moey-chips-clear>Clear all</button>
</div>
filters.addEventListener('moey:chip-remove', (e) => e.detail.value); // 'status' — cancelable
filters.addEventListener('moey:chips-clear', (e) => e.detail.values); // ['status', 'date', 'customer']
Filter toggles
A row of choices you tap on and off — quicker than checkboxes on a phone. Off, they're neutral; on, they're solid. data-moey-chips="multiple" lets several be on, "single" keeps exactly one on, like radios.
Tap a few.
<div class="chip-group" data-moey-chips="multiple" aria-label="Status">
<button class="chip chip-pill" value="paid" aria-pressed="true">Paid</button>
<button class="chip chip-pill" value="pending">Pending</button>
<button class="chip chip-pill" value="refunded">Refunded</button>
<button class="chip chip-pill" value="failed">Failed</button>
</div>
Only one at a time.
<div class="chip-group" data-moey-chips="single" aria-label="Period">
<button class="chip" value="today">Today</button>
<button class="chip" value="7d" aria-pressed="true">7 days</button>
<button class="chip" value="30d">30 days</button>
<button class="chip" value="year">This year</button>
</div>
They take colors too — the color shows only while the chip is on.
<div class="chip-group" data-moey-chips="multiple" aria-label="Priority">
<button class="chip chip-pill chip-red" aria-pressed="true"><i class="mi mi-flame"></i>Urgent</button>
<button class="chip chip-pill chip-amber">High</button>
<button class="chip chip-pill chip-blue">Normal</button>
<button class="chip chip-pill chip-gray">Low</button>
</div>
In a form, no JavaScript
Put a checkbox or radio inside a <label class="chip">. It looks the same, the form sends it like any checkbox, and it works before moey.js loads — or without it.
Sends: channel=email&channel=push
<form class="chip-group" aria-label="Channels">
<label class="chip"><input type="checkbox" name="channel" value="email" checked>Email</label>
<label class="chip"><input type="checkbox" name="channel" value="sms">SMS</label>
<label class="chip"><input type="checkbox" name="channel" value="push" checked>Push</label>
<label class="chip"><input type="checkbox" name="channel" value="slack" disabled>Slack</label>
</form>
One row on phones
.chip-group-scroll keeps the chips on one line that scrolls sideways — the usual filter bar on a phone, so it never takes half the screen.
<div class="chip-group chip-group-scroll max-w-sm" data-moey-chips="single" aria-label="Category">
<button class="chip chip-pill" aria-pressed="true">All</button>
<button class="chip chip-pill">Electronics</button>
<button class="chip chip-pill">Home & garden</button>
<button class="chip chip-pill">Clothing</button>
<button class="chip chip-pill">Sports</button>
<button class="chip chip-pill">Books</button>
<button class="chip chip-pill">Toys</button>
</div>
Pick several
A tag input with a combobox list is a multi-select: each pick becomes a chip, and you can still type to search. Add data-moey-strict and only names from the list are accepted.
<div class="max-w-md">
<label class="form-label" for="chips-people">Assign to</label>
<input class="form-control" name="assignees" value="Ana Kim" list="chips-people-list" data-moey-tags data-moey-strict>
<datalist>
<option value="Ana Kim">Design</option>
<option value="Marco Rossi">Engineering</option>
<option value="Lena Fischer">Support</option>
<option value="Sam Okafor">Sales</option>
<option value="Priya Nair">Engineering</option>
</datalist>
</div>
Sizes
<div class="chip-group">
<span class="chip chip-sm">Small</span>
<span class="chip">Default</span>
<span class="chip chip-lg">Large</span>
<span class="chip chip-lg">
<span class="chip-label">Large, removable</span>
<button class="chip-remove" aria-label="Remove Large, removable"></button>
</span>
</div>
Colors and strengths
The same colors and strengths as buttons.
<span class="chip chip-green">Paid</span>
<span class="chip chip-green chip-subtle">Paid</span>
<span class="chip chip-green chip-vivid">Paid</span>
From code
Moey.chips(group); // ['paid'] — the values that are on
Moey.chips(group, ['paid', 'failed']); // turn exactly these on (buttons or checkbox chips)
group.addEventListener('moey:chips-change', (e) => e.detail.values);
| Class / attribute | What it does |
|---|---|
.chip | A chip (<span>, <a>, <button> or <label>) |
.chip-<color> · .chip-subtle … .chip-deep | Color and strength |
.chip-pill · .chip-sm · .chip-lg | Round ends · sizes |
.chip-label · .chip-key | Text that cuts off with “…” · the name of a filter |
.chip-remove | The × — removes its chip (event moey:chip-remove, cancelable) |
.chip-group · .chip-group-scroll | A wrapping row · one row that scrolls |
.chip-clear + data-moey-chips-clear | Removes every chip in its group (or ="#id"); event moey:chips-clear |
data-moey-chips="multiple" · "single" | On a group: its button.chips toggle; event moey:chips-change |
aria-pressed="true" · value / data-value | On a toggle chip: it's on · its value (otherwise its text) |
<label class="chip"><input type="checkbox"> | A toggle chip in a form, no JavaScript |