# @salmonui/dropdowns/listbox API reference

> 25 exported symbols of @salmonui/dropdowns/listbox: 1 component, 2 functions, 13 interfaces, 8 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/dropdowns/listbox

```ts
import { … } from '@salmonui/dropdowns/listbox';
```

## Components

### Listbox

Kind: component

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/Listbox

```ts
function Listbox<T>(props: ListboxProps<T>): ReactNode;
```

A persistent list of options (WAI-ARIA APG listbox) with single or
multiple selection. `ref` receives the `role="listbox"` element.

## Functions

### moveItems

Kind: function

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/moveItems

```ts
function moveItems<T>(source: readonly T[], target: readonly T[], values: Iterable<ListboxKey>, index?: number, getItemValue?: (item: T) => ListboxKey): [
    nextSource: T[],
    nextTarget: T[]
];
```

Moves the items whose values are in `values` from `source` to `target`,
inserted at `index` of `target` (default: the end), in `source` order.
Returns `[nextSource, nextTarget]`. When `source === target` the items
move within the list: `index` is the insertion index in the current list
(as a drop position), and both results are the same new array.

### reorderItems

Kind: function

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/reorderItems

```ts
function reorderItems<T>(list: readonly T[], values: Iterable<ListboxKey>, delta: number, getItemValue?: (item: T) => ListboxKey): T[];
```

Moves the items whose values are in `values` by `delta` positions
(negative: up), keeping their relative order; items stop at the ends of
the list (a block that reaches an end keeps its shape).

## Interfaces

### ListboxBaseProps

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxBaseProps

```ts
interface ListboxBaseProps<T> extends ListboxDomProps {
    readonly data: readonly T[] | ListboxDataSource<T>;
    readonly getItemValue?: (item: T) => ListboxKey;
    readonly getItemLabel?: (item: T) => string;
    readonly getItemGroup?: (item: T) => string | null | undefined;
    readonly getItemIcon?: (item: T) => ReactNode;
    readonly isItemDisabled?: (item: T) => boolean;
    readonly layout?: 'list' | 'grid';
    readonly columns?: number;
    readonly indicator?: 'check' | 'checkbox';
    readonly indicatorPosition?: 'start' | 'end';
    readonly showSelectAll?: boolean;
    readonly maxSelected?: number;
    readonly searchable?: boolean;
    readonly searchOperator?: ListboxSearchOperator<T>;
    readonly matchCase?: boolean;
    readonly ignoreAccents?: boolean;
    readonly searchPlaceholder?: string;
    readonly onSearchChange?: (event: {
        readonly text: string;
    }) => void;
    readonly debounce?: number;
    readonly minSearchLength?: number;
    readonly maxResults?: number;
    readonly query?: ListboxQuery;
    readonly searchFields?: readonly string[];
    readonly virtualization?: boolean;
    readonly maxVisibleItems?: number;
    readonly highlightMatches?: boolean;
    readonly renderItem?: (state: ListboxItemState<T>) => ReactNode;
    readonly renderGroupHeader?: (state: {
        readonly group: string;
    }) => ReactNode;
    readonly renderEmpty?: (state: {
        readonly reason: 'noData' | 'noMatch';
    }) => ReactNode;
    readonly renderError?: (state: {
        readonly error: unknown;
        readonly retry: () => void;
    }) => ReactNode;
    readonly renderLoading?: () => ReactNode;
    readonly getItemProps?: (item: T, state: {
        readonly selected: boolean;
        readonly disabled: boolean;
    }) => ListboxItemProps | undefined;
    readonly onLoadError?: (error: unknown) => void;
    readonly loading?: boolean;
    readonly name?: string;
    readonly required?: boolean;
    readonly form?: string;
    readonly disabled?: boolean;
    readonly readOnly?: boolean;
    readonly reorderable?: boolean;
    readonly onReorder?: (event: ListboxReorderEvent<T>) => void;
    readonly dragGroup?: string;
    readonly onItemDragStart?: (event: ListboxDragStartEvent<T>) => void;
    readonly onItemDrag?: (event: ListboxDragEvent) => void;
    readonly onItemDrop?: (event: ListboxDropEvent<T>) => void;
    readonly localeText?: Partial<ListboxLocaleText>;
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly classNames?: Partial<Record<ListboxPart, string>>;
    readonly styles?: Partial<Record<ListboxPart, CSSProperties>>;
    readonly ref?: Ref<HTMLDivElement>;
}
```

Props shared by single and multiple `Listbox`.

Members (51):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `data` | `readonly data: readonly T[] \| ListboxDataSource<T>;` |  | Items (an array, never copied), or a remote `@salmonui/data` source. |
| `getItemValue` | `readonly getItemValue?: (item: T) => ListboxKey;` | optional | Default: a primitive is its own value; objects read `value`. Keep accessors stable (module scope or `useCallback`). |
| `getItemLabel` | `readonly getItemLabel?: (item: T) => string;` | optional | Default: a primitive is its own label; objects read `label`. |
| `getItemGroup` | `readonly getItemGroup?: (item: T) => string \| null \| undefined;` | optional | Default: objects read `group`. Items of one group must be contiguous. |
| `getItemIcon` | `readonly getItemIcon?: (item: T) => ReactNode;` | optional |  |
| `isItemDisabled` | `readonly isItemDisabled?: (item: T) => boolean;` | optional | Default: objects read `disabled`. Evaluated on render (reactive). |
| `layout` | `readonly layout?: 'list' \| 'grid';` | optional | `'grid'`: the APG Grid pattern (`role="grid"`, rows of `columns` cells) for items holding their own controls, and tile galleries. Tab and the arrow keys reach the active cell's controls; selection does not follow focus. No group headers or reordering. Default `'list'`. |
| `columns` | `readonly columns?: number;` | optional | Items per row with `layout="grid"`. Default 1. |
| `indicator` | `readonly indicator?: 'check' \| 'checkbox';` | optional | Marker of selected options. Default `'check'`. |
| `indicatorPosition` | `readonly indicatorPosition?: 'start' \| 'end';` | optional | Side of the marker: `'start'` (default) or `'end'`, logical so it mirrors in RTL. |
| `showSelectAll` | `readonly showSelectAll?: boolean;` | optional | Tri-state "select all" checkbox above the list (`multiple`). |
| `maxSelected` | `readonly maxSelected?: number;` | optional | Most values `multiple` may hold; further options become unavailable. |
| `searchable` | `readonly searchable?: boolean;` | optional | A search field above the list filters it. |
| `searchOperator` | `readonly searchOperator?: ListboxSearchOperator<T>;` | optional | Default `'startsWith'`. |
| `matchCase` | `readonly matchCase?: boolean;` | optional |  |
| `ignoreAccents` | `readonly ignoreAccents?: boolean;` | optional |  |
| `searchPlaceholder` | `readonly searchPlaceholder?: string;` | optional |  |
| `onSearchChange` | `readonly onSearchChange?: (event: {     readonly text: string; }) => void;` | optional | Fires when the search text changes. |
| `debounce` | `readonly debounce?: number;` | optional | Remote search debounce in ms. Default 300; local data filters on every keystroke. |
| `minSearchLength` | `readonly minSearchLength?: number;` | optional | Remote: searches shorter than this send no request. |
| `maxResults` | `readonly maxResults?: number;` | optional | Caps the number of listed items. |
| `query` | `readonly query?: ListboxQuery;` | optional | Remote: base filters and sort merged into every read. |
| `searchFields` | `readonly searchFields?: readonly string[];` | optional | Remote: fields the search text runs over. Default `['label']`. |
| `virtualization` | `readonly virtualization?: boolean;` | optional | Virtual list (fixed item height). Default: on above 100 items. |
| `maxVisibleItems` | `readonly maxVisibleItems?: number;` | optional | List height in items. Default 8. |
| `highlightMatches` | `readonly highlightMatches?: boolean;` | optional | Mark the search text in labels (`<mark>`). |
| `renderItem` | `readonly renderItem?: (state: ListboxItemState<T>) => ReactNode;` | optional |  |
| `renderGroupHeader` | `readonly renderGroupHeader?: (state: {     readonly group: string; }) => ReactNode;` | optional |  |
| `renderEmpty` | `readonly renderEmpty?: (state: {     readonly reason: 'noData' \| 'noMatch'; }) => ReactNode;` | optional |  |
| `renderError` | `readonly renderError?: (state: {     readonly error: unknown;     readonly retry: () => void; }) => ReactNode;` | optional |  |
| `renderLoading` | `readonly renderLoading?: () => ReactNode;` | optional |  |
| `getItemProps` | `readonly getItemProps?: (item: T, state: {     readonly selected: boolean;     readonly disabled: boolean; }) => ListboxItemProps \| undefined;` | optional |  |
| `onLoadError` | `readonly onLoadError?: (error: unknown) => void;` | optional | Remote: called when a read fails. |
| `loading` | `readonly loading?: boolean;` | optional | Forces the busy state (`aria-busy`); set automatically while a remote read is pending. |
| `name` | `readonly name?: string;` | optional | Form field name: renders a hidden native `<select>` that submits the value. |
| `required` | `readonly required?: boolean;` | optional |  |
| `form` | `readonly form?: string;` | optional |  |
| `disabled` | `readonly disabled?: boolean;` | optional |  |
| `readOnly` | `readonly readOnly?: boolean;` | optional |  |
| `reorderable` | `readonly reorderable?: boolean;` | optional | Alt+Up / Alt+Down and drag within the list fire `onReorder`. |
| `onReorder` | `readonly onReorder?: (event: ListboxReorderEvent<T>) => void;` | optional |  |
| `dragGroup` | `readonly dragGroup?: string;` | optional | Lists with the same group accept each other's items by drag and drop. |
| `onItemDragStart` | `readonly onItemDragStart?: (event: ListboxDragStartEvent<T>) => void;` | optional |  |
| `onItemDrag` | `readonly onItemDrag?: (event: ListboxDragEvent) => void;` | optional |  |
| `onItemDrop` | `readonly onItemDrop?: (event: ListboxDropEvent<T>) => void;` | optional |  |
| `localeText` | `readonly localeText?: Partial<ListboxLocaleText>;` | optional |  |
| `className` | `readonly className?: string;` | optional |  |
| `style` | `readonly style?: CSSProperties;` | optional |  |
| `classNames` | `readonly classNames?: Partial<Record<ListboxPart, string>>;` | optional |  |
| `styles` | `readonly styles?: Partial<Record<ListboxPart, CSSProperties>>;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement>;` | optional | The focusable `role="listbox"` (or `role="grid"` with `layout="grid"`) element. |

### ListboxDataSource

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxDataSource

```ts
interface ListboxDataSource<T> {
    read(request: DataSourceRequest): DataSourceResult<T> | Promise<DataSourceResult<T>>;
}
```

A remote list: any `@salmonui/data` source (`createJsonDataSource`,
`createOfflineDataSource`, ...). Reads use the search text, a `range`, and
`totalRowCount`.

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `read` | `read(request: DataSourceRequest): DataSourceResult<T> \| Promise<DataSourceResult<T>>;` |  |  |

### ListboxDragEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxDragEvent

```ts
interface ListboxDragEvent {
    readonly values: readonly ListboxKey[];
    readonly clientX: number;
    readonly clientY: number;
    readonly overGroup: string | null;
    readonly toIndex: number | null;
}
```

`onItemDrag` argument, at most once per animation frame.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `values` | `readonly values: readonly ListboxKey[];` |  |  |
| `clientX` | `readonly clientX: number;` |  |  |
| `clientY` | `readonly clientY: number;` |  |  |
| `overGroup` | `readonly overGroup: string \| null;` |  | `dragGroup` of the list under the pointer, or null outside any accepting list. |
| `toIndex` | `readonly toIndex: number \| null;` |  |  |

### ListboxDragStartEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxDragStartEvent

```ts
interface ListboxDragStartEvent<T> {
    readonly values: readonly ListboxKey[];
    readonly items: readonly T[];
    readonly source: ListboxEventSource;
    preventDefault(): void;
    readonly defaultPrevented: boolean;
}
```

`onItemDragStart` argument; `preventDefault()` cancels the drag.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `values` | `readonly values: readonly ListboxKey[];` |  |  |
| `items` | `readonly items: readonly T[];` |  |  |
| `source` | `readonly source: ListboxEventSource;` |  |  |
| `preventDefault` | `preventDefault(): void;` |  |  |
| `defaultPrevented` | `readonly defaultPrevented: boolean;` |  |  |

### ListboxDropEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxDropEvent

```ts
interface ListboxDropEvent<T> {
    readonly values: readonly ListboxKey[];
    readonly items: readonly T[];
    readonly fromList: string;
    readonly dragGroup: string;
    readonly toIndex: number;
    readonly source: ListboxEventSource;
}
```

`onItemDrop` argument, fired on the receiving list.

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `values` | `readonly values: readonly ListboxKey[];` |  |  |
| `items` | `readonly items: readonly T[];` |  | The dragged items, from the source list's `data`. |
| `fromList` | `readonly fromList: string;` |  | `id` of the source list (the `id` prop, or a generated id). |
| `dragGroup` | `readonly dragGroup: string;` |  |  |
| `toIndex` | `readonly toIndex: number;` |  | Insertion index in this list's `data`. |
| `source` | `readonly source: ListboxEventSource;` |  |  |

### ListboxItemProps

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxItemProps

```ts
interface ListboxItemProps {
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly title?: string;
    readonly [dataAttribute: `data-${string}`]: string | number | boolean | undefined;
}
```

Pure per-item props from `getItemProps` (rendered items only).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `className` | `readonly className?: string;` | optional |  |
| `style` | `readonly style?: CSSProperties;` | optional |  |
| `title` | `readonly title?: string;` | optional |  |

### ListboxItemState

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxItemState

```ts
interface ListboxItemState<T> {
    readonly item: T;
    readonly value: ListboxKey;
    readonly label: string;
    readonly selected: boolean;
    readonly active: boolean;
    readonly disabled: boolean;
    readonly matches: readonly ListboxMatchRange[];
}
```

`renderItem` argument.

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `item` | `readonly item: T;` |  |  |
| `value` | `readonly value: ListboxKey;` |  |  |
| `label` | `readonly label: string;` |  |  |
| `selected` | `readonly selected: boolean;` |  |  |
| `active` | `readonly active: boolean;` |  |  |
| `disabled` | `readonly disabled: boolean;` |  |  |
| `matches` | `readonly matches: readonly ListboxMatchRange[];` |  | Highlight ranges of the search text in `label` (with `highlightMatches`). |

### ListboxLocaleText

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxLocaleText

```ts
interface ListboxLocaleText {
    readonly noData: ListboxLocaleMessage;
    readonly noResults: ListboxLocaleMessage;
    readonly loading: ListboxLocaleMessage;
    readonly loadError: ListboxLocaleMessage;
    readonly retry: ListboxLocaleMessage;
    readonly searchLabel: ListboxLocaleMessage;
    readonly selectAll: ListboxLocaleMessage;
    readonly resultCount: ListboxLocaleMessage;
    readonly selectionLimit: ListboxLocaleMessage;
    readonly moved: ListboxLocaleMessage;
}
```

Static texts of `Listbox`. Plain JSON, safe to pass from a server component.

Members (10):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `noData` | `readonly noData: ListboxLocaleMessage;` |  |  |
| `noResults` | `readonly noResults: ListboxLocaleMessage;` |  |  |
| `loading` | `readonly loading: ListboxLocaleMessage;` |  |  |
| `loadError` | `readonly loadError: ListboxLocaleMessage;` |  |  |
| `retry` | `readonly retry: ListboxLocaleMessage;` |  |  |
| `searchLabel` | `readonly searchLabel: ListboxLocaleMessage;` |  |  |
| `selectAll` | `readonly selectAll: ListboxLocaleMessage;` |  |  |
| `resultCount` | `readonly resultCount: ListboxLocaleMessage;` |  | `{count}`: matches after a search (live region). |
| `selectionLimit` | `readonly selectionLimit: ListboxLocaleMessage;` |  | `{max}`: announced when `maxSelected` is reached. |
| `moved` | `readonly moved: ListboxLocaleMessage;` |  | `{label}`, `{position}`, `{count}`: announced after a keyboard reorder. |

### ListboxMultipleProps

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxMultipleProps

```ts
interface ListboxMultipleProps<T> extends ListboxBaseProps<T> {
    readonly multiple: true;
    readonly value?: readonly ListboxKey[];
    readonly defaultValue?: readonly ListboxKey[];
    readonly onValueChange?: (value: readonly ListboxKey[], event: ListboxValueChangeEvent<T>) => void;
}
```

Multiple selection.

Members (55):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `multiple` | `readonly multiple: true;` |  |  |
| `value` | `readonly value?: readonly ListboxKey[];` | optional |  |
| `defaultValue` | `readonly defaultValue?: readonly ListboxKey[];` | optional |  |
| `onValueChange` | `readonly onValueChange?: (value: readonly ListboxKey[], event: ListboxValueChangeEvent<T>) => void;` | optional |  |
| `data` | `data: ListboxDataSource<T> \| readonly T[];` | inherited | Items (an array, never copied), or a remote `@salmonui/data` source. |
| `getItemValue` | `getItemValue?: ((item: T) => ListboxKey);` | optional, inherited | Default: a primitive is its own value; objects read `value`. Keep accessors stable (module scope or `useCallback`). |
| `getItemLabel` | `getItemLabel?: ((item: T) => string);` | optional, inherited | Default: a primitive is its own label; objects read `label`. |
| `getItemGroup` | `getItemGroup?: ((item: T) => string \| null \| undefined);` | optional, inherited | Default: objects read `group`. Items of one group must be contiguous. |
| `getItemIcon` | `getItemIcon?: ((item: T) => ReactNode);` | optional, inherited |  |
| `isItemDisabled` | `isItemDisabled?: ((item: T) => boolean);` | optional, inherited | Default: objects read `disabled`. Evaluated on render (reactive). |
| `layout` | `layout?: "grid" \| "list";` | optional, inherited | `'grid'`: the APG Grid pattern (`role="grid"`, rows of `columns` cells) for items holding their own controls, and tile galleries. Tab and the arrow keys reach the active cell's controls; selection does not follow focus. No group headers or reordering. Default `'list'`. |
| `columns` | `columns?: number;` | optional, inherited | Items per row with `layout="grid"`. Default 1. |
| `indicator` | `indicator?: "check" \| "checkbox";` | optional, inherited | Marker of selected options. Default `'check'`. |
| `indicatorPosition` | `indicatorPosition?: "end" \| "start";` | optional, inherited | Side of the marker: `'start'` (default) or `'end'`, logical so it mirrors in RTL. |
| `showSelectAll` | `showSelectAll?: boolean;` | optional, inherited | Tri-state "select all" checkbox above the list (`multiple`). |
| `maxSelected` | `maxSelected?: number;` | optional, inherited | Most values `multiple` may hold; further options become unavailable. |
| `searchable` | `searchable?: boolean;` | optional, inherited | A search field above the list filters it. |
| `searchOperator` | `searchOperator?: ListboxSearchOperator<T>;` | optional, inherited | Default `'startsWith'`. |
| `matchCase` | `matchCase?: boolean;` | optional, inherited |  |
| `ignoreAccents` | `ignoreAccents?: boolean;` | optional, inherited |  |
| `searchPlaceholder` | `searchPlaceholder?: string;` | optional, inherited |  |
| `onSearchChange` | `onSearchChange?: ((event: { readonly text: string; }) => void);` | optional, inherited | Fires when the search text changes. |
| `debounce` | `debounce?: number;` | optional, inherited | Remote search debounce in ms. Default 300; local data filters on every keystroke. |
| `minSearchLength` | `minSearchLength?: number;` | optional, inherited | Remote: searches shorter than this send no request. |
| `maxResults` | `maxResults?: number;` | optional, inherited | Caps the number of listed items. |
| `query` | `query?: ListboxQuery;` | optional, inherited | Remote: base filters and sort merged into every read. |
| `searchFields` | `searchFields?: readonly string[];` | optional, inherited | Remote: fields the search text runs over. Default `['label']`. |
| `virtualization` | `virtualization?: boolean;` | optional, inherited | Virtual list (fixed item height). Default: on above 100 items. |
| `maxVisibleItems` | `maxVisibleItems?: number;` | optional, inherited | List height in items. Default 8. |
| `highlightMatches` | `highlightMatches?: boolean;` | optional, inherited | Mark the search text in labels (`<mark>`). |
| `renderItem` | `renderItem?: ((state: ListboxItemState<T>) => ReactNode);` | optional, inherited |  |
| `renderGroupHeader` | `renderGroupHeader?: ((state: { readonly group: string; }) => ReactNode);` | optional, inherited |  |
| `renderEmpty` | `renderEmpty?: ((state: { readonly reason: "noData" \| "noMatch"; }) => ReactNode);` | optional, inherited |  |
| `renderError` | `renderError?: ((state: { readonly error: unknown; readonly retry: () => void; }) => ReactNode);` | optional, inherited |  |
| `renderLoading` | `renderLoading?: (() => ReactNode);` | optional, inherited |  |
| `getItemProps` | `getItemProps?: ((item: T, state: { readonly selected: boolean; readonly disabled: boolean; }) => ListboxItemProps \| undefined);` | optional, inherited |  |
| `onLoadError` | `onLoadError?: ((error: unknown) => void);` | optional, inherited | Remote: called when a read fails. |
| `loading` | `loading?: boolean;` | optional, inherited | Forces the busy state (`aria-busy`); set automatically while a remote read is pending. |
| `name` | `name?: string;` | optional, inherited | Form field name: renders a hidden native `<select>` that submits the value. |
| `required` | `required?: boolean;` | optional, inherited |  |
| `form` | `form?: string;` | optional, inherited |  |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `readOnly` | `readOnly?: boolean;` | optional, inherited |  |
| `reorderable` | `reorderable?: boolean;` | optional, inherited | Alt+Up / Alt+Down and drag within the list fire `onReorder`. |
| `onReorder` | `onReorder?: ((event: ListboxReorderEvent<T>) => void);` | optional, inherited |  |
| `dragGroup` | `dragGroup?: string;` | optional, inherited | Lists with the same group accept each other's items by drag and drop. |
| `onItemDragStart` | `onItemDragStart?: ((event: ListboxDragStartEvent<T>) => void);` | optional, inherited |  |
| `onItemDrag` | `onItemDrag?: ((event: ListboxDragEvent) => void);` | optional, inherited |  |
| `onItemDrop` | `onItemDrop?: ((event: ListboxDropEvent<T>) => void);` | optional, inherited |  |
| `localeText` | `localeText?: Partial<ListboxLocaleText>;` | optional, inherited |  |
| `className` | `className?: string;` | optional, inherited |  |
| `style` | `style?: CSSProperties;` | optional, inherited |  |
| `classNames` | `classNames?: Partial<Record<ListboxPart, string>>;` | optional, inherited |  |
| `styles` | `styles?: Partial<Record<ListboxPart, CSSProperties>>;` | optional, inherited |  |
| `ref` | `ref?: Ref<HTMLDivElement>;` | optional, inherited | The focusable `role="listbox"` (or `role="grid"` with `layout="grid"`) element. |

### ListboxQuery

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxQuery

```ts
interface ListboxQuery {
    readonly filters?: readonly FilterEntry[];
    readonly sorting?: readonly SortDescriptor[];
}
```

Base query merged into every remote read.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `filters` | `readonly filters?: readonly FilterEntry[];` | optional |  |
| `sorting` | `readonly sorting?: readonly SortDescriptor[];` | optional |  |

### ListboxReorderEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxReorderEvent

```ts
interface ListboxReorderEvent<T> {
    readonly values: readonly ListboxKey[];
    readonly items: readonly T[];
    readonly toIndex: number;
    readonly delta: number | null;
    readonly source: ListboxEventSource;
}
```

`onReorder` argument: the application applies it to its `data` (`reorderItems` / `moveItems`).

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `values` | `readonly values: readonly ListboxKey[];` |  |  |
| `items` | `readonly items: readonly T[];` |  |  |
| `toIndex` | `readonly toIndex: number;` |  | Insertion index in the current `data` (before the moved items are removed), as `moveItems` takes it. |
| `delta` | `readonly delta: number \| null;` |  | `-1` / `1` for a keyboard step (Alt+Up / Alt+Down), as `reorderItems` takes it. |
| `source` | `readonly source: ListboxEventSource;` |  |  |

### ListboxSingleProps

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxSingleProps

```ts
interface ListboxSingleProps<T> extends ListboxBaseProps<T> {
    readonly multiple?: false;
    readonly value?: ListboxKey | null;
    readonly defaultValue?: ListboxKey | null;
    readonly onValueChange?: (value: ListboxKey | null, event: ListboxValueChangeEvent<T>) => void;
}
```

Single selection (default).

Members (55):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `multiple` | `readonly multiple?: false;` | optional |  |
| `value` | `readonly value?: ListboxKey \| null;` | optional |  |
| `defaultValue` | `readonly defaultValue?: ListboxKey \| null;` | optional |  |
| `onValueChange` | `readonly onValueChange?: (value: ListboxKey \| null, event: ListboxValueChangeEvent<T>) => void;` | optional |  |
| `data` | `data: ListboxDataSource<T> \| readonly T[];` | inherited | Items (an array, never copied), or a remote `@salmonui/data` source. |
| `getItemValue` | `getItemValue?: ((item: T) => ListboxKey);` | optional, inherited | Default: a primitive is its own value; objects read `value`. Keep accessors stable (module scope or `useCallback`). |
| `getItemLabel` | `getItemLabel?: ((item: T) => string);` | optional, inherited | Default: a primitive is its own label; objects read `label`. |
| `getItemGroup` | `getItemGroup?: ((item: T) => string \| null \| undefined);` | optional, inherited | Default: objects read `group`. Items of one group must be contiguous. |
| `getItemIcon` | `getItemIcon?: ((item: T) => ReactNode);` | optional, inherited |  |
| `isItemDisabled` | `isItemDisabled?: ((item: T) => boolean);` | optional, inherited | Default: objects read `disabled`. Evaluated on render (reactive). |
| `layout` | `layout?: "grid" \| "list";` | optional, inherited | `'grid'`: the APG Grid pattern (`role="grid"`, rows of `columns` cells) for items holding their own controls, and tile galleries. Tab and the arrow keys reach the active cell's controls; selection does not follow focus. No group headers or reordering. Default `'list'`. |
| `columns` | `columns?: number;` | optional, inherited | Items per row with `layout="grid"`. Default 1. |
| `indicator` | `indicator?: "check" \| "checkbox";` | optional, inherited | Marker of selected options. Default `'check'`. |
| `indicatorPosition` | `indicatorPosition?: "end" \| "start";` | optional, inherited | Side of the marker: `'start'` (default) or `'end'`, logical so it mirrors in RTL. |
| `showSelectAll` | `showSelectAll?: boolean;` | optional, inherited | Tri-state "select all" checkbox above the list (`multiple`). |
| `maxSelected` | `maxSelected?: number;` | optional, inherited | Most values `multiple` may hold; further options become unavailable. |
| `searchable` | `searchable?: boolean;` | optional, inherited | A search field above the list filters it. |
| `searchOperator` | `searchOperator?: ListboxSearchOperator<T>;` | optional, inherited | Default `'startsWith'`. |
| `matchCase` | `matchCase?: boolean;` | optional, inherited |  |
| `ignoreAccents` | `ignoreAccents?: boolean;` | optional, inherited |  |
| `searchPlaceholder` | `searchPlaceholder?: string;` | optional, inherited |  |
| `onSearchChange` | `onSearchChange?: ((event: { readonly text: string; }) => void);` | optional, inherited | Fires when the search text changes. |
| `debounce` | `debounce?: number;` | optional, inherited | Remote search debounce in ms. Default 300; local data filters on every keystroke. |
| `minSearchLength` | `minSearchLength?: number;` | optional, inherited | Remote: searches shorter than this send no request. |
| `maxResults` | `maxResults?: number;` | optional, inherited | Caps the number of listed items. |
| `query` | `query?: ListboxQuery;` | optional, inherited | Remote: base filters and sort merged into every read. |
| `searchFields` | `searchFields?: readonly string[];` | optional, inherited | Remote: fields the search text runs over. Default `['label']`. |
| `virtualization` | `virtualization?: boolean;` | optional, inherited | Virtual list (fixed item height). Default: on above 100 items. |
| `maxVisibleItems` | `maxVisibleItems?: number;` | optional, inherited | List height in items. Default 8. |
| `highlightMatches` | `highlightMatches?: boolean;` | optional, inherited | Mark the search text in labels (`<mark>`). |
| `renderItem` | `renderItem?: ((state: ListboxItemState<T>) => ReactNode);` | optional, inherited |  |
| `renderGroupHeader` | `renderGroupHeader?: ((state: { readonly group: string; }) => ReactNode);` | optional, inherited |  |
| `renderEmpty` | `renderEmpty?: ((state: { readonly reason: "noData" \| "noMatch"; }) => ReactNode);` | optional, inherited |  |
| `renderError` | `renderError?: ((state: { readonly error: unknown; readonly retry: () => void; }) => ReactNode);` | optional, inherited |  |
| `renderLoading` | `renderLoading?: (() => ReactNode);` | optional, inherited |  |
| `getItemProps` | `getItemProps?: ((item: T, state: { readonly selected: boolean; readonly disabled: boolean; }) => ListboxItemProps \| undefined);` | optional, inherited |  |
| `onLoadError` | `onLoadError?: ((error: unknown) => void);` | optional, inherited | Remote: called when a read fails. |
| `loading` | `loading?: boolean;` | optional, inherited | Forces the busy state (`aria-busy`); set automatically while a remote read is pending. |
| `name` | `name?: string;` | optional, inherited | Form field name: renders a hidden native `<select>` that submits the value. |
| `required` | `required?: boolean;` | optional, inherited |  |
| `form` | `form?: string;` | optional, inherited |  |
| `disabled` | `disabled?: boolean;` | optional, inherited |  |
| `readOnly` | `readOnly?: boolean;` | optional, inherited |  |
| `reorderable` | `reorderable?: boolean;` | optional, inherited | Alt+Up / Alt+Down and drag within the list fire `onReorder`. |
| `onReorder` | `onReorder?: ((event: ListboxReorderEvent<T>) => void);` | optional, inherited |  |
| `dragGroup` | `dragGroup?: string;` | optional, inherited | Lists with the same group accept each other's items by drag and drop. |
| `onItemDragStart` | `onItemDragStart?: ((event: ListboxDragStartEvent<T>) => void);` | optional, inherited |  |
| `onItemDrag` | `onItemDrag?: ((event: ListboxDragEvent) => void);` | optional, inherited |  |
| `onItemDrop` | `onItemDrop?: ((event: ListboxDropEvent<T>) => void);` | optional, inherited |  |
| `localeText` | `localeText?: Partial<ListboxLocaleText>;` | optional, inherited |  |
| `className` | `className?: string;` | optional, inherited |  |
| `style` | `style?: CSSProperties;` | optional, inherited |  |
| `classNames` | `classNames?: Partial<Record<ListboxPart, string>>;` | optional, inherited |  |
| `styles` | `styles?: Partial<Record<ListboxPart, CSSProperties>>;` | optional, inherited |  |
| `ref` | `ref?: Ref<HTMLDivElement>;` | optional, inherited | The focusable `role="listbox"` (or `role="grid"` with `layout="grid"`) element. |

### ListboxValueChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxValueChangeEvent

```ts
interface ListboxValueChangeEvent<T> {
    readonly reason: ListboxValueChangeReason;
    readonly source: ListboxEventSource;
    readonly items: readonly T[];
    readonly previousValue: ListboxKey | readonly ListboxKey[] | null;
}
```

Second argument of `onValueChange`: frozen, read-only.

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `reason` | `readonly reason: ListboxValueChangeReason;` |  |  |
| `source` | `readonly source: ListboxEventSource;` |  |  |
| `items` | `readonly items: readonly T[];` |  | The items of the new value that are loaded (materialized on first read). |
| `previousValue` | `readonly previousValue: ListboxKey \| readonly ListboxKey[] \| null;` |  |  |

## Types

### ListboxEventSource

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxEventSource

```ts
type ListboxEventSource = 'pointer' | 'keyboard' | 'touch' | 'api';
```

Where a change came from.

### ListboxKey

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxKey

```ts
type ListboxKey = string | number | boolean;
```

An item value: one stable, unique key per item (`getItemValue`).

### ListboxLocaleMessage

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxLocaleMessage

```ts
type ListboxLocaleMessage = string | {
    readonly [category in Intl.LDMLPluralRule]?: string;
};
```

A `{param}` template, or plural forms keyed by `Intl.PluralRules` category.

### ListboxMatchRange

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxMatchRange

```ts
type ListboxMatchRange = readonly [
    start: number,
    end: number
];
```

A `[start, end)` range of the label matched by the search text.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `0` | `0: number;` | inherited |  |
| `1` | `1: number;` | inherited |  |
| `length` | `length: 2;` | inherited |  |

### ListboxPart

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxPart

```ts
type ListboxPart = 'root' | 'search' | 'selectAll' | 'list' | 'option' | 'group' | 'groupHeader' | 'empty';
```

Part names of `classNames` / `styles`.

### ListboxProps

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxProps

```ts
type ListboxProps<T> = ListboxSingleProps<T> | ListboxMultipleProps<T>;
```

### ListboxSearchOperator

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxSearchOperator

```ts
type ListboxSearchOperator<T> = 'startsWith' | 'contains' | 'endsWith' | ((item: T, text: string) => boolean);
```

Built-in search operators, or a predicate over the item and the search text.

### ListboxValueChangeReason

Kind: type

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/ListboxValueChangeReason

```ts
type ListboxValueChangeReason = 'select' | 'deselect' | 'selectAll' | 'clear' | 'reset';
```

Why the value changed.

## Constants

### LISTBOX_DEFAULT_LOCALE_TEXT

Kind: const

Page: https://salmonui.dev/docs/reference/dropdowns/listbox/LISTBOX_DEFAULT_LOCALE_TEXT

```ts
const LISTBOX_DEFAULT_LOCALE_TEXT: ListboxLocaleText;
```
