---
title: Combobox Component
description: "A modern, accessible combobox component for STX applications."
---
# Combobox
A modern, accessible combobox component for STX applications.
## Features
- ๐ฏ Fully accessible (WAI-ARIA compliant)
- ๐ Keyboard navigation support
- ๐จ Customizable styling
- ๐ Dynamic filtering
- ๐ฑ Mobile-friendly
- ๐ฏ TypeScript support
## Install
::: code-group
```sh [npm]
npm install @stacksjs/components
```
```sh [bun]
bun install @stacksjs/components
# bun add @stacksjs/components
# bun i @stacksjs/components
```
```sh [pnpm]
pnpm add @stacksjs/components
# pnpm i @stacksjs/components
```
```sh [yarn]
yarn add @stacksjs/components
# yarn i -d @stacksjs/components
```
:::
## Usage
The combobox component is composed of several sub-components that work together to create a fully functional and accessible combobox:
```html
{{ item.name }}
```
## API Reference
### Combobox
The root component that wraps all combobox elements.
#### Props
- `v-model` - The selected value(s)
- `disabled` - (boolean) Whether the combobox is disabled
- `as` - (string) The element to render as (default: 'template')
### ComboboxInput
The input element of the combobox.
#### Props
- `displayValue` - (Function) Function to format the display value
- `placeholder` - (string) Input placeholder text
#### Events
- `@change` - Emitted when the input value changes
- `@focus` - Emitted when the input receives focus
- `@blur` - Emitted when the input loses focus
### ComboboxButton
The button that toggles the combobox options.
#### Props
- `as` - (string) The element to render as (default: 'button')
### ComboboxOptions
The container for the list of options.
#### Props
- `as` - (string) The element to render as (default: 'ul')
- `static` - (boolean) Whether the options should always be rendered
- `hold` - (boolean) Whether to maintain the options in the DOM when hidden
### ComboboxOption
Individual option items within the combobox.
#### Props
- `value` - The value associated with the option
- `disabled` - (boolean) Whether the option is disabled
- `as` - (string) The element to render as (default: 'li')
#### Slot Props
The ComboboxOption component exposes the following slot props:
- `active` - (boolean) Whether the option is currently active (focused)
- `selected` - (boolean) Whether the option is currently selected
- `disabled` - (boolean) Whether the option is disabled
## Styling
The combobox components can be styled using standard CSS classes. Each component accepts standard HTML attributes including `class` and `style`.
For dynamic styling based on state, use the slot props provided by ComboboxOption:
```html
{{ option.name }}
```
## Accessibility
The combobox component follows WAI-ARIA guidelines and includes the following features:
- Full keyboard navigation support
- ARIA attributes automatically managed
- Screen reader announcements for selection changes
- Focus management
## TypeScript Support
The combobox component includes full TypeScript support. You can specify the type of your items:
```ts
interface Item {
id: number
name: string
}
const selected = ref- (null)
const items = ref
- ([])
```
Still have questions relating this componentโs usage? Contact us and we will help you out. In the meantime, if you are curious about the [``](./command-palette.md) component read more on the next page.