Searching Puzzle Pieces

Type to search Puzzle Pieces.

Command

A command palette — filtered, grouped, keyboard-driven quick actions in a modal on the native dialog element. The parent owns the open flag and decides what each selection does. The overlay rides @magic-spells/dialog-panel, the same web component behind Dialog, Alert Dialog, Sheet and Bottom Sheet — one scrim, one fade in and out, one open/close machine across the family.

New file⌘ N
New window
Open…⌘ O
Undo⌘ Z
Redo
Copy⌘ C
Paste⌘ V
Toggle sidebar
Command palette⌘ K
Zoom in

Installation

Copy the piece into your app — it compiles with your build and the code is yours:

puzzle add piece command

Like Dialog, Alert Dialog, Sheet and Bottom Sheet, this piece has a runtime dependency: the web component it wraps. If you use any of those it is installed once and shared.

npm install @magic-spells/dialog-panel

Then merge the component's stylesheet into your app's style entry (app/styles/styles.css). It owns the overlay transport — the state-driven fade of both the scrim and the panel, the backdrop element, and the page scroll lock. Without it the palette is an unstyled native dialog with no animation and no scrim:

/* app/styles/styles.css */
@import "tailwindcss";
@import "@magic-spells/dialog-panel/css" layer(components);

layer(components) is not optional cosmetics: the stylesheet uses plain element selectors, and an unlayered import would outrank every Tailwind utility on the panel — including the width cap and the surface color this piece sets.

Requires the pieces.css tokens merged into your app styles (see Introduction).

Usage

import Command from '@/components/ui/Command.pzl';
<Command open={ commandOpen } items={ commandItems } @select={ runCommand } @close={ closeCommand } />
// The option element, ARIA, and handlers stay owned by Command.
// Command has no persistent selection, so selected is always false.
<Command open={ commandOpen } items={ commands } @select={ runCommand } @close={ closeCommand }>
  <Snippet fits="option" item active selected disabled>
    <img class="size-6 rounded-full" src={ item.avatar } alt="" />
    <span class="truncate">{ item.name }</span>
  </Snippet>
</Command>

Keyboard

The input holds focus the moment the palette opens. Type to filter — matching is a word-prefix first, then a loose substring, and each item's keywords count too. The arrow keys move the active row, Enter runs it, and Escape closes the palette. Open the palette above and try it.

The global hotkey to open the palette is the parent's job — bind Cmd/Ctrl+K in a layout and flip the open flag there. Command never binds a page-wide shortcut itself.

Escape and a click on the scrim close the palette themselves and report through @close once the exit fade has finished — flip the open flag false there. A close the parent asks for, by flipping open after a selection, is never reported back.