OverlaysCommandPalette
⌘K launcher with fuzzy filtering over grouped commands and keyboard navigation.
CommandPalette
CommandPaletteProps props| Prop | Type | Default | Description |
|---|
open | boolean | — | Controlled open state. |
onClose | () => void | — | Called on Escape or backdrop click. |
groups | CommandGroup[] | — | Grouped commands to filter and display. |
onRun | (command: Command) => void | — | Called when a command is selected. |
placeholder | string | "Type a command or search…" | Search input placeholder. |
renderCommand | (command: Command, state: { active: boolean }) => ReactNode | — | Replaces a row's contents. The row button, its padding and its active background stay Onset's, so a custom row still highlights and scrolls into view. |
Command shape props| Prop | Type | Default | Description |
|---|
id | string | — | Unique identifier. |
label | string | — | Display label. |
keywords | string | — | Extra strings to match against (aliases, record IDs). |
icon | ReactNode | — | Leading icon. |
shortcut | ReactNode | — | Keyboard shortcut hint on the right. |
hint | ReactNode | — | Dim right-side annotation (e.g. record type). |
CommandGroup shape props| Prop | Type | Default | Description |
|---|
label | ReactNode | — | Group heading. |
commands | Command[] | — | Commands in this group. |
Basic usage with useCommandKCopy link
ImportTSXimport { CommandPalette, useCommandK, Button } from "@solarius/onset";
import { IconHome, IconSettings, IconUser } from "@tabler/icons-react";
import { useState } from "react";
function Example() {
const [open, setOpen] = useState(false);
useCommandK(() => setOpen(true));
const groups = [
{
label: "Navigation",
commands: [
{
id: "home",
label: "Home",
icon: <IconHome size={14} />,
hint: "Dashboard",
},
{
id: "settings",
label: "Settings",
icon: <IconSettings size={14} />,
shortcut: "⌘,",
},
],
},
{
label: "People",
commands: [
{
id: "profile",
label: "View profile",
icon: <IconUser size={14} />,
keywords: "account",
},
],
},
];
return (
<>
<Button onClick={() => setOpen(true)}>⌘K</Button>
<CommandPalette
open={open}
onClose={() => setOpen(false)}
groups={groups}
onRun={(cmd) => {
console.log("Run:", cmd.id);
setOpen(false);
}}
/>
</>
);
}
useCommandKTSXimport { useCommandK } from "@solarius/onset";
function App() {
const [open, setOpen] = useState(false);
useCommandK(() => setOpen(true));
return (/* ... */);
}