šŸ“ Sign Up | šŸ” Log In

← Root | ↑ Up

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ šŸ“„ shadcn/directory/sadmann7/diceui/components/combobox │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

╔══════════════════════════════════════════════════════════════════════════════════════════════╗
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘

title: Combobox description: An input with a popover that helps users filter through a list of options. preview: true links: api: /docs/components/combobox#api-reference

<ComponentTabs name="combobox-demo" />

Installation

@diceui/combobox

Installation with shadcn/ui

CLI

npx shadcn@latest add "https://diceui.com/r/combobox"

Manual

<Steps> <Step> Install the following dependencies:
 ```package-install
 @diceui/combobox
 ```
</Step> <Step> Copy and paste the following code into your project.
<ComponentSource name="combobox" />
</Step> </Steps>

Layout

Import the parts, and compose them together.

import * as Combobox from "@diceui/combobox";

<Combobox.Root>
  <Combobox.Label />
  <Combobox.Anchor>
    <Combobox.BadgeList>
      <Combobox.BadgeItem>
        <Combobox.BadgeItemDelete />
      </Combobox.BadgeItem>
    </Combobox.BadgeList>
    <Combobox.Input />
    <Combobox.Trigger />
    <Combobox.Cancel />
  </Combobox.Anchor>
  <Combobox.Portal>
    <Combobox.Content>
      <Combobox.Arrow />
      <Combobox.Loading />
      <Combobox.Empty />
      <Combobox.Group>
        <Combobox.GroupLabel />
        <Combobox.Item>
          <Combobox.ItemText />
          <Combobox.ItemIndicator />
        </Combobox.Item>
      </Combobox.Group>
      <Combobox.Separator />
    </Combobox.Content>
  </Combobox.Portal>
</Combobox.Root>

Examples

With Groups

<ComponentTabs name="combobox-groups-demo" />

With Multiple Selection

<ComponentTabs name="combobox-multiple-demo" />

With Custom Filter

<ComponentTabs name="combobox-custom-filter-demo" />

With Debounce

<ComponentTabs name="combobox-debounced-demo" />

With Virtualization

<ComponentTabs name="combobox-virtualized-demo" />

With Tags Input

<ComponentTabs name="combobox-tags-demo" />

API Reference

Root

The container for all combobox parts.

<AutoTypeTable path="./types/docs/combobox.ts" name="RootProps" />

<DataAttributesTable attributes={[ { title: "[data-state]", value: ["open", "closed"], }, { title: "[data-disabled]", value: "Present when disabled", }, ]} />

Label

An accessible label that describes the combobox. Associates with the input element for screen readers.

<AutoTypeTable path="./types/docs/combobox.ts" name="LabelProps" />

Anchor

A wrapper element that positions the combobox popover relative to the input and trigger. Provides the reference point for popover positioning.

<AutoTypeTable path="./types/docs/combobox.ts" name="AnchorProps" />

<DataAttributesTable attributes={[ {
title: "[data-state]", value: ["open", "closed"], }, { title: "[data-anchor]", value: "Present when the anchor is present", }, { title: "[data-disabled]", value: "Present when disabled", }, { title: "[data-focused]", value: "Present when the anchor is focused", }, ]} />

Trigger

A button that toggles the combobox popover. Handles focus management and keyboard interactions for opening/closing the popover.

<AutoTypeTable path="./types/docs/combobox.ts" name="TriggerProps" />

<DataAttributesTable attributes={[ { title: "[data-state]", value: ["open", "closed"], }, { title: "[data-disabled]", value: "Present when disabled", }, ]} />

Input

The text input field that users can type into to filter options.

<AutoTypeTable path="./types/docs/combobox.ts" name="InputProps" />

BadgeList

A container for displaying selected items as badges in a multi-select combobox.

<AutoTypeTable path="./types/docs/combobox.ts" name="BadgeListProps" />

<DataAttributesTable attributes={[ { title: "[data-orientation]", value: ["horizontal", "vertical"], }, ]} />

BadgeItem

An individual badge representing a selected item in a multi-select combobox.

<AutoTypeTable path="./types/docs/combobox.ts" name="BadgeItemProps" />

<DataAttributesTable attributes={[ { title: "[data-disabled]", value: "Present when the badge is disabled", }, { title: "[data-highlighted]", value: "Present when the badge is highlighted", }, { title: "[data-orientation]", value: ["horizontal", "vertical"], }, ]} />

BadgeItemDelete

A button to remove a selected item from the multi-select combobox.

<AutoTypeTable path="./types/docs/combobox.ts" name="BadgeItemDeleteProps" />

<DataAttributesTable attributes={[ { title: "[data-disabled]", value: "Present when the parent badge is disabled", }, { title: "[data-highlighted]", value: "Present when the parent badge is highlighted", }, ]} />

Cancel

A button that clears the input value and resets the filter.

<AutoTypeTable path="./types/docs/combobox.ts" name="CancelProps" />

<DataAttributesTable attributes={[ { title: "[data-disabled]", value: "Present when disabled", }, ]} />

Portal

A portal for rendering the combobox content outside of its DOM hierarchy.

<AutoTypeTable path="./types/docs/combobox.ts" name="PortalProps" />

Content

The popover container for combobox items. Positions the combobox popover relative to the anchor.

<AutoTypeTable path="./types/docs/combobox.ts" name="ContentProps" />

<DataAttributesTable attributes={[ { title: "[data-state]", value: ["open", "closed"], }, { title: "[data-side]", value: ["top", "right", "bottom", "left"], }, { title: "[data-align]", value: ["start", "center", "end"], }, ]} />

<CSSVariablesTable variables={[ { title: "--dice-transform-origin", description: "Transform origin for anchor positioning.", }, { title: "--dice-anchor-width", description: "Width of the anchor element.", }, { title: "--dice-anchor-height", description: "Height of the anchor element.", }, { title: "--dice-available-width", description: "Available width in the viewport for the popover element.", }, { title: "--dice-available-height", description: "Available height in the viewport for the popover element.", }, ]} />

Arrow

A visual arrow element that points to the anchor.

<AutoTypeTable path="./types/docs/combobox.ts" name="ArrowProps" />

Loading

A loading indicator for asynchronous filtering operations.

<AutoTypeTable path="./types/docs/combobox.ts" name="LoadingProps" />

Empty

A placeholder component displayed when no options match the current filter.

<AutoTypeTable path="./types/docs/combobox.ts" name="EmptyProps" />

Group

A container for logically grouping related options.

<AutoTypeTable path="./types/docs/combobox.ts" name="GroupProps" />

GroupLabel

A label that describes a group of options.

<AutoTypeTable path="./types/docs/combobox.ts" name="GroupLabelProps" />

Item

An interactive item in the combobox list.

<AutoTypeTable path="./types/docs/combobox.ts" name="ItemProps" />

<DataAttributesTable attributes={[ { title: "[data-highlighted]", value: "Present when the item is highlighted", }, { title: "[data-disabled]", value: "Present when the item is disabled", }, { title: "[data-state]", value: ["checked", "unchecked"], }, ]} />

ItemText

The textual content of an item.

<AutoTypeTable path="./types/docs/combobox.ts" name="ItemTextProps" />

ItemIndicator

A visual indicator for selected options.

<AutoTypeTable path="./types/docs/combobox.ts" name="ItemIndicatorProps" />

Separator

A visual divider for separating options or groups.

<AutoTypeTable path="./types/docs/combobox.ts" name="SeparatorProps" />

Accessibility

Keyboard Interactions

<KeyboardShortcutsTable shortcuts={[ { keys: ["Enter"], description: "When open, selects the highlighted option. When a badge is highlighted in multiple mode, removes the badge." }, { keys: ["ArrowUp"], description: "When open, highlights the previous option." }, { keys: ["ArrowDown"], description: "When open, highlights the next option." }, { keys: ["ArrowLeft"], description: "In multiple mode: When cursor is at start of input, closes the menu and highlights the last badge. When a badge is highlighted, moves highlight to previous badge." }, { keys: ["ArrowRight"], description: "In multiple mode: When a badge is highlighted, moves highlight to next badge. If on last badge, removes highlight and focuses input." }, { keys: ["Backspace", "Delete"], description: "In multiple mode: When input is empty, removes the last badge. When a badge is highlighted, removes the highlighted badge." }, { keys: ["Home"], description: "When open, highlights the first option." }, { keys: ["End"], description: "When open, highlights the last option." }, { keys: ["PageUp"], description: "When open and modal is enabled, highlights the previous option." }, { keys: ["PageDown"], description: "When open and modal is enabled, highlights the next option." }, { keys: ["Escape"], description: "Closes the combobox popover, returns focus to the input, and resets or restores the input value." }, ]} />

ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

← Root | ↑ Up