j3w1 / theme

j3w1 / theme4.0.0

j3w1 / command

  • SPEC Overview
  • SPEC Foundations
  • SPEC Components
  • SPEC Patterns
  • SPEC Tokens
  • SPEC Tools
  • SPEC Workbench
  • SPEC Form builder
  • SPEC Task kit
  • SPEC Recipes
  • SPEC Figma bridge
  • SPEC Report an issue
  • SPEC Implement
  • SPEC For agents
  • SPEC Ports
  • SPEC Releases
  • SPEC Specification
  • DEMO Vue application demo

Command palette

A compact square modal command prompt with local results and category labels.

stable · light DOM · 4.0.0. Light DOM retains static content, native semantics, label relationships and host composition without duplicating controls.

Live variants

default

Command prompt

  • SPEC Explore foundations
  • BUILD Browse components
  • AGENT Prepare a copy kit

3 commands

Markup
<j3w1-command-palette id="example-command-palette-default"><div class="command-palette"><button class="command-palette-control" type="button" data-open="" data-demo-focus-target="">Search commands <kbd>Ctrl K</kbd></button><dialog class="command-palette-dialog" aria-labelledby="example-command-palette-default-command-title"><h2 id="example-command-palette-default-command-title">Command prompt</h2><label for="example-command-palette-default-command-query">Search commands</label><input class="command-palette-control" id="example-command-palette-default-command-query" type="search" role="combobox" aria-autocomplete="list" aria-expanded="true" aria-controls="example-command-palette-default-command-results" autocomplete="off"><ul id="example-command-palette-default-command-results" role="listbox" aria-label="Commands"><li role="option" id="example-command-palette-default-command-foundations" data-action="foundations"><span>SPEC</span> Explore foundations</li><li role="option" id="example-command-palette-default-command-components" data-action="components"><span>BUILD</span> Browse components</li><li role="option" id="example-command-palette-default-command-copy" data-action="copy"><span>AGENT</span> Prepare a copy kit</li></ul><p role="status" data-command-status="">3 commands</p><button class="command-palette-control" type="button" data-close="">Close</button></dialog></div></j3w1-command-palette>

Install and register

Use the exact version. If npm publication is pending, install the release tarball from the installation guide.

npm install --save-exact @j3w1/ui@4.0.0
import '@j3w1/ui/tokens.css';
import '@j3w1/ui/styles/command-palette.css';
import '@j3w1/ui/register/command-palette';

Insert the maintained markup above after loading these imports. Its native children provide accessible names and form behavior; the empty custom tag alone does not create a control.

Vue SFC, React, Astro and plain HTML integration →

Copy the complete implementation

npx --package=@j3w1/ui@4.0.0 j3w1-ui copy command-palette --out ./vendor/j3w1/command-palette

The CLI verifies every file before writing and refuses overwrites. Serve the output over HTTP and open index.html. Keep its modules, CSS, tokens and licence notices together.

Public API

attributes

NameType / signatureMeaning
disabledCustomEventDisable the native controls owned by this instance.
loadingCustomEventMark the primary control busy and prevent duplicate activation.
shortcutCustomEventOpt in to Ctrl+K / Cmd+K; absence leaves global shortcuts to the host.

properties

NameType / signatureMeaning
disabledbooleanDelegates disabled state to native children.
namestringNative control name; application form keys remain explicit.
openbooleanNative modal state.

methods

NameType / signatureMeaning
refresh(): voidReconnect behavior after replacing native child structure.
focus(options?: FocusOptions): voidFocus the first usable native control.
show(): voidOpen and focus the command prompt.
close(): voidClose and restore the opener.

events

NameType / signatureMeaning
j3w1-commandCustomEventInvoke the chosen command; prevent default to handle a result link yourself.

Dependencies and verification

Registered components: none. Style dependencies: none.

Package presence establishes an available implementation. Actual passes depend on the tested artifact and environment. Read specification execution evidence; read packed-consumer evidence; inspect the complete state matrix.

Full implementation manifest, API and token dependency closure

Canonical specification

Command palette command-palette

  • Family: Navigation
  • Maturity: stable
  • Priority: R2
  • Since: 1.0.0
  • Custom widget: combobox — APG pattern
  • specified
  • demonstrated

A compact square modal command prompt with local results and category labels.

Report an issue with this component

Tokens

Focus a role to inspect its values; follow its link for persistent usage and source details.

PartRoleValueUse
root.bgcolor.surface.defaultapproveduse#0d0707D-041 surface.default: color.primitive.modern.panel.
root.textcolor.text.defaultapproveduse#e99499D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
root.bordercolor.border.controlapproveduse#c81a1aD-041 owner correction: red control and floating-frame borders, distinct from rose text.
heading.textcolor.text.brightapproveduse#ffa2a7D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
secondary.textcolor.text.mutedapproveduse#d4868bD-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
control.bgcolor.surface.inputapproveduse#000000Form-control fill.
control.focuscolor.interaction.focus.ringobserveduse#e539351px dashed focus ring on controls and rows.
button.bgcolor.action.secondary.bgobservedusergb(0 0 0 / 0%)Secondary button has no fill.
button.textcolor.action.secondary.textapproveduse#ffa2a7D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
button.bordercolor.action.secondary.borderapproveduse#986f72D-041 action.secondary.border: color.primitive.modern.control.
button.bg-hovercolor.action.secondary.hover-bgobserveduse#630f0dSecondary button hover.
button.bg-activecolor.action.secondary.pressed-bgobserveduse#420f0cSecondary button pressed.
button.border-activecolor.border.activeobserveduse#e53935Active or focused control border.
button.focuscolor.interaction.focus.ringobserveduse#e539351px dashed focus ring on controls and rows.
dependency.role-border-width-defaultborder.width.defaultobserveduse1pxEvery border is 1px.
dependency.role-border-width-emphasisborder.width.emphasisobserveduse2pxSelected indicator, sticky header rule, invalid border.
dependency.role-color-border-overlaycolor.border.overlayapproveduse#c81a1aD-041 owner correction: red control and floating-frame borders, distinct from rose text.
dependency.role-color-border-selected-indicatorcolor.border.selected-indicatorobserveduse#e539352px indicator bar on the selected tab or nav item.
dependency.role-color-interaction-selection-bgcolor.interaction.selection.bgapproveduse#531310Selected row, tab, workspace; D-027 recessed the fill, leaving the 2px indicator and the check to carry selection.
dependency.role-color-interaction-selection-textcolor.interaction.selection.textobserveduse#f4eeeeText on the selection.
dependency.role-color-surface-backdropcolor.surface.backdropproposeduse-and-reportD-008rgb(0 0 0 / 65%)Behind modal dialogs.
dependency.role-color-surface-overlaycolor.surface.overlayapproveduse#1c1010D-041 surface.overlay: color.primitive.modern.overlay.
dependency.role-density-comfortable-control-heightdensity.comfortable.control-heightobserveduse32px
dependency.role-density-compact-control-heightdensity.compact.control-heightobserveduse24px
dependency.role-focus-offsetfocus.offsetobserveduse-2pxoutline-offset for controls.
dependency.role-radius-noneradius.noneobserveduse0pxThe only radius. Nothing is rounded.
dependency.role-space-12space.12observeduse12px
dependency.role-space-16space.16observeduse16px
dependency.role-space-8space.8observeduse8px

State matrix

Every declared state and combination, statically rendered; the default cell is live. Sizes: compact, comfortable (switch with the density control above).

StateDefault
default

Command prompt

  • SPEC Explore foundations
  • BUILD Browse components
  • AGENT Prepare a copy kit

3 commands

open
closed
focus-visible
no-results

Purpose

Finds and invokes local commands; navigation the site requires stays available outside the palette, without JavaScript.

Anatomy

Parts as listed in the anatomy.

States

StateVisualNon-colour channel
defaultOne prompt, dense command rows. Button controls are the secondary button (button.md); inputs keep the input look.Visible names and categories.
openSquare overlay surface and border.Native modal dialog; active-descendant relationship.
closedPanel absent.Opener stays focusable.
focus-visibleDashed input ring.Input keeps DOM focus while results change.
no-resultsMuted zero-results status.Explicit result count; no active descendant.

Keyboard

As in the key table. Shortcuts are never intercepted globally unless the host opts in, and one Escape closes the palette.

Accessibility

Each result’s name includes its category and command text. Selection uses the approved selected roles.

Portability

Follows the shared component defaults in spec/portability.md (section “Shared component defaults”).

Non-examples

Unlabelled controls, color-only status, drag-only operations, hidden required instructions, stolen focus or an invented service success.

Contrast report

7 declared pairs measured on resolved sRGB values with the WCAG 2.x formula; 0 waived (decorative only), 0 failing. A pass is a design target for the named role, not an application-wide conformance claim.

PairStateKindForegroundBackgroundRatioMinResult
command-palette default textdefaulttextcolor.text.default #e99499color.surface.default #0d07078.724.5pass
command-palette default borderdefaultuicolor.border.control #c81a1acolor.surface.default #0d07073.443pass
Primary content—textcolor.text.default #e99499color.surface.default #0d07078.724.5pass
Supporting content—textcolor.text.muted #d4868bcolor.surface.default #0d07077.224.5pass
Control boundary—uicolor.border.control #c81a1acolor.surface.default #0d07073.443pass
Button label—textcolor.action.secondary.text #ffa2a7color.surface.default #0d070710.454.5pass
Button label on hover—textcolor.action.secondary.text #ffa2a7color.action.secondary.hover-bg #630f0d6.844.5pass

Keys

KeyAction
Ctrl+K / Cmd+KOpen when the host explicitly enables the shortcut.
Up / DownMove the active result while retaining input focus.
EnterInvoke the active enabled result and close.
EscapeClose and restore the opener.
Tab / Shift+TabCycle through native modal controls.

For agents

Component JSON ·Implementation brief ·Build a task kit ·

Stress fixtures: FX-320 FX-360 FX-ZOOM-200 FX-I18N FX-RTL FX-RM FX-HC FX-TOUCH FX-DENSITY FX-STATE-MATRIX