Command palette

Search and run actions from the keyboard (Mantine's Spotlight): fuzzy search, groups, shortcuts, ⌘K / Ctrl+K; combobox + listbox pattern in a modal dialog.

Source on GitHub

Open command palette

On this site ⌘K belongs to the docs search in the header — another ray-command-palette, over the components and guides. This one has hotkey="" and opens with the button.

Code

In a raylang app

With native-menus and the native bridge, the palette also lists the app's menu bar: every item, grouped by its menu, with its shortcut, the disabled ones greyed out. Running one gives the program the same "menu" event as choosing it in the menu bar, so the program handles it in one place.

let n = bridge.system();
bridge.menu(n, "File", [ui.item("new", "New window", "cmd+n"), ui.item("open", "Open…", "cmd+o")])?;
for raw in ui.events() {
    let e = match (bridge.route(n, raw)) {
        Option.Some(e) => e,
        Option.None => continue,
    };
    if (e.kind == "menu" && e.tag == "new") {
        new_window()?;
    }
}
<ray-command-palette native-menus></ray-command-palette>

Declare the menus with bridge.menu (and change them with bridge.replace_menu and bridge.set_menu_item) so the palette knows them.

API

For AI agents: this API as Markdown, or every component in llms-full.txt.

<ray-command-palette> · RayCommandPalette

Running an action fires ray-select and calls its onSelect. The best matches come first, grouped.

PropertyAttributeTypeDefaultDescription
openopen reflectsbooleanShown.
actions—arrayThe actions.
queryquerystringThe search text.
placeholderplaceholderstringSearch commands… (text command-palette.placeholder)Placeholder of the search field.
hotkeyhotkeystringmod+kToggle shortcut (mod = ⌘ on macOS, Ctrl elsewhere); empty to disable.
limitlimitnumber50Maximum results.
emptyLabelempty-labelstringNothing found (text command-palette.empty)Text without results.
labellabelstringCommand palette (text command-palette.label)Accessible name.
hideHinthide-hint reflectsbooleanNo keyboard hint at the bottom.
navigateLabelnavigate-labelstringnavigate (text command-palette.navigate)The keyboard hint's word for ↑↓.
runLabelrun-labelstringrun (text command-palette.run)The keyboard hint's word for ↵.
closeLabelclose-labelstringclose (text command-palette.close)The keyboard hint's word for esc.
nativeMenusnative-menus reflectsbooleanWith a native host (ray-elements/core/raylang.js in a std/ui window, menus declared with elements/bridge), also lists the app's menu bar, grouped by menu with its shortcuts (an item of a submenu under its path, "File › Open Recent"); running one gives the program the menu's own event.
overlayBluroverlay-blurstringBlur of the page behind: px ("8"), a CSS length or "none". Default: --ray-overlay-blur ([overlay] blur in tokens.toml).
EventDescription
ray-selectAn action was run.
ray-openAfter it opened.
ray-closeAfter it closed.
PartDescription
dialogThe dialog.
inputThe search field.
optionEach result.

Texts

What it writes itself, in English; setStrings() translates them (Getting started: Languages).

KeyEnglish
command-palette.labelCommand palette
command-palette.placeholderSearch commands…
command-palette.emptyNothing found
command-palette.navigatenavigate
command-palette.runrun
command-palette.closeclose
command-palette.shortcutShortcut {shortcut}