List
A navigable, optionally-selectable collection of items — the reference skin over the shared collection substrate.
Live demo
The plainest collection: a list of items you move a keyboard cursor across and optionally choose among. It is the reference skin over xtyle's shared collection core (roving navigation + the none/single/multi/range selection model + the item anatomy), the same core the specialized list-like components build on.
Reach for it when you want a general list and none of the specialized identities (menu, tree, tabs, combobox).
When to use
How this component composes with the rest of the set.
Props
7 props, straight from the manifest.
| Prop | Type | Default | Bindings | Description |
|---|---|---|---|---|
id of an element elsewhere on the page that names the list, for a heading the list already sits under. |
Events
What the component emits, and what rides along on event.detail. The name in the
first column is the one addEventListener takes.
| Event | Detail | Bindings | Description |
|---|---|---|---|
Appearance
Sizes
sm
Compact rows.
md
Default rows.
lg
Roomy rows.
States
active
The item under the roving keyboard cursor (focus), distinct from selection.
selected
A chosen item, marked with an accent fill and, under --selection-cue: marker, a redundant check.
disabled
A non-interactive item, skipped by roving.
Anatomy
The named parts that make up the component. A ::part() handle is reachable from your own stylesheet; the class beside it is the component's internal selector, which a shadow boundary keeps to itself.
root
The host container.
list
The list/listbox element holding the items.
item
One row: lead, content, trail, and (when actionable) actions.
lead
A leading icon.
label
The item's primary text.
trail
Trailing text: a shortcut, count, or badge.
actions
The per-item action cluster (actionable posture); each button emits a list-action event.
Tokens & coverage
What the component consumes, checked live against what the algorithm produces.
Live coverage check against the xtyle-default register
(derive(xtyleDefault, { anchors }) →
coverComponent(manifest, register)). Every token this component
consumes must be a key the algorithm produces.
--accent--accent-bg--border-normal--fg-0--fg-1--fg-2--fg-disabled--font-sans--radius-sm--selection-cue--space-1--space-2--space-3--state-hover--text-body--text-lg--text-sm--weight-medium--weight-semiboldAccessibility
Code
Single-select
A listbox where one item is chosen at a time.
<xtyle-list label="Plan" interaction="selectable" selection="single" items="Starter,Pro,Team"></xtyle-list><List label="Plan" interaction="selectable" selection="single" items="Starter,Pro,Team" /><List label="Plan" interaction="selectable" selection="single" items="Starter,Pro,Team" />Multi-select
Ctrl/Cmd-click toggles items; Shift-click (with selection="range") extends a span.
<xtyle-list label="Toppings" interaction="selectable" selection="multi" items="Cheese,Basil,Chili,Olives"></xtyle-list><List label="Toppings" interaction="selectable" selection="multi" items="Cheese,Basil,Chili,Olives" /><List label="Toppings" interaction="selectable" selection="multi" items="Cheese,Basil,Chili,Olives" />