Listbox

One option or several, chosen from a list always in view — like a native select with several rows. In a form, the value chosen, or the values.

FormsExperimental

Usage

Usage

Topping
Cheese
Basil
Onion
Mushroom
Olive

basil

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScLabel,  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';

Anatomy

The list holds options only — and groups, separators. Buttons, a search, an empty message go beside it.

import { ScListbox, ScListboxGroup, ScListboxGroupLabel, ScListboxItem, ScListboxItemIcon, ScListboxItemIndicator, ScListboxMultiple, ScListboxSeparator } from '@semantic-components/ui';
<div scListbox [formField]="form.topping">  <div scListboxGroup>    <div scListboxGroupLabel>Cheeses</div>    <div scListboxItem value="brie">      <span scListboxItemIcon><svg …></svg></span>      Brie      <span scListboxItemIndicator><svg siCheckIcon></svg></span>    </div>  </div>  <div scListboxSeparator></div></div>

Choosing

scListbox holds one value (or null); scListbox multiple an array, in the list's order. With activationautomatic — one value's default — the option under focus is chosen; with manual — several's default — Space, Enter or a click chooses. deselectable lets the chosen option be pressed off. In a form, an empty array is not empty to Signal Forms' required(): use minLength(path, 1).

Keyboard

KeyDoes
↑↓ (←→ horizontal) The previous / next option (wrapping, unless loop is off)
Home / EndThe first / last option
LettersThe next option starting with them
Space / EnterChooses (toggles, with several)
Shift + ↑Shift + ↓With several: a range
Ctrl + Shift + Home / Ctrl + Shift + EndWith several: the range to the first / last
Ctrl + AWith several: all (again: none)
Ctrl + ↑Ctrl + ↓, Ctrl + Space With several, automatic: move without choosing; toggle

Accessibility

  • A listbox (multiselectable with several), its options saying whether they are chosen; named by its field's label or aria-label.
  • One Tab stop: the chosen option (or the first). With virtualFocus, focus stays on the list, which points at the option under it.
  • Groups are named by their label; separators and icons are hidden from screen readers; the check is decorative.

Examples

Multiple

Toppings
Cheese
Basil
Onion
Mushroom
Olive

cheese, onion

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScLabel,  ScListboxItem,  ScListboxItemIndicator,  ScListboxMultiple,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';

Selection that follows focus

README.md
package.json
tsconfig.json
main.ts

1 selected

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListboxItem,  ScListboxItemIcon,  ScListboxItemIndicator,  ScListboxMultiple,} from '@semantic-components/ui';import { SiCheckIcon, SiFileIcon } from '@semantic-icons/lucide-icons';
/** activation="automatic" with several: the arrows choose — Ctrl + arrow moves without choosing, Ctrl + Space or Ctrl-click adds. */

Manual activation

Angular
Astro
Next.js
Nuxt
SvelteKit

None

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** activation="manual": the arrows only move — Space, Enter or a click chooses. Nothing chosen at first. */@Component({

Focus on the list

Angular
Astro
Next.js
Nuxt
SvelteKit

None

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** virtualFocus: focus stays on the list, the option under it pointed at (aria-activedescendant) — as a combobox does. */@Component({

Deselectable

Angular
Astro
Next.js
Nuxt
SvelteKit

astro

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** deselectable: the chosen option, pressed again, is no longer chosen. */@Component({

Groups

Fruits
Apple
Banana
Cherry
Vegetables
Carrot
Leek
Pea

banana

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListboxGroup,  ScListboxGroupLabel,  ScListboxItem,  ScListboxItemIndicator,  ScListboxMultiple,  ScListboxSeparator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';

Icons

Inbox
Sent
Drafts
Replies
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListbox,  ScListboxItem,  ScListboxItemIcon,  ScListboxItemIndicator,} from '@semantic-components/ui';import {  SiCheckIcon,  SiFileTextIcon,

Horizontal

XS
S
M
L
XL

M

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScListbox, ScListboxItem } from '@semantic-components/ui';
/** orientation="horizontal": ← → move (as the text reads); loop off — they stop at the ends; XL disabled, skipped. */@Component({  selector: 'app-horizontal-listbox-demo',  imports: [ScListbox, ScListboxItem],  template: `    <div class="grid gap-2">      <div

Disabled

Cheese
Basil
Onion
Mushroom
Olive
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScButton,  ScListboxItem,  ScListboxItemIndicator,  ScListboxMultiple,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** An option disabled (skipped by the arrows, typing and ranges), or the whole list — out of the Tab order. */

Read-only

Angular
Astro
Next.js
Nuxt
SvelteKit
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** readonly: focusable and browsable, its value kept — not changed. */@Component({

Form

Toppings
Cheese
Basil
Onion
Mushroom
Olive

One to three.

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  FormField,  FormRoot,  form,  maxLength,  minLength,} from '@angular/forms/signals';import {  ScButton,

Object values

Free$0
Pro$12
Team$30
EnterpriseContact us

pro

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** Values are any type: here the plans themselves — the same objects in the options and in the value. */@Component({

Methods

Cheese
Basil
Onion
Mushroom
Olive

None

import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScButton,  ScListboxItem,  ScListboxItemIndicator,  ScListboxMultiple,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** #list="scListbox": selectAll(), clear(), focus(). */

Scrollable

UTC−12
UTC−11
UTC−10
UTC−9
UTC−8
UTC−7
UTC−6
UTC−5
UTC−4
UTC−3
UTC−2
UTC−1
UTC
UTC+1
UTC+2
UTC+3
UTC+4
UTC+5
UTC+6
UTC+7
UTC+8
UTC+9
UTC+10
UTC+11
UTC+12
UTC+13
UTC+14
import { Component, ViewEncapsulation, signal } from '@angular/core';import {  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';
/** A long list in a set height: the option under focus — and the chosen one, at first — scrolled into view. */@Component({

RTL

الإضافة
جبن
ريحان
بصل
زيتون
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import {  ScField,  ScLabel,  ScListbox,  ScListboxItem,  ScListboxItemIndicator,} from '@semantic-components/ui';import { SiCheckIcon } from '@semantic-icons/lucide-icons';

API reference

Each part takes class, merged over its own (cn: a later class wins). The box is the style's (listbox, as its textarea); options, indicator, group labels and separators are its combobox's.

PartSelectorDescription
ScListboxdiv[scListbox] The list, one value (T | null). exportAs scListbox: clear(), focus().
ScListboxMultiplediv[scListbox][multiple] The list, several values (T[]). exportAs scListbox: selectAll(), clear(), focus().
ScListboxItem[scListboxItem] An option: [value], label, disabled. data-selected, data-active.
ScListboxItemIndicator[scListboxItemIndicator] Its content shown while the option is chosen.
ScListboxItemIcon[scListboxItemIcon] An icon at the start: hidden from screen readers; mirror.
ScListboxGroupdiv[scListboxGroup] Options together, named by their label.
ScListboxGroupLabel[scListboxGroupLabel] A group's name.
ScListboxSeparator[scListboxSeparator] A line between groups; hidden from screen readers.
InputTypeDefaultDescription
valueT | null (several: T[])null ([]) Two-way, or [formField].
activation'automatic' | 'manual'automatic (several: manual) Whether the option under focus is chosen.
deselectablebooleanfalse One value: the chosen option, pressed again, is not.
orientation'vertical' | 'horizontal''vertical' Which arrows move.
loopbooleantrue The arrows wrap.
virtualFocusbooleanfalse Focus stays on the list (aria-activedescendant).
disabled, readonly, required, invalid, touchedbooleanfalse Bound by [formField].
InputTypeDefaultDescription
valueT— Required: what choosing it gives.
labelstringits text What typing finds it by.
disabledbooleanfalse Not chosen; skipped by the arrows, typing and ranges.