v1.6.0

Combobox

Installation

Install yarn add @spark-web/combobox
Source GitHub.com
Bundle unpkg.com

The Combobox allows the user to browse, search, and make a single selection from a large list of values.

Usage

Controlled component

Select a character

Uncontrolled component

Select a character

Async

Start typing...

Custom label and value

Select a movie
{}

Grouped

Select a character

With Default Option

Select a character

Appearance

Disabled

Select a character

Invalid

Select a character
Required

Props

PropTypeDescription

items

Awaitable<(Item | GroupBase<Item>)[]>

Array of items for the user to select from.

data?

DataAttributeMap

Sets data attributes on the component.

defaultOption?

DefaultOption<Item>

Option that will be displayed regardless of filter results

getOptionLabel?

GetOptionLabel<Item>

Resolves option data to a string to be displayed as the label by components.

Note: Failure to resolve to a string type can interfere with filtering and

screen reader support.

getOptionValue?

GetOptionValue<Item>

Resolves option data to a string to compare options and specify value attributes.

inputValue?

string

The value of the input.

isLoading?

boolean

When true, shows a loading indicator in the dropdown instead of results.

menuPortalTarget?

HTMLElement

Whether the menu should use a portal, and where it should attach.

onChange?

(value: Item) => void

Called when an item is selected.

onInputChange?

(inputValue: string) => void

Called whenever the input value changes. Use to filter the items.

placeholder?

string

The text that appears in the form control when it has no value set.

value?

Item

The selected item.

© 2023 Brighte Capital Pty Ltd