List
Scrollable list panel for pickers, menus, and custom overlays. Compose rows with catnip-list-item; optional catnip-divider between rows for visual grouping.
Overview
catnip-list is a presentational primitive: it does not own selection state or an items prop. The parent loops catnip-list-item children (or places them statically), binds selected, active, disabled, and intent, and handles click on each row.
Set selection-appearance once on the list so every row uses the same selection chrome (default stroke, checkmark, or checkbox).
| Piece | Role |
|---|---|
catnip-list | Panel chrome, scrollable body, header / footer slots |
catnip-list-item | One interactive row (left, default, right slots). Labels wrap; unbreakable strings break instead of stretching the panel. |
catnip-divider | Optional visual separator between direct children of the list |
catnip-dropdown still uses an internal list implementation for its option panel; you do not need catnip-list inside a dropdown unless you are building a custom overlay.
Live example
Guidelines
When to use
| Pattern | Use |
|---|---|
catnip-list + catnip-list-item | Custom overlays, standalone pickers, or menus where you own layout and state |
catnip-dropdown | Labelled field with trigger, filter, and value binding |
Internal list (Vue only) | Inside Catnip package development; prefer public CEs in apps |
Composition rules
- Place
catnip-list-item(and optionalcatnip-divider) as direct children ofcatnip-list. Useslot="header"/slot="footer"only on non-row content. - Set
selection-appearanceon the list once; bindselectedper row. - Parent owns the loop (
v-foror static markup), click handlers, and any filter logic inheader.
Selection appearance
| Value | Use |
|---|---|
default | Single-select with side stroke + primary fill |
checkmark | Single-select with a tick on the right |
checkbox | Multi-select; checkbox on the left of every row |
State styling
- Unselected rows have a transparent background. Neutral rows use the neutral hover surface; danger rows use the danger subtle hover surface.
- Disabled rows use the disabled foreground colour and no background. Selected
defaultandcheckmarkrows retain their disabled selection fill. - Selected
defaultandcheckmarkdanger rows retain their danger selection fill;checkboxrows remain transparent until hover. - Disabled styling takes precedence when
disabledandintent="danger"are combined.
Dividers
Insert catnip-divider between items for visual groups (for example destructive actions):
<catnip-list list-role="menu" list-aria-label="Actions">
<catnip-list-item>Rename</catnip-list-item>
<catnip-divider size="s"></catnip-divider>
<catnip-list-item intent="danger">Delete</catnip-list-item>
</catnip-list>Keep dividers decorative (default) inside listbox/menu panels; see Accessibility for how parent keyboard logic treats them.
Vue binding
<catnip-list selection-appearance="checkmark" list-role="listbox" list-aria-label="Services" .maxHeight="280">
<catnip-list-item
v-for="item in items"
:key="item.value"
:list-item-id="'opt-' + item.value"
.selected="selected === item.value"
.active="active === item.value"
@click="onSelect(item.value)"
>
{{ item.label }}
</catnip-list-item>
</catnip-list>Use leading-dot props for booleans and objects. Listen for @click and read event.detail[0].