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.
On this site ray-command-palette, over the components and guides. This one has hotkey="" and opens with the button.
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.
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
open | open reflects | boolean | Shown. | |
actions | — | array | The actions. | |
query | query | string | The search text. | |
placeholder | placeholder | string | Search commands… (text command-palette.placeholder) | Placeholder of the search field. |
hotkey | hotkey | string | mod+k | Toggle shortcut (mod = ⌘ on macOS, Ctrl elsewhere); empty to disable. |
limit | limit | number | 50 | Maximum results. |
emptyLabel | empty-label | string | Nothing found (text command-palette.empty) | Text without results. |
label | label | string | Command palette (text command-palette.label) | Accessible name. |
hideHint | hide-hint reflects | boolean | No keyboard hint at the bottom. | |
navigateLabel | navigate-label | string | navigate (text command-palette.navigate) | The keyboard hint's word for ↑↓. |
runLabel | run-label | string | run (text command-palette.run) | The keyboard hint's word for ↵. |
closeLabel | close-label | string | close (text command-palette.close) | The keyboard hint's word for esc. |
nativeMenus | native-menus reflects | boolean | With 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. | |
overlayBlur | overlay-blur | string | Blur of the page behind: px ("8"), a CSS length or "none". Default: --ray-overlay-blur ([overlay] blur in tokens.toml). |
| Event | Description |
|---|---|
ray-select | An action was run. |
ray-open | After it opened. |
ray-close | After it closed. |
| Part | Description |
|---|---|
dialog | The dialog. |
input | The search field. |
option | Each result. |
Texts
What it writes itself, in English; setStrings() translates them (Getting started: Languages).
| Key | English |
|---|---|
command-palette.label | Command palette |
command-palette.placeholder | Search commands… |
command-palette.empty | Nothing found |
command-palette.navigate | navigate |
command-palette.run | run |
command-palette.close | close |
command-palette.shortcut | Shortcut {shortcut} |