---
title: Listbox
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, PropsTable, TokensTable } from '../../src/components'
import { Listbox as BaseDocs } from 'docs/@telus-uds/components-base'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# Listbox

<LibraryInfo />

```jsx live
<Listbox
  items={[
    {
      label: 'Link 1',
      href: '#link1'
    },
    {
      label: 'Link 2',
      items: [{ label: 'Child One', href: '#' }]
    },
    {
      label: 'Link 3',
      items: [{ label: 'Child Two', href: '#' }]
    },
    {
      label: 'Link 4',
      href: '#link3'
    }
  ]}
/>
```

## Introduction

Listbox provide suggestions based on user input

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

- The `items` props accepts an array of objects with the following shape `{ label: string, href: string, items: Array of Subitems}`
- Use the `selectedId` to define a selected item by default, it should match the `label` of one of the items, including any child item
- Use `LinkRouter` to integrate the component to any router system you might be using.
- The `itemRouterProps` accepts any router-specific props (such as `to`)
- Use `parentRef` to pass the parent element reference (used to return focus after leaving last menu item)
- Use `firstItemRef` to make reference to first item (focus will be moved to this element once within the menu)

### Accessibility

The `role` prop is assigned fora the `Listbox` container is `listbox` and `option` for items and subItems

## Variants

<NoStylisticVariants />

## Props

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable base={BaseDocs} component="Listbox" />

## Feedback

<Feedback component="Listbox" />
