CLI previewInstall commands shown on this site are not released yet.

DocsComponentsNavigation

Command

React example follows below.
ts
import { Command, type CommandGroup } from "@grassroot/ui-react";
const groups: CommandGroup[] = [
{ heading: "Actions", items: [{ label: "Deploy to prod", shortcut: "⌘R" }] },
];
const [open, setOpen] = React.useState(false);
<Command groups={groups} open={open} onOpenChange={setOpen} />
ts
<script setup lang="ts">
import { ref } from "vue";
import { Command } from "@grassroot/ui-vue";
const groups: CommandGroup[] = [
{ heading: "Actions", items: [{ label: "Deploy to prod", shortcut: "⌘R" }] },
];
const open = ref(false);
</script>
<template>
<Command :groups="groups" :open="open" />
</template>
ts
import { Component, signal } from "@angular/core";
import { GrassrootCommand } from "@grassroot/ui-angular";
@Component({
selector: "app-example",
standalone: true,
imports: [GrassrootCommand],
template: `
<grassroot-command [groups]="groups" [open]="open()" (openChange)="open.set($event)" />
`,
})
export class ExampleComponent {
readonly groups: CommandGroup[] = [
{ heading: "Actions", items: [{ label: "Deploy to prod", shortcut: "⌘R" }] },
];
readonly open = signal(false);
}
ts
<script lang="ts">
import { Command } from "@grassroot/ui-svelte";
const groups: CommandGroup[] = [
{ heading: "Actions", items: [{ label: "Deploy to prod", shortcut: "⌘R" }] },
];
let open = $state(false);
</script>
<Command groups={groups} open={open} onOpenChange={(next) => (open = next)} />
ts
import { createSignal } from "solid-js";
import { Command } from "@grassroot/ui-solid";
const groups: CommandGroup[] = [
{ heading: "Actions", items: [{ label: "Deploy to prod", shortcut: "⌘R" }] },
];
export function Example() {
const [open, setOpen] = createSignal(false);
return (
<>
<Command groups={groups} open={open()} onOpenChange={setOpen} />
</>
);
}

Installation

bash
pnpm dlx grassroot add ui/command
bash
npx grassroot@latest add ui/command
bash
yarn dlx grassroot add ui/command
bash
bunx grassroot add ui/command

API Reference

CommandProps
PropTypeDefault
groupsrequiredCommandGroup[]
openboolean | undefined
defaultOpenboolean | undefined
onOpenChange((open: boolean) => void) | undefined
placeholderstring | undefined
hotkeyBind ⌘K / Ctrl-K to toggle open.boolean | undefinedtrue