Skip to content

Components

CommandPalette

Go to page

Component reference

Properties

Use CommandPalette

A modal search surface for navigating pages or running commands.

Example import style
command-palette.tsxTSX
"use client";

import { FloodRoot, CommandPalette, Button } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <CommandPalette title="Go to page" searchLabel="Search pages" trigger={props => <Button {...props}>Go to page</Button>} items={[{id:"projects",label:"All projects"}]} onAction={id => console.log(id)} />
    </FloodRoot>
  );
}

Design notes

  • Choose comfortable or compact density. Items can be grouped, described or disabled.
  • Opening focuses search. Enter or click runs an enabled action and requests closure. Escape and the close button return focus to the trigger.
  • Use controlled query and loading for asynchronous search. The application owns requests, navigation and any global shortcut.

API reference

PropValuesDefault
titlestringRequired
trigger(props: OverlayTriggerProps) => ReactNodeRequired
openboolean—
defaultOpenbooleanfalse
onOpenChange(open: boolean) => void—
disabledboolean—
closeLabelstring—
closeOnOutsideClickboolean—
getFallbackFocus() => HTMLElement | null—
searchLabelstringRequired
itemsreadonly CommandListItem[]Required
density"comfortable" | "compact""comfortable"
querystring—
defaultQuerystring—
onQueryChange(query: string) => void—
onAction(id: string) => voidRequired
loadingboolean—
placeholderstring—
emptyMessagestring—
loadingMessagestring—
Native HTML propsOmit<Omit<HTMLAttributes<HTMLDialogElement>, "children" | "title" | "role">, "children" | "description" | "initialFocusRef">Forwarded
View TypeScript source