Command

A command palette component built with Dialog and Autocomplete for searching and executing commands.

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 { Command, CommandCollection, CommandDialog, CommandDialogPopup, CommandDialogTrigger, CommandEmpty, CommandFooter, CommandGroup, CommandGroupLabel, CommandInput, CommandItem, CommandList, CommandPanel, CommandSeparator, CommandShortcut } from "coss-svelte";

Anatomy

  • Command
  • CommandCollection
  • CommandDialog
  • CommandDialogPopup
  • CommandDialogTrigger
  • CommandEmpty
  • CommandFooter
  • CommandGroup
  • CommandGroupLabel
  • CommandInput
  • CommandItem
  • CommandList
  • CommandPanel
  • CommandSeparator
  • CommandShortcut

API Reference

Command

A command palette component built with Dialog and Autocomplete for searching and executing commands.

PropTypeDefaultDescription
bind:valuestring""Current value for the component. Bind with `bind:value` when supported.
itemsCommandItem[][]Items rendered by the component's built-in fallback composition.
placeholderstring"Type a command"Placeholder text shown by the built-in input.
labelstring"Command menu"Accessible label or fallback visible label for the control.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Command.Root.

CommandCollection

Connects repeated items to the parent collection state.

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

Inherits from Bits UI Command.GroupItems.

CommandDialog

Composes the parent component into a dialog-style surface.

PropTypeDefaultDescription
bind:openbooleanfalseOpen state for the popup or disclosure. Bind with `bind:open`.
children : Snippet<[]>

Inherits from Bits UI Dialog.Root.

CommandDialogPopup

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

CommandDialogTrigger

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

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

Inherits from Bits UI Dialog.Trigger.

CommandEmpty

Renders fallback content when the collection has no results.

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

Inherits from Bits UI Command.Empty.

CommandFooter

Groups footer content and actions for the parent component.

children : Snippet<[]>

Inherits from Svelte component attributes.

CommandGroup

Groups related items inside the parent component.

PropTypeDescription
forceMountbooleanKeeps content mounted while closed so transitions can complete.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Command.Group.

CommandGroupLabel

Labels a group of related items.

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

Inherits from Bits UI Command.GroupHeading.

CommandInput

Renders the input field for the parent component.

PropTypeDefaultDescription
bind:valuestring""Current value for the component. Bind with `bind:value` when supported.
bind:ref : HTMLElement | null

Inherits from Bits UI Command.Input.

CommandItem

Renders one selectable or repeated item.

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

Inherits from Bits UI Command.Item.

CommandList

Wraps a list of related items.

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

Inherits from Bits UI Command.List.

CommandPanel

Renders the main panel surface for the parent component.

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

Inherits from Bits UI Command.Viewport.

CommandSeparator

Visually separates related content.

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

Inherits from Bits UI Command.Separator.

CommandShortcut

Displays a keyboard shortcut hint.

children : Snippet<[]>

Inherits from Svelte component attributes.

Implementation Details

Status
Stable
Foundation
compound
Category
Overlays & Popups
Particles
2