# Listbox URL: https://ark-ui.com/docs/components/listbox Source: https://raw.githubusercontent.com/chakra-ui/ark/refs/heads/main/website/src/content/pages/components/listbox.mdx A component for selecting a single or multiple items from a list. --- ## Anatomy {/* */} ```tsx ``` ## Examples ### Basic Here's a basic example of the Listbox component. **Example: basic** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' export const Basic = () => { const collection = createListCollection({ items: [ { label: 'United States', value: 'us' }, { label: 'United Kingdom', value: 'uk' }, { label: 'Canada', value: 'ca' }, { label: 'Australia', value: 'au' }, { label: 'Germany', value: 'de' }, { label: 'France', value: 'fr' }, { label: 'Japan', value: 'jp' }, ], }) return ( Select Country {collection.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import styles from 'styles/listbox.module.css' export const Basic = () => { const collection = createListCollection({ items: [ { label: 'United States', value: 'us' }, { label: 'United Kingdom', value: 'uk' }, { label: 'Canada', value: 'ca' }, { label: 'Australia', value: 'au' }, { label: 'Germany', value: 'de' }, { label: 'France', value: 'fr' }, { label: 'Japan', value: 'jp' }, ], }) return ( Select Country {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Select Country {#each collection.items as item (item.value)} {item.label} {/each} ``` ### Controlled The Listbox component can be controlled by using the `value` and `onValueChange` props. This allows you to manage the selected value externally. **Example: controlled** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import { useState } from 'react' import styles from 'styles/listbox.module.css' export const Controlled = () => { const collection = createListCollection({ items: [ { label: 'Small', value: 'sm' }, { label: 'Medium', value: 'md' }, { label: 'Large', value: 'lg' }, { label: 'Extra Large', value: 'xl' }, ], }) const [value, setValue] = useState(['md']) return ( setValue(e.value)} > Select Size {collection.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index, createSignal } from 'solid-js' import styles from 'styles/listbox.module.css' export const Controlled = () => { const collection = createListCollection({ items: [ { label: 'Small', value: 'sm' }, { label: 'Medium', value: 'md' }, { label: 'Large', value: 'lg' }, { label: 'Extra Large', value: 'xl' }, ], }) const [value, setValue] = createSignal(['md']) return ( setValue(e.value)}> Select Size {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte (value = e.value)}> Select Size {#each collection.items as item (item.value)} {item.label} {/each} ``` ### Root Provider An alternative way to control the listbox is to use the `RootProvider` component and the `useListbox` hook. This way you can access the state and methods from outside the component. **Example: root-provider** #### React ```tsx import { Listbox, createListCollection, useListbox } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import button from 'styles/button.module.css' import styles from 'styles/listbox.module.css' export const RootProvider = () => { const collection = createListCollection({ items: [ { label: 'Low', value: 'low' }, { label: 'Medium', value: 'medium' }, { label: 'High', value: 'high' }, { label: 'Critical', value: 'critical' }, ], }) const listbox = useListbox({ collection }) return (
Select Priority {collection.items.map((item) => ( {item.label} ))}
) } ``` #### Solid ```tsx import { Listbox, createListCollection, useListbox } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import button from 'styles/button.module.css' import styles from 'styles/listbox.module.css' export const RootProvider = () => { const collection = createListCollection({ items: [ { label: 'Low', value: 'low' }, { label: 'Medium', value: 'medium' }, { label: 'High', value: 'high' }, { label: 'Critical', value: 'critical' }, ], }) const listbox = useListbox({ collection }) return (
Select Priority {(item) => ( {item().label} )}
) } ``` #### Vue ```vue ``` #### Svelte ```svelte
Select Priority {#each collection.items as item (item.value)} {item.label} {/each}
``` ### Disabled Item Listbox items can be disabled using the `disabled` prop on the collection item. **Example: disabled-item** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' export const DisabledItem = () => { const collection = createListCollection({ items: [ { label: 'Free', value: 'free' }, { label: 'Pro', value: 'pro' }, { label: 'Enterprise', value: 'enterprise', disabled: true }, { label: 'Custom', value: 'custom' }, ], }) return ( Select Plan {collection.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import styles from 'styles/listbox.module.css' export const DisabledItem = () => { const collection = createListCollection({ items: [ { label: 'Free', value: 'free' }, { label: 'Pro', value: 'pro' }, { label: 'Enterprise', value: 'enterprise', disabled: true }, { label: 'Custom', value: 'custom' }, ], }) return ( Select Plan {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Select Plan {#each collection.items as item (item.value)} {item.label} {/each} ``` > You can also use the `isItemDisabled` within the `createListCollection` to disable items based on a condition. ### Multiple You can set the `selectionMode` property as `multiple` to allow the user to select multiple items at a time. **Example: multiple** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' export const Multiple = () => { const collection = createListCollection({ items: [ { label: 'Monday', value: 'mon' }, { label: 'Tuesday', value: 'tue' }, { label: 'Wednesday', value: 'wed' }, { label: 'Thursday', value: 'thu' }, { label: 'Friday', value: 'fri' }, { label: 'Saturday', value: 'sat' }, { label: 'Sunday', value: 'sun' }, ], }) return ( Select Days {collection.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import styles from 'styles/listbox.module.css' export const Multiple = () => { const collection = createListCollection({ items: [ { label: 'Monday', value: 'mon' }, { label: 'Tuesday', value: 'tue' }, { label: 'Wednesday', value: 'wed' }, { label: 'Thursday', value: 'thu' }, { label: 'Friday', value: 'fri' }, { label: 'Saturday', value: 'sat' }, { label: 'Sunday', value: 'sun' }, ], }) return ( Select Days {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Select Days {#each collection.items as item (item.value)} {item.label} {/each} ``` ### Grouping The Listbox component supports grouping items. You can use the `groupBy` function to group items based on a specific property. **Example: group** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' export const Group = () => { const collection = createListCollection({ items: [ { label: 'New York', value: 'nyc', region: 'North America' }, { label: 'Los Angeles', value: 'lax', region: 'North America' }, { label: 'Toronto', value: 'yyz', region: 'North America' }, { label: 'London', value: 'lhr', region: 'Europe' }, { label: 'Paris', value: 'cdg', region: 'Europe' }, { label: 'Berlin', value: 'ber', region: 'Europe' }, { label: 'Tokyo', value: 'nrt', region: 'Asia Pacific' }, { label: 'Singapore', value: 'sin', region: 'Asia Pacific' }, { label: 'Sydney', value: 'syd', region: 'Asia Pacific' }, ], groupBy: (item) => item.region, }) return ( Select Region {collection.group().map(([region, items]) => ( {region} {items.map((item) => ( {item.label} ))} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { For } from 'solid-js' import styles from 'styles/listbox.module.css' export const Group = () => { const collection = createListCollection({ items: [ { label: 'New York', value: 'nyc', region: 'North America' }, { label: 'Los Angeles', value: 'lax', region: 'North America' }, { label: 'Toronto', value: 'yyz', region: 'North America' }, { label: 'London', value: 'lhr', region: 'Europe' }, { label: 'Paris', value: 'cdg', region: 'Europe' }, { label: 'Berlin', value: 'ber', region: 'Europe' }, { label: 'Tokyo', value: 'nrt', region: 'Asia Pacific' }, { label: 'Singapore', value: 'sin', region: 'Asia Pacific' }, { label: 'Sydney', value: 'syd', region: 'Asia Pacific' }, ], groupBy: (item) => item.region, }) return ( Select Region {([region, items]) => ( {region} {(item) => ( {item.label} )} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Select Region {#each collection.group() as [region, items]} {region} {#each items as item (item.value)} {item.label} {/each} {/each} ``` ### Extended Selection The extended selection mode allows users to select multiple items using keyboard modifiers like `Cmd` (Mac) or `Ctrl` (Windows/Linux). **Example: extended-select** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' export const ExtendedSelect = () => { const collection = createListCollection({ items: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, { label: 'Svelte', value: 'svelte' }, { label: 'Solid', value: 'solid' }, { label: 'Preact', value: 'preact' }, ], }) return ( Hold or Ctrl to select multiple {collection.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import styles from 'styles/listbox.module.css' export const ExtendedSelect = () => { const collection = createListCollection({ items: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, { label: 'Svelte', value: 'svelte' }, { label: 'Solid', value: 'solid' }, { label: 'Preact', value: 'preact' }, ], }) return ( Hold or Ctrl to select multiple {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Hold or Ctrl to select multiple {#each collection.items as item (item.value)} {item.label} {/each} ``` ### Horizontal Use the `orientation` prop to display the listbox items horizontally. **Example: horizontal** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' export const Horizontal = () => { const collection = createListCollection({ items: [ { title: 'Midnight Dreams', artist: 'Luna Ray', image: 'https://picsum.photos/seed/album1/300/300', }, { title: 'Neon Skyline', artist: 'The Electric', image: 'https://picsum.photos/seed/album2/300/300', }, { title: 'Acoustic Sessions', artist: 'Sarah Woods', image: 'https://picsum.photos/seed/album3/300/300', }, { title: 'Urban Echoes', artist: 'Metro Collective', image: 'https://picsum.photos/seed/album4/300/300', }, { title: 'Summer Vibes', artist: 'Coastal Waves', image: 'https://picsum.photos/seed/album5/300/300', }, ], itemToValue: (item) => item.title, itemToString: (item) => item.title, }) return ( Select Album {collection.items.map((item) => ( {item.title} {item.title} {item.artist} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import styles from 'styles/listbox.module.css' export const Horizontal = () => { const collection = createListCollection({ items: [ { title: 'Midnight Dreams', artist: 'Luna Ray', image: 'https://picsum.photos/seed/album1/300/300', }, { title: 'Neon Skyline', artist: 'The Electric', image: 'https://picsum.photos/seed/album2/300/300', }, { title: 'Acoustic Sessions', artist: 'Sarah Woods', image: 'https://picsum.photos/seed/album3/300/300', }, { title: 'Urban Echoes', artist: 'Metro Collective', image: 'https://picsum.photos/seed/album4/300/300', }, { title: 'Summer Vibes', artist: 'Coastal Waves', image: 'https://picsum.photos/seed/album5/300/300', }, ], itemToValue: (item) => item.title, itemToString: (item) => item.title, }) return ( Select Album {(item) => ( {item().title} {item().title} {item().artist} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Select Album {#each collection.items as item (item.title)} {item.title} {item.title} {item.artist} {/each} ``` ### Grid Layout Use `createGridCollection` to display items in a grid layout with keyboard navigation support. **Example: grid** #### React ```tsx import { createGridCollection } from '@ark-ui/react/collection' import { Listbox } from '@ark-ui/react/listbox' import styles from 'styles/listbox.module.css' export const Grid = () => { const collection = createGridCollection({ items: [ { label: '😀', value: 'grinning' }, { label: '😍', value: 'heart-eyes' }, { label: '🥳', value: 'partying' }, { label: '😎', value: 'sunglasses' }, { label: '🤩', value: 'star-struck' }, { label: '😂', value: 'joy' }, { label: '🥰', value: 'smiling-hearts' }, { label: '😊', value: 'blush' }, { label: '🤗', value: 'hugging' }, { label: '😇', value: 'innocent' }, { label: '🔥', value: 'fire' }, { label: '✨', value: 'sparkles' }, { label: '💯', value: 'hundred' }, { label: '🎉', value: 'tada' }, { label: '❤️', value: 'heart' }, { label: '👍', value: 'thumbs-up' }, { label: '👏', value: 'clap' }, { label: '🚀', value: 'rocket' }, { label: '⭐', value: 'star' }, { label: '🌈', value: 'rainbow' }, ], columnCount: 5, }) return ( Pick a reaction {collection.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { createGridCollection } from '@ark-ui/solid/collection' import { Listbox } from '@ark-ui/solid/listbox' import { Index } from 'solid-js' import styles from 'styles/listbox.module.css' export const Grid = () => { const collection = createGridCollection({ items: [ { label: '😀', value: 'grinning' }, { label: '😍', value: 'heart-eyes' }, { label: '🥳', value: 'partying' }, { label: '😎', value: 'sunglasses' }, { label: '🤩', value: 'star-struck' }, { label: '😂', value: 'joy' }, { label: '🥰', value: 'smiling-hearts' }, { label: '😊', value: 'blush' }, { label: '🤗', value: 'hugging' }, { label: '😇', value: 'innocent' }, { label: '🔥', value: 'fire' }, { label: '✨', value: 'sparkles' }, { label: '💯', value: 'hundred' }, { label: '🎉', value: 'tada' }, { label: '❤️', value: 'heart' }, { label: '👍', value: 'thumbs-up' }, { label: '👏', value: 'clap' }, { label: '🚀', value: 'rocket' }, { label: '⭐', value: 'star' }, { label: '🌈', value: 'rainbow' }, ], columnCount: 5, }) return ( Pick a reaction {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Pick a reaction {#each collection.items as item (item.value)} {item.label} {/each} ``` ### Filtering Use `useListCollection` with the `filter` function to enable filtering of items. **Example: filtering** #### React ```tsx import { useListCollection } from '@ark-ui/react/collection' import { Listbox } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import field from 'styles/field.module.css' import styles from 'styles/listbox.module.css' export const Filtering = () => { const { collection, filter } = useListCollection({ initialItems: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, { label: 'Svelte', value: 'svelte' }, { label: 'Solid', value: 'solid' }, { label: 'Next.js', value: 'nextjs' }, { label: 'Nuxt.js', value: 'nuxtjs' }, { label: 'Remix', value: 'remix' }, { label: 'Gatsby', value: 'gatsby' }, { label: 'Preact', value: 'preact' }, ], filter: (itemText, filterText) => itemText.toLowerCase().includes(filterText.toLowerCase()), }) return ( Select Framework filter(e.target.value)} /> {collection.items.map((item) => ( {item.label} ))} No frameworks found ) } ``` #### Solid ```tsx import { useListCollection } from '@ark-ui/solid/collection' import { Listbox } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import field from 'styles/field.module.css' import styles from 'styles/listbox.module.css' export const Filtering = () => { const { collection, filter } = useListCollection({ initialItems: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, { label: 'Svelte', value: 'svelte' }, { label: 'Solid', value: 'solid' }, { label: 'Next.js', value: 'nextjs' }, { label: 'Nuxt.js', value: 'nuxtjs' }, { label: 'Remix', value: 'remix' }, { label: 'Gatsby', value: 'gatsby' }, { label: 'Preact', value: 'preact' }, ], filter: (itemText, filterText) => itemText.toLowerCase().includes(filterText.toLowerCase()), }) return ( Select Framework filter(e.target.value)} /> {(item) => ( {item().label} )} No frameworks found ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Select Framework filter(e.currentTarget.value)} /> {#each collection().items as item (item.value)} {item.label} {/each} No frameworks found ``` ### Select All Use `useListboxContext` to implement a "Select All" functionality that allows users to select or deselect all items at once. **Example: select-all** #### React ```tsx import { Listbox, createListCollection, useListboxContext } from '@ark-ui/react/listbox' import { CheckIcon, MinusIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' const frameworks = createListCollection({ items: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, { label: 'Svelte', value: 'svelte' }, { label: 'Next.js', value: 'nextjs' }, { label: 'Nuxt.js', value: 'nuxtjs' }, { label: 'Remix', value: 'remix' }, { label: 'Gatsby', value: 'gatsby' }, ], }) const SelectAllHeader = () => { const listbox = useListboxContext() const isAllSelected = listbox.value.length === frameworks.items.length const isSomeSelected = listbox.value.length > 0 && listbox.value.length < frameworks.items.length const handleSelectAll = () => { if (isAllSelected) { listbox.setValue([]) } else { listbox.setValue(frameworks.items.map((item) => item.value)) } } return ( ) } export const SelectAll = () => { return ( {frameworks.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection, useListboxContext } from '@ark-ui/solid/listbox' import { CheckIcon, MinusIcon } from 'lucide-solid' import { Index, Show } from 'solid-js' import styles from 'styles/listbox.module.css' const frameworks = createListCollection({ items: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, { label: 'Angular', value: 'angular' }, { label: 'Svelte', value: 'svelte' }, { label: 'Next.js', value: 'nextjs' }, { label: 'Nuxt.js', value: 'nuxtjs' }, { label: 'Remix', value: 'remix' }, { label: 'Gatsby', value: 'gatsby' }, ], }) const SelectAllHeader = () => { const listbox = useListboxContext() const isAllSelected = () => listbox().value.length === frameworks.items.length const isSomeSelected = () => listbox().value.length > 0 && listbox().value.length < frameworks.items.length const handleSelectAll = () => { if (isAllSelected()) { listbox().setValue([]) } else { listbox().setValue(frameworks.items.map((item) => item.value)) } } return ( ) } export const SelectAll = () => { return ( {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte {#snippet selectAllHeader()} {/snippet} {@render selectAllHeader()} {#each frameworks.items as item (item.value)} {item.label} {/each} ``` ### Value Text Use `Listbox.ValueText` to display the selected values as a comma-separated string. **Example: value-text** #### React ```tsx import { Listbox, createListCollection } from '@ark-ui/react/listbox' import { CheckIcon } from 'lucide-react' import styles from 'styles/listbox.module.css' export const ValueText = () => { const collection = createListCollection({ items: [ { label: 'Red', value: 'red' }, { label: 'Blue', value: 'blue' }, { label: 'Green', value: 'green' }, { label: 'Yellow', value: 'yellow' }, { label: 'Purple', value: 'purple' }, ], }) return ( Colors: {collection.items.map((item) => ( {item.label} ))} ) } ``` #### Solid ```tsx import { Listbox, createListCollection } from '@ark-ui/solid/listbox' import { CheckIcon } from 'lucide-solid' import { Index } from 'solid-js' import styles from 'styles/listbox.module.css' export const ValueText = () => { const collection = createListCollection({ items: [ { label: 'Red', value: 'red' }, { label: 'Blue', value: 'blue' }, { label: 'Green', value: 'green' }, { label: 'Yellow', value: 'yellow' }, { label: 'Purple', value: 'purple' }, ], }) return ( Colors: {(item) => ( {item().label} )} ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Colors: {#each collection.items as item (item.value)} {item.label} {/each} ``` ## Guides ### Type Safety The `Listbox.RootComponent` type enables you to create typed wrapper components that maintain full type safety for collection items. ```tsx const Listbox: ArkListbox.RootComponent = (props) => { return {/* ... */} } ``` Use the wrapper with full type inference on `onValueChange` and other callbacks: ```tsx const App = () => { const collection = createListCollection({ initialItems: [ { label: 'React', value: 'react' }, { label: 'Vue', value: 'vue' }, ], }) return ( { // e.items is typed as Array<{ label: string, value: string }> console.log(e.items) }} > {/* ... */} ) } ``` ## API Reference ### Props **Component API Reference** #### React **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `collection` | `ListCollection` | Yes | The collection of items | | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `defaultHighlightedValue` | `string` | No | The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox. | | `defaultValue` | `string[]` | No | The initial default value of the listbox when rendered. Use when you don't need to control the value of the listbox. | | `deselectable` | `boolean` | No | Whether to disallow empty selection | | `disabled` | `boolean` | No | Whether the listbox is disabled | | `disallowSelectAll` | `boolean` | No | Whether to disallow selecting all items when `meta+a` is pressed | | `highlightedValue` | `string` | No | The controlled key of the highlighted item | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ root: string content: string label: string item: (id: string | number) => string itemGroup: (id: string | number) => string itemGroupLabel: (id: string | number) => string }>` | No | The ids of the elements in the listbox. Useful for composition. | | `loopFocus` | `boolean` | No | Whether to loop the keyboard navigation through the options | | `onHighlightChange` | `(details: HighlightChangeDetails) => void` | No | The callback fired when the highlighted item changes. | | `onSelect` | `(details: SelectionDetails) => void` | No | Function called when an item is selected | | `onValueChange` | `(details: ValueChangeDetails) => void` | No | The callback fired when the selected item changes. | | `orientation` | `'horizontal' | 'vertical'` | No | The orientation of the listbox. | | `scrollToIndexFn` | `(details: ScrollToIndexDetails) => void` | No | Function to scroll to a specific index | | `selectionMode` | `SelectionMode` | No | How multiple selection should behave in the listbox. - `single`: The user can select a single item. - `multiple`: The user can select multiple items without using modifier keys. - `extended`: The user can select multiple items by using modifier keys. | | `selectOnHighlight` | `boolean` | No | Whether to select the item when it is highlighted | | `typeahead` | `boolean` | No | Whether to enable typeahead on the listbox | | `value` | `string[]` | No | The controlled keys of the selected items | **Root Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | root | | `[data-orientation]` | The orientation of the listbox | | `[data-disabled]` | Present when disabled | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | content | | `[data-activedescendant]` | The id the active descendant of the content | | `[data-orientation]` | The orientation of the content | | `[data-layout]` | | | `[data-empty]` | Present when the content is empty | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--column-count` | The column count value for the Content | **Empty Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Input Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `autoHighlight` | `boolean` | No | Whether to automatically highlight the item when typing | **Input Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | input | | `[data-disabled]` | Present when disabled | **ItemGroupLabel Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemGroup Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemGroup Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-group | | `[data-disabled]` | Present when disabled | | `[data-orientation]` | The orientation of the item | | `[data-empty]` | Present when the content is empty | **ItemIndicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemIndicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-indicator | | `[data-state]` | "checked" | "unchecked" | **Item Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `highlightOnHover` | `boolean` | No | Whether to highlight the item on hover | | `item` | `any` | No | The item to render | **Item Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item | | `[data-value]` | The value of the item | | `[data-selected]` | Present when selected | | `[data-layout]` | | | `[data-state]` | "checked" | "unchecked" | | `[data-orientation]` | The orientation of the item | | `[data-highlighted]` | Present when highlighted | | `[data-disabled]` | Present when disabled | **ItemText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-text | | `[data-state]` | "checked" | "unchecked" | | `[data-disabled]` | Present when disabled | | `[data-highlighted]` | Present when highlighted | **Label Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Label Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | label | | `[data-disabled]` | Present when disabled | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `UseListboxReturn` | Yes | | | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ValueText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `placeholder` | `string` | No | Text to display when no value is listboxed. | **ValueText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | value-text | | `[data-disabled]` | Present when disabled | #### Solid **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `collection` | `ListCollection` | Yes | The collection of items | | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `defaultHighlightedValue` | `string` | No | The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox. | | `defaultValue` | `string[]` | No | The initial default value of the listbox when rendered. Use when you don't need to control the value of the listbox. | | `deselectable` | `boolean` | No | Whether to disallow empty selection | | `disabled` | `boolean` | No | Whether the listbox is disabled | | `disallowSelectAll` | `boolean` | No | Whether to disallow selecting all items when `meta+a` is pressed | | `highlightedValue` | `string` | No | The controlled key of the highlighted item | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ root: string content: string label: string item: (id: string | number) => string itemGroup: (id: string | number) => string itemGroupLabel: (id: string | number) => string }>` | No | The ids of the elements in the listbox. Useful for composition. | | `loopFocus` | `boolean` | No | Whether to loop the keyboard navigation through the options | | `onHighlightChange` | `(details: HighlightChangeDetails) => void` | No | The callback fired when the highlighted item changes. | | `onSelect` | `(details: SelectionDetails) => void` | No | Function called when an item is selected | | `onValueChange` | `(details: ValueChangeDetails) => void` | No | The callback fired when the selected item changes. | | `orientation` | `'horizontal' | 'vertical'` | No | The orientation of the listbox. | | `scrollToIndexFn` | `(details: ScrollToIndexDetails) => void` | No | Function to scroll to a specific index | | `selectionMode` | `SelectionMode` | No | How multiple selection should behave in the listbox. - `single`: The user can select a single item. - `multiple`: The user can select multiple items without using modifier keys. - `extended`: The user can select multiple items by using modifier keys. | | `selectOnHighlight` | `boolean` | No | Whether to select the item when it is highlighted | | `typeahead` | `boolean` | No | Whether to enable typeahead on the listbox | | `value` | `string[]` | No | The controlled keys of the selected items | **Root Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | root | | `[data-orientation]` | The orientation of the listbox | | `[data-disabled]` | Present when disabled | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | content | | `[data-activedescendant]` | The id the active descendant of the content | | `[data-orientation]` | The orientation of the content | | `[data-layout]` | | | `[data-empty]` | Present when the content is empty | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--column-count` | The column count value for the Content | **Empty Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Input Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'input'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `autoHighlight` | `boolean` | No | Whether to automatically highlight the item when typing | **Input Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | input | | `[data-disabled]` | Present when disabled | **ItemGroupLabel Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemGroup Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemGroup Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-group | | `[data-disabled]` | Present when disabled | | `[data-orientation]` | The orientation of the item | | `[data-empty]` | Present when the content is empty | **ItemIndicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemIndicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-indicator | | `[data-state]` | "checked" | "unchecked" | **Item Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `highlightOnHover` | `boolean` | No | Whether to highlight the item on hover | | `item` | `any` | No | The item to render | **Item Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item | | `[data-value]` | The value of the item | | `[data-selected]` | Present when selected | | `[data-layout]` | | | `[data-state]` | "checked" | "unchecked" | | `[data-orientation]` | The orientation of the item | | `[data-highlighted]` | Present when highlighted | | `[data-disabled]` | Present when disabled | **ItemText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-text | | `[data-state]` | "checked" | "unchecked" | | `[data-disabled]` | Present when disabled | | `[data-highlighted]` | Present when highlighted | **Label Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'label'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Label Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | label | | `[data-disabled]` | Present when disabled | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `UseListboxReturn` | Yes | | | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ValueText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'span'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `placeholder` | `string` | No | Text to display when no value is selected. | **ValueText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | value-text | | `[data-disabled]` | Present when disabled | #### Vue **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `collection` | `ListCollection` | Yes | The collection of items | | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `defaultHighlightedValue` | `string` | No | The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox. | | `defaultValue` | `string[]` | No | The initial default value of the listbox when rendered. Use when you don't need to control the value of the listbox. | | `deselectable` | `boolean` | No | Whether to disallow empty selection | | `disabled` | `boolean` | No | Whether the listbox is disabled | | `disallowSelectAll` | `boolean` | No | Whether to disallow selecting all items when `meta+a` is pressed | | `highlightedValue` | `string` | No | The controlled key of the highlighted item | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ root: string content: string label: string item(id: string | number): string itemGroup(id: string | number): string itemGroupLabel(id: string | number): string }>` | No | The ids of the elements in the listbox. Useful for composition. | | `loopFocus` | `boolean` | No | Whether to loop the keyboard navigation through the options | | `modelValue` | `string[]` | No | The model value of the listbox | | `orientation` | `'horizontal' | 'vertical'` | No | The orientation of the element. | | `scrollToIndexFn` | `(details: ScrollToIndexDetails) => void` | No | Function to scroll to a specific index | | `selectionMode` | `SelectionMode` | No | How multiple selection should behave in the listbox. - `single`: The user can select a single item. - `multiple`: The user can select multiple items without using modifier keys. - `extended`: The user can select multiple items by using modifier keys. | | `selectOnHighlight` | `boolean` | No | Whether to select the item when it is highlighted | | `typeahead` | `boolean` | No | Whether to enable typeahead on the listbox | **Root Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | root | | `[data-orientation]` | The orientation of the listbox | | `[data-disabled]` | Present when disabled | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | content | | `[data-activedescendant]` | The id the active descendant of the content | | `[data-orientation]` | The orientation of the content | | `[data-layout]` | | | `[data-empty]` | Present when the content is empty | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--column-count` | The column count value for the Content | **Empty Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Input Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Input Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | input | | `[data-disabled]` | Present when disabled | **ItemGroupLabel Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemGroup Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `id` | `string` | No | | **ItemGroup Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-group | | `[data-disabled]` | Present when disabled | | `[data-orientation]` | The orientation of the item | | `[data-empty]` | Present when the content is empty | **ItemIndicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemIndicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-indicator | | `[data-state]` | "checked" | "unchecked" | **Item Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `highlightOnHover` | `boolean` | No | Whether to highlight the item on hover | | `item` | `any` | No | The item to render | **Item Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item | | `[data-value]` | The value of the item | | `[data-selected]` | Present when selected | | `[data-layout]` | | | `[data-state]` | "checked" | "unchecked" | | `[data-orientation]` | The orientation of the item | | `[data-highlighted]` | Present when highlighted | | `[data-disabled]` | Present when disabled | **ItemText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ItemText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-text | | `[data-state]` | "checked" | "unchecked" | | `[data-disabled]` | Present when disabled | | `[data-highlighted]` | Present when highlighted | **Label Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Label Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | label | | `[data-disabled]` | Present when disabled | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `ListboxApi` | Yes | | | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ValueText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `placeholder` | `string` | No | | **ValueText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | value-text | | `[data-disabled]` | Present when disabled | #### Svelte **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `collection` | `ListCollection` | Yes | The collection of items | | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `defaultHighlightedValue` | `string` | No | The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox. | | `defaultValue` | `string[]` | No | The initial default value of the listbox when rendered. Use when you don't need to control the value of the listbox. | | `deselectable` | `boolean` | No | Whether to disallow empty selection | | `disabled` | `boolean` | No | Whether the listbox is disabled | | `disallowSelectAll` | `boolean` | No | Whether to disallow selecting all items when `meta+a` is pressed | | `highlightedValue` | `string` | No | The controlled key of the highlighted item | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ root: string content: string label: string item: (id: string | number) => string itemGroup: (id: string | number) => string itemGroupLabel: (id: string | number) => string }>` | No | The ids of the elements in the listbox. Useful for composition. | | `loopFocus` | `boolean` | No | Whether to loop the keyboard navigation through the options | | `onHighlightChange` | `(details: HighlightChangeDetails) => void` | No | The callback fired when the highlighted item changes. | | `onSelect` | `(details: SelectionDetails) => void` | No | Function called when an item is selected | | `onValueChange` | `(details: ValueChangeDetails) => void` | No | The callback fired when the selected item changes. | | `orientation` | `'horizontal' | 'vertical'` | No | The orientation of the listbox. | | `scrollToIndexFn` | `(details: ScrollToIndexDetails) => void` | No | Function to scroll to a specific index | | `selectionMode` | `SelectionMode` | No | How multiple selection should behave in the listbox. - `single`: The user can select a single item. - `multiple`: The user can select multiple items without using modifier keys. - `extended`: The user can select multiple items by using modifier keys. | | `selectOnHighlight` | `boolean` | No | Whether to select the item when it is highlighted | | `typeahead` | `boolean` | No | Whether to enable typeahead on the listbox | | `value` | `string[]` | No | The controlled keys of the selected items | **Root Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | root | | `[data-orientation]` | The orientation of the listbox | | `[data-disabled]` | Present when disabled | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | content | | `[data-activedescendant]` | The id the active descendant of the content | | `[data-orientation]` | The orientation of the content | | `[data-layout]` | | | `[data-empty]` | Present when the content is empty | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--column-count` | The column count value for the Content | **Context Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `render` | `Snippet<[UseListboxContext]>` | Yes | | **Empty Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Input Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'input'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `autoHighlight` | `boolean` | No | Whether to automatically highlight the item when typing | | `ref` | `Element` | No | | **Input Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | input | | `[data-disabled]` | Present when disabled | **ItemContext Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `render` | `Snippet<[UseListboxItemContext]>` | Yes | | **ItemGroupLabel Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **ItemGroup Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **ItemGroup Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-group | | `[data-disabled]` | Present when disabled | | `[data-orientation]` | The orientation of the item | | `[data-empty]` | Present when the content is empty | **ItemIndicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **ItemIndicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-indicator | | `[data-state]` | "checked" | "unchecked" | **Item Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `highlightOnHover` | `boolean` | No | Whether to highlight the item on hover | | `item` | `any` | No | The item to render | | `ref` | `Element` | No | | **Item Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item | | `[data-value]` | The value of the item | | `[data-selected]` | Present when selected | | `[data-layout]` | | | `[data-state]` | "checked" | "unchecked" | | `[data-orientation]` | The orientation of the item | | `[data-highlighted]` | Present when highlighted | | `[data-disabled]` | Present when disabled | **ItemText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'span'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **ItemText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | item-text | | `[data-state]` | "checked" | "unchecked" | | `[data-disabled]` | Present when disabled | | `[data-highlighted]` | Present when highlighted | **Label Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'label'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Label Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | label | | `[data-disabled]` | Present when disabled | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `UseListboxReturn` | Yes | | | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **ValueText Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'span'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `placeholder` | `string` | No | Text to display when no value is selected. | **ValueText Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | listbox | | `[data-part]` | value-text | | `[data-disabled]` | Present when disabled | ### Context **API:** | Property | Type | Description | |----------|------|-------------| | `empty` | `boolean` | Whether the select value is empty | | `highlightedValue` | `string` | The value of the highlighted item | | `highlightedItem` | `V` | The highlighted item | | `highlightValue` | `(value: string) => void` | Function to highlight a value | | `clearHighlightedValue` | `VoidFunction` | Function to clear the highlighted value | | `selectedItems` | `V[]` | The selected items | | `hasSelectedItems` | `boolean` | Whether there's a selected option | | `value` | `string[]` | The selected item keys | | `valueAsString` | `string` | The string representation of the selected items | | `selectValue` | `(value: string) => void` | Function to select a value | | `selectAll` | `VoidFunction` | Function to select all values. **Note**: This should only be called when the selectionMode is `multiple` or `extended`. Otherwise, an exception will be thrown. | | `setValue` | `(value: string[]) => void` | Function to set the value of the select | | `clearValue` | `(value?: string) => void` | Function to clear the value of the select. If a value is provided, it will only clear that value, otherwise, it will clear all values. | | `getItemState` | `(props: ItemProps) => ItemState` | Returns the state of a select item | | `collection` | `ListCollection` | Function to toggle the select | | `disabled` | `boolean` | Whether the select is disabled |