Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation

CommandPalette

Modal ⌘K command palette — the L1 Dialog backdrop/overlay wrapping the L1 Combobox: grouped, searchable commands with icon/hash/kind sub-parts.

All components · Theme builder · Implementation source

Live preview

Open live command-palette preview

Install

Shell
netscript ui:add command-palette

Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

TypeScript
import { useState } from 'preact/hooks';
import { Button } from '@app/components/ui/button.tsx';
import { CommandPalette } from '@app/components/ui/command-palette.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><div><Button onClick={() => setOpen(true)}>Open commands</Button><CommandPalette open={open} onOpenChange={setOpen} groups={[{id:"orders",label:"Orders",items:[{id:"create",label:"Create order",onSelect:()=>report("Order created")}]}]} /></div></div><p role="status">{notice}</p></>);
}

Props

Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

OwnerPropTypeOptionalDescription
CommandPalettePropsopenbooleanYes
CommandPalettePropsonOpenChange(open: boolean) => voidYes
CommandPalettePropsgroupsCommandGroup[]No
CommandPalettePropsplaceholderstringYes
CommandPalettePropsemptyLabelstringYes
CommandPalettePropsclassstringYes
CommandPalettePropsloadingbooleanYes
CommandPalettePropsloadingLabelstringYes
CommandPalettePropssearchLabelstringYes
CommandPalettePropsdialogLabelstringYesLocalized accessible name of the modal.
CommandPalettePropsonQueryChange(query: string) => voidYesUser edits only; async search and its results remain caller-owned.
CommandPalettePropsscrimbooleanYesFalse renders an inline surface without modal focus capture.
CommandPalettePropsfiltersRenderableYes
CommandPalettePropsfooterRenderableYes
TypeScript
type CommandItemType = "page" | "section" | "action"

Keyboard

KeyAction
ArrowDown/ArrowUpNavigate matching enabled options using the existing combobox active descendant.
Home/EndHighlight first/last matching enabled option.
EnterInvoke the highlighted command once and request modal close; IME composition does not activate commands.
EscapeRequest modal close once; controlled refusal preserves focus and options. Inline mode clears the query.
Tab/Shift+TabNative modal focus containment or inline control traversal; options remain in the active-descendant list, not the tab order.

Tokens

Semantic contract roles: border/default, border/subtle, marker/default, radius/card, surface/card, surface/selected, surface/surface, text/fg, text/muted.

CSS custom properties referenced directly: --ns-bg, --ns-border, --ns-border-subtle, --ns-border-width, --ns-card, --ns-control-gap, --ns-control-height, --ns-fg, --ns-font-eyebrow, --ns-font-mono, --ns-font-sans, --ns-label-tracking, --ns-leading-body, --ns-leading-caption, --ns-leading-label, --ns-leading-small, --ns-leading-strong, --ns-marker, --ns-muted, --ns-muted-fg, --ns-overlay, --ns-radius-badge, --ns-radius-card, --ns-radius-control, --ns-ring, --ns-selected, --ns-shadow-md, --ns-size-icon-md, --ns-space-1, --ns-space-10, --ns-space-14, --ns-space-2, --ns-space-24, --ns-space-4, --ns-space-8, --ns-surface, --ns-surface-raised, --ns-text-body, --ns-text-caption, --ns-text-label, --ns-text-small, --ns-text-strong, --ns-tracking-body, --ns-tracking-caption, --ns-tracking-label, --ns-weight-body, --ns-weight-caption, --ns-weight-eyebrow, --ns-weight-label, --ns-weight-strong.

Contract and compatibility

Accessibility pattern: WAI-ARIA guidance

  • Existing root and item fields remain supported; native DOM attributes do not pass through beyond class.
  • Phase-one metadata correction: content/type/state describe derived output or item fields, not invented root props; excerpt/url/kind/shortcut are optional item content and filters/footer are slots.
  • Headless data-state compatibility values remain unchanged; data-highlighted identifies current keyboard/pointer highlight.
  • Local filtering matches label, url, excerpt, kind and hash text in source order; Pagefind/backend requests and navigation remain caller-owned.
  • Disabled options remain visible but are excluded from headless arrow registration and activation. Empty/loading feedback is outside the listbox.
  • Modal and inline composition share existing Dialog/Combobox; no new focus manager. Native IME editing is preserved.

Design contract values marked planned are not implementation props. The props above describe what ships today.

Search all documentation

Type a term to search the documentation.