Skip to content

ListBox

Props

API reference for ListBox. For usage examples, see the React tab.

ListBox.Root

NameTypeDefault
children((item: T) => ReactNode) | ReactNode

The contents of the collection.

dependenciesreadonly any[]

Values that should invalidate the item cache when using dynamic collections.

disabledKeysIterable<Key>

The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.

disallowEmptySelectionboolean

Whether the collection allows empty selection.

dragAndDropHooksDragAndDropHooks<NoInfer<T>>

The drag and drop hooks returned by useDragAndDrop used to enable drag and drop behavior for the ListBox.

escapeKeyBehavior"clearSelection" | "none"'clearSelection'

Whether pressing the escape key should clear selection in the listbox or not.

Most experiences should not modify this option as it eliminates a keyboard user's ability to easily clear selection. Only use if the escape key is being handled externally or should not trigger selection clearing contextually.

gridColumnsnumber2

Number of columns when layout="grid". Ignored when layout is "stack".

itemsIterable<T>

Item objects in the collection.

layout"grid" | "stack"'stack'

Whether the items are arranged in a stack or grid.

orientationOrientation'vertical'

The primary orientation of the items. Usually this is the direction that the collection scrolls.

renderEmptyState((props: ListBoxRenderProps) => ReactNode)

Provides content to display when there are no items in the list.

selectionBehaviorSelectionBehavior'toggle'

How multiple selection should behave in the collection.

selectionModeSelectionMode

The type of selection that is allowed in the collection.

shouldFocusOnHoverboolean

Whether options should be focused when the user hovers over them.

shouldFocusWrapboolean

Whether focus should wrap around when the end/start is reached.

shouldSelectOnPressUpboolean

Whether selection should occur on press up instead of press down.

sizeListBoxSizemd

Controls list item height, padding, and label typography.

ListBox.Item

NameTypeDefault
childrenChildrenOrFunction<ListBoxItemRenderProps>

The children of the component. A function may be provided to alter the children based on component state.

downloadstring | boolean

Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN (opens in new tab).

hrefstring

A URL to link to. See MDN (opens in new tab).

hrefLangstring

Hints at the human language of the linked URL. SeeMDN (opens in new tab).

isDisabledboolean

Whether the item is disabled.

pingstring

A space-separated list of URLs to ping when the link is followed. See MDN (opens in new tab).

referrerPolicyHTMLAttributeReferrerPolicy

How much of the referrer to send when following the link. See MDN (opens in new tab).

relstring

The relationship between the linked resource and the current page. See MDN (opens in new tab).

routerOptionsundefined

Options for the configured client side router.

targetHTMLAttributeAnchorTarget

The target window for the link. See MDN (opens in new tab).

textValuestring

A string representation of the item's contents, used for features like typeahead.

ListBox.LeadingIcon

NameTypeDefault
aboutstring
accessKeystring
autoSavestring
childrenReactNode
colorstring
contentstring
contextMenustring
dangerouslySetInnerHTML{ __html: string | TrustedHTML; }
datatypestring
defaultCheckedboolean
exportpartsstring

See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts (opens in new tab)

inlistany
inputMode"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url"

Hints at the type of data that might be entered by the user while editing the element or its contents

See: https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute (opens in new tab)

itemIDstring
itemPropstring
itemRefstring
itemScopeboolean
itemTypestring
partstring

See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part (opens in new tab)

prefixstring
propertystring
radioGroupstring
relstring
resourcestring
resultsnumber
revstring
securitystring
titlestring
typeofstring
unselectable"off" | "on"
vocabstring

ListBox.Section

NameTypeDefault
children((item: T) => ReactElement<unknown, string | JSXElementConstructor<any>>) | ReactNode

Static child items or a function to render children.

dependenciesreadonly any[]

Values that should invalidate the item cache when using dynamic collections.

itemsIterable<T>

Item objects in the section.

ListBox.SectionHeader

NameTypeDefault
aboutstring
accessKeystring
autoSavestring
childrenReactNode
colorstring
contentstring
contextMenustring
dangerouslySetInnerHTML{ __html: string | TrustedHTML; }
datatypestring
defaultCheckedboolean
exportpartsstring

See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts (opens in new tab)

inlistany
inputMode"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url"

Hints at the type of data that might be entered by the user while editing the element or its contents

See: https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute (opens in new tab)

itemIDstring
itemPropstring
itemRefstring
itemScopeboolean
itemTypestring
partstring

See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part (opens in new tab)

prefixstring
propertystring
radioGroupstring
relstring
resourcestring
resultsnumber
revstring
securitystring
titlestring
typeofstring
unselectable"off" | "on"
vocabstring