Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-command-palette>

@methane-ui/ui~10.1 KB brotli (cold + Lit)~3.2 KB marginal

Modal command palette (Cmd/Ctrl+K) with keyword filtering, active-descendant listbox navigation, top-layer <dialog>, and global hotkey binding.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-command-palette> (@methane-ui/ui)
Open Command Palette (Cmd+K)
Ready · interact with <mth-command-palette>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/command-palette"></script>
<mth-command-palette shortcut="mod+k" register-global-shortcut></mth-command-palette>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
openopenbooleanfalseControls whether the command palette dialog is visible.
queryquerystring""Current search filter query string.
labellabelstring""Accessible dialog label override.
placeholderplaceholderstring""Search input placeholder override.
shortcutshortcutstring"mod+k"Global hotkey combo used to toggle the command palette.
registerGlobalShortcutregister-global-shortcutbooleantrueWhether to bind the global hotkey listener on the document.
forceFallbackforce-fallbackbooleanfalseForces fallback modal overlay rendering instead of native <dialog>.showModal().
commands—ReadonlyArray<unknown>[]Command entries available for filtering and selection.

Events

EventDetail TypeDescription
mth-openvoidCancelable event dispatched before the command palette opens.
mth-closevoidCancelable event dispatched before the command palette closes.
mth-query-change{ query: string }Dispatched when the command search input value changes.
mth-select{ id: string; label: string; href?: string }Dispatched when a command option is chosen.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowDownbothinput focusedactivates next matching command
ArrowUpbothinput focusedactivates previous matching command
Enterbothcommand activeexecutes active command and closes dialog
Escapebothopencloses dialog and restores trigger focus

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 4 APG keyboard transitions across LTR/RTL.mth-command-palette.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(open), :state(empty).Conformance suite
i18nRoutes 6 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test