terminal Grouped commands
groups Custom item snippet
list Without groups
Svelte
<script lang="ts">
import Command from "./Command.svelte";
import type { CommandItem, CommandGroup } from "./command.config";
let open = $state(false);
const items: CommandItem[] = [
{ id: "new-file", label: "New File", hint: "Ctrl+N", group: "file" },
{ id: "save", label: "Save", hint: "Ctrl+S", group: "file" },
{ id: "undo", label: "Undo", hint: "Ctrl+Z", group: "edit" },
];
const groups: CommandGroup[] = [
{ id: "file", label: "File" },
{ id: "edit", label: "Edit" },
];
</script>
<Button onclick={() => open = true}>Open Command</Button>
<Command
bind:open
{items}
{groups}
placeholder="Type a command…"
onselect={(item) => console.log(item.label)}
/> API
package_2
import type { CommandItem, CommandGroup } from '@abhc/spektral-ui';| Prop | Type | Default |
|---|---|---|
| open | boolean | false |
| items | CommandItem[] | — |
| groups | CommandGroup[] | [] |
| placeholder | string | "Search..." |
| empty_placeholder | string | "No results" |
| onselect | (item: CommandItem) => void | — |
| onclose | () => void | — |
| item | Snippet<[CommandItem]> | — |
| empty | Snippet | — |
| palette | "tone" | "accent" | "accentbg" | "tone" |
| rounded | boolean | false |
| elevation | "none" | "subtle" | "hard" | "subtle" |
| width | string | "560px" |
Prop open
Type
booleanDefault
falseProp items
Type
CommandItem[]Default
—Prop groups
Type
CommandGroup[]Default
[]Prop placeholder
Type
stringDefault
"Search..."Prop empty_placeholder
Type
stringDefault
"No results"Prop onselect
Type
(item: CommandItem) => voidDefault
—Prop onclose
Type
() => voidDefault
—Prop item
Type
Snippet<[CommandItem]>Default
—Prop empty
Type
SnippetDefault
—Prop palette
Type
"tone" | "accent" | "accentbg"Default
"tone"Prop rounded
Type
booleanDefault
falseProp elevation
Type
"none" | "subtle" | "hard"Default
"subtle"Prop width
Type
stringDefault
"560px"