Combobox

An input combined with a list of predefined items to select.

Installation

Install the component package, shared coss-svelte theme, and Bits UI peer.

npm install coss-svelte @coss-svelte/theme bits-ui

Usage

Import the Svelte component exports directly from the package.

import { Combobox, ComboboxClear, ComboboxCollection, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxList, ComboboxPopup, ComboboxSeparator, ComboboxTrigger, ComboboxValue } from "coss-svelte";

Anatomy

  • Combobox
  • ComboboxClear
  • ComboboxCollection
  • ComboboxEmpty
  • ComboboxGroup
  • ComboboxGroupLabel
  • ComboboxInput
  • ComboboxItem
  • ComboboxList
  • ComboboxPopup
  • ComboboxSeparator
  • ComboboxTrigger
  • ComboboxValue

API Reference

Combobox

An input combined with a list of predefined items to select.

Signatures

{ type?: "single"; value?: string; onValueChange?: OnChangeFn<string> }{ type: "multiple"; value?: string[]; onValueChange?: OnChangeFn<string[]> }
PropTypeDefaultDescription
type"single" | "multiple""single"Behavior, selection, or HTML type passed to the underlying control.
bind:valuestring | string[]""Current value for the component. Bind with `bind:value` when supported.
bind:openbooleanfalseOpen state for the popup or disclosure. Bind with `bind:open`.
optionsOption[][]Options rendered by the component's built-in fallback composition.
placeholderstring"Choose"Placeholder text shown by the built-in input.
children : Snippet<[]>

Inherits from Bits UI Combobox.Root and Bits UI Combobox.Input.

ComboboxClear

Renders a control that clears the current value.

children : Snippet<[]>

Inherits from Svelte component attributes.

ComboboxCollection

Connects repeated items to the parent collection state.

children : Snippet<[]>

Inherits from Svelte component attributes.

ComboboxEmpty

Renders fallback content when the collection has no results.

children : Snippet<[]>

Inherits from Svelte component attributes.

ComboboxGroup

Groups related items inside the parent component.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.Group.

ComboboxGroupLabel

Labels a group of related items.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.GroupHeading.

ComboboxInput

Renders the input field for the parent component.

PropTypeDefaultDescription
showTriggerbooleantrueShows a trigger button beside the input.
triggerProps(Omit<{}, "child" | "children"> & { child?: Snippet<[{ props: Record<string, unknown> }]> | undefined; children?: Snippet<[]> | undefined; style?: StyleProperties | string | null | undefined; ref?: HTMLElement | null | undefined } & Without<BitsPrimitiveButtonAttributes, SelectTriggerPropsWithoutHTML>){}Props forwarded to the optional trigger button.
bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.Input and Bits UI Combobox.Trigger.

ComboboxItem

Renders one selectable or repeated item.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.Item.

ComboboxList

Wraps a list of related items.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.Viewport.

ComboboxPopup

Renders the floating or modal surface for the parent component.

PropTypeDefaultDescription
portalProps{ disabled?: boolean; to?: PortalTarget }{}Configures the exact Bits Portal target (`to`) or renders inline when `disabled`.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.Content.

ComboboxSeparator

Visually separates related content.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.Separator.

ComboboxTrigger

Renders the control that opens, closes, or selects related content.

children : Snippet<[]>child : Snippet<[{ props: Record<string, unknown> }]>bind:ref : HTMLElement | null

Inherits from Bits UI Combobox.Trigger.

ComboboxValue

Renders the current value for the parent component.

children : Snippet<[]>

Inherits from Svelte component attributes.

Implementation Details

Status
Stable
Foundation
bits
Category
Selection & Input
Particles
18