Skip to content
API reference

components/listbox

Import
import * as api from "@fungi.computer/caps/components/listbox";
Kind Export Description
type alias ListboxItemState Intrinsic focus and selection state supplied when rendering a Listbox item.
type alias ListboxProps Props accepted by Listbox.
type alias ListboxValue Supported ListboxValue values.
function Listbox() A selection primitive with caller-owned values and intrinsic keyboard navigation.

ListboxItemStatetype alias

Section titled “ListboxItemState”
Signature
type ListboxItemState = object;

Intrinsic focus and selection state supplied when rendering a Listbox item.

Signature
active: boolean;
Signature
disabled: boolean;
Signature
selected: boolean;

ListboxPropstype alias

Section titled “ListboxProps”
Signature
type ListboxProps<T, Multiple> = object &
Omit<
HTMLAttributes<HTMLDivElement>,
"defaultValue" | "onChange" | "onSelect" | "value"
> &
Multiple extends true
? object
: Multiple extends false
? object
: | {
defaultValue?: ListboxValue;
multiple?: false;
onValueChange?: (value, item) => void;
value?: ListboxValue;
}
| {
defaultValue?: ListboxValue<true>;
multiple: true;
onValueChange?: (value, item) => void;
value?: ListboxValue<true>;
};

Props accepted by Listbox.

Name Type Description
emptyMessage? ReactNode -
getKey() (item) => string Returns the stable key used for focus and selection.
getLabel() (item) => string Returns the accessible label used for an item.
isDisabled()? (item) => boolean Determines whether an item can receive focus or selection.
items readonly T[] -
rootRef? React.Ref<HTMLDivElement> Receives the selection control’s root div.
renderItem()? (item, active, state) => ReactNode Renders an item with its intrinsic focus and selection state.
Type Parameter Default type
T -
Multiple extends boolean false

ListboxValuetype alias

Section titled “ListboxValue”
Signature
type ListboxValue<Multiple> = Multiple extends true ? string[] : null | string;

Supported ListboxValue values.

Type Parameter Default type
Multiple extends boolean false
Signature
function Listbox<T>(input): Element;

A selection primitive with caller-owned values and intrinsic keyboard navigation.

Type Parameter
T
Parameter Type
input ListboxProps<T, boolean>

Element