Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Command Palette

Command list that opens as a dialog, with fuzzy, ranked search and shortcut hints.

ComponentsCommand Palette
feedbackinteractive
<arc-command-palette>

Overview

CommandPalette is a modal dialog with a search field, a list of commands and a footer of key hints. You open it by setting `open`, usually from a Cmd+K handler or a button. The palette doesn't bind any shortcut itself. Commands are `<arc-command-item>` children. An item's text content is its label, and it can add an `icon`, a `shortcut` hint, `keywords` that are searched but never shown, and a `description` that's shown as a second line and also searched. Search is fuzzy and ranked: "cmdpal" finds "Command Palette", terms can come in any order, and the best matches come first with the matched characters marked. Only the top `max-results` (50 by default) are rendered. Picking an item fires `arc-select` with its `value`, or its label if it has no value, and closes the palette. Escape and a click on the backdrop close it too. Each of these fires a cancelable `arc-close`, so `preventDefault()` keeps the palette open. Setting `open` to `false` from code closes it without the event. For a search field that's always on screen, use CommandBar.

Guidelines

Do

  • Write labels as short actions, such as "Open file" or "Toggle theme"
  • Add `shortcut` to items that have a key binding
  • Give items a `value` when two of them could share a label, so your `arc-select` handler can tell them apart

Don't

  • Don't put forms or other interactive content in an item. The palette renders its own copy of each item from its text, so anything else is lost

Features

  • Opens with a scale-in transition. The search input takes focus and the query clears on every open
  • Arrow Up and Arrow Down move the highlight, Enter selects and Escape closes
  • Body scroll is locked while it's open, and focus returns to where it was when it closes
  • When nothing matches, the empty state repeats the query
  • The backdrop is `::backdrop`, which can't be a CSS part. Style it with `--palette-backdrop`

Preview

Open command palette New file Open file Save Toggle dark mode Go to settings Sign out

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<arc-button onclick="document.querySelector('#palette').open = true">Open Palette</arc-button>
<arc-command-palette id="palette">
  <arc-command-item shortcut="⌘O">Open File</arc-command-item>
  <arc-command-item shortcut="⌘S">Save File</arc-command-item>
</arc-command-palette>

API

placeholderstring'Type a command...'
Placeholder text displayed in the search input when the query is empty.
max-resultsnumber50
How many ranked results to render. Truncation happens after ranking, so what survives is the best of the set. Raise it for a short command list; the default suits a large one.
openbooleanfalse
Controls whether the palette is visible. When set to true, the dialog animates in, the search input auto-focuses, and body scroll is locked. Set to false to close.

Events

arc-selectdetail:{ value: string, item: { label: string, shortcut: string, value: string } }
Fired when a command item is selected. detail.value is the item's value, falling back to its label.
arc-close
Fired when the palette closes

CommandItem

<arc-command-item>

One command in a CommandPalette. Its text content is the label.

label
selectionValue
What arc-select reports. Falls back to the label so an item that never sets value behaves as it always did.
shortcutstring''
Keyboard shortcut hint
iconstring''
Name of the icon to display before the item label.
keywordsstring''
Extra space-separated terms the search filter matches against but never displays, e.g. keywords="dialog popup" on a Modal item.
descriptionstring''
Secondary line shown under the label and matched by search. Use it for the sentence that tells two similar results apart; a docs site can put the matching passage here so a query finds page content rather than only page titles.
valuestring''
Stable identifier carried on the arc-select detail. Defaults to the label, which is fine until two items share one; give anything a handler must act on its own value rather than matching against display text.

CommandGroup

<arc-command-group>

Puts CommandItems under a small uppercase heading. Items in groups still filter and move as one flat list, groups are ordered by their best match, and a heading hides when none of its items match.

headingstring''
Heading text displayed above the group’s items.

See also