Select

A common form component for choosing a predefined value in a dropdown menu.

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 { Select, SelectGroup, SelectGroupLabel, SelectItem, SelectPopup, SelectScrollDownButton, SelectScrollUpButton, SelectTrigger, SelectValue, SelectViewport } from "coss-svelte";

Anatomy

  • Select
  • SelectGroup
  • SelectGroupLabel
  • SelectItem
  • SelectPopup
  • SelectScrollDownButton
  • SelectScrollUpButton
  • SelectTrigger
  • SelectValue
  • SelectViewport

API Reference

Select

A common form component for choosing a predefined value in a dropdown menu.

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"Select"Placeholder text shown by the built-in input.
children : Snippet<[]>

Inherits from Bits UI Select.Root and Bits UI Select.Trigger.

SelectGroup

Groups related items inside the parent component.

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

Inherits from Bits UI Select.Group.

SelectGroupLabel

Labels a group of related items.

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

Inherits from Bits UI Select.GroupHeading.

SelectItem

Renders one selectable or repeated item.

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

Inherits from Bits UI Select.Item.

SelectPopup

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 Select.Content.

SelectScrollDownButton

Renders a button-shaped control for the parent component.

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

Inherits from Bits UI Select.ScrollDownButton.

SelectScrollUpButton

Renders a button-shaped control for the parent component.

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

Inherits from Bits UI Select.ScrollUpButton.

SelectTrigger

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 Select.Trigger.

SelectValue

Renders the current value for the parent component.

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

Inherits from Bits UI Select.Value.

SelectViewport

Wraps the scrollable viewport for the parent component.

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

Inherits from Bits UI Select.Viewport.

Implementation Details

Status
Stable
Foundation
bits
Category
Selection & Input
Particles
23