Interactive
Multi select combobox
On a select with multiple the combobox shows the picks as chips. Backspace in the empty field removes the last one and the listbox stays open while you pick. Needs monsoon.js.
Needs monsoon.js. The styles work on their own, and the behavior comes from the optional interactive layer: add <script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script> or import 'monsooncss/js'. See the interactive layer.
Example
<div class="combobox max-w-sm" data-m-combobox data-m-combobox-placeholder="Add a skill">
<select class="select" multiple aria-label="Skills">
<option value="design" selected>Design</option>
<option value="research">User research</option>
<option value="frontend" selected>Frontend</option>
<option value="backend">Backend</option>
<option value="devops">DevOps</option>
<option value="writing">Technical writing</option>
<option value="data">Data analysis</option>
</select>
</div>JavaScript API
Attribute
data-m-combobox
Options
| Option | Description |
|---|---|
multiple on the select |
Methods
| Method | Description |
|---|---|
Monsoon.combobox(el).value (an array) | |
Monsoon.combobox(el).value = ["design"] |
Events
| Event | Description |
|---|---|
monsoon:change { value: [...] } | |
change on the native select |
Classes
6 classes. Click a name to copy it. Utilities on the same element always win over component defaults, so any of them can be adjusted with plain utility classes.
| Class | Type | What it does |
|---|---|---|
| Base | Base class of the multi select combobox. On a <div> in the example. Sets block display, width, padding and transform.CSS |
|
| Modifier | Modifier, combined with the combobox class. Not used in the example above. Sets flex display, alignment, gap, height, padding and text cursor, and --_line.CSS |
|
| Modifier | Modifier, combined with the combobox class. Not used in the example above. Sets contents display.CSS |
|
| Modifier | Modifier, combined with the combobox class. Not used in the example above. Sets width.CSS |
|
| Part | Part of the multi select combobox. Not used in the example above. Sets absolute position, width, height, margin, opacity and native control styling, and 15 custom properties.CSS |
|
| Part | Part of the multi select combobox. Not used in the example above. Sets inline-grid display, alignment, width, height, margin and corner radius.CSS |
Usage
The styles ship inside the same stylesheet as the utilities, and the behavior comes from the optional monsoon.js script, which enhances any element with a matching data-m attribute, including markup added later.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">
<script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script>
<!-- Multi select combobox: start from the base class, then add modifiers -->
<div class="combobox max-w-sm" data-m-combobox data-m-combobox-placeholder="Add a skill">
<select class="select" multiple aria-label="Skills">
<option value="design" selected>Design</option>
<option value="research">User research</option>
<option value="frontend" selected>Frontend</option>
<option value="backend">Backend</option>
<option value="devops">DevOps</option>
<option value="writing">Technical writing</option>
<option value="data">Data analysis</option>
</select>
</div>Theme it with --seed on any ancestor, for example style="--seed: #0d9488", and force a scheme with class="dark" or class="light" on a wrapper.
Accessibility
- Give every control a visible
labellinked withfor, or anaria-labelwhen the purpose is obvious from context. Link help and error text witharia-describedby; invalid styles use:user-invalid, so they appear only after the user interacts. - Every interactive part shows a visible focus ring with
:focus-visible, and tone colors pair with-foregroundtokens that keep text at 4.5:1 or better in light and dark mode.