---
title: "Search dialog"
description: "Search your docs from a dialog opened with a keyboard shortcut."
url: https://docscn.dev/docs/components/search-dialog
lastModified: 2026-10-28T02:05:06.000Z
---

# Search dialog (/docs/components/search-dialog)

> Search your docs from a dialog opened with a keyboard shortcut.

## Installation [#installation]

```npm
npx shadcn@latest add @docscn/search-dialog-default
```

## Usage [#usage]

`RootProvider` opens the default search dialog with <kbd>⌘</kbd> <kbd>K</kbd> (<kbd>Ctrl</kbd> <kbd>K</kbd> on Windows and Linux), or from the search triggers in the layouts. It queries `/api/search`, which you create with Fumadocs Core's search server:

```ts title="app/api/search/route.ts"
import { createFromSource } from "fumadocs-core/search/server";
import { source } from "@/lib/source";

export const { GET } = createFromSource(source);
```

Results show pages, headings, text and table rows. Use the arrow keys and <kbd>Enter</kbd> to open one, and <kbd>Esc</kbd> to close the dialog. If a search fails, the dialog says so above the results of the last search that worked.

Matches are highlighted with the [CSS Custom Highlight API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API), in your `--primary` colour and underlined. Style them with `::highlight(fd-search)`.

## Options [#options]

Pass options to the default dialog through `RootProvider`:

```tsx
<RootProvider
  search={{
    options: {
      api: "/api/search",
      delayMs: 100,
      tags: [{ name: "Guides", value: "guides" }],
    },
    links: [["Getting started", "/docs/getting-started"]],
  }}
>
```

| Option       | Type             | Description                                    |
| ------------ | ---------------- | ---------------------------------------------- |
| `api`        | `string`         | The search API URL. Defaults to `/api/search`. |
| `delayMs`    | `number`         | Debounce delay before searching.               |
| `tags`       | `TagItem[]`      | Tag filters shown below the results.           |
| `defaultTag` | `string`         | The tag selected at first.                     |
| `allowClear` | `boolean`        | Allow deselecting the tag.                     |
| `footer`     | `ReactNode`      | Extra content at the bottom of the dialog.     |
| `links`      | `[name, href][]` | Links shown before the reader types a query.   |

## Build your own dialog [#build-your-own-dialog]

The `search-dialog` component exports the parts the default dialog is made of, for other search clients. Fumadocs Core has a search hook for each client, like `useAlgoliaSearch()` or `useOramaCloudSearch()`, and `experimental_useSearch()` for others. They return the dialog's props:

```tsx
import { useFetchSearch } from "fumadocs-core/search/client";
import {
  SearchDialog,
  SearchDialogClose,
  SearchDialogContent,
  SearchDialogHeader,
  SearchDialogIcon,
  SearchDialogInput,
  SearchDialogList,
  SearchDialogOverlay,
  type SharedProps,
} from "@/components/docs/components/dialog/search";

export default function CustomSearchDialog(props: SharedProps) {
  const search = useFetchSearch({ api: "/api/search" });

  return (
    <SearchDialog {...search} {...props}>
      <SearchDialogOverlay />
      <SearchDialogContent>
        <SearchDialogHeader>
          <SearchDialogIcon />
          <SearchDialogInput />
          <SearchDialogClose />
        </SearchDialogHeader>
        <SearchDialogList />
      </SearchDialogContent>
    </SearchDialog>
  );
}
```

`SearchDialogList` shows the results of the last search, or its `defaultItems` before the reader types. Pass `Item` or `Table` to render results your own way.

Pass it to `RootProvider` as `search={{ SearchDialog: CustomSearchDialog }}`. The dialog is built on Base UI's `Dialog`, the primitive under shadcn/ui's `dialog`, with shadcn/ui `kbd`.