# Command: Pages

> An item with `page` opens the matching `<CommandPage />`. The page title appears as a chip in the input, the list slides in from the side, and Backspace on an empty search or Escape goes back.

Example: https://hextaui.com/docs/command/examples/pages
Component docs: https://hextaui.com/docs/command.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/command-pages.json
```

This adds `components/examples/command/pages.tsx` with the Command component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/command/pages.tsx"
"use client"

import * as React from "react"
import {
  IconBrandGithub,
  IconFolder,
  IconFolderPlus,
  IconUsers,
} from "@tabler/icons-react"

import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandPage,
} from "@/components/ui/command"

const projects = ["hextaui", "marketing-site", "design-tokens"]
const members = ["Ada Lovelace", "Grace Hopper", "Alan Turing"]

export function CommandPages() {
  const [last, setLast] = React.useState<string>()

  return (
    <div className="flex w-full max-w-sm flex-col gap-3">
      <Command>
        <CommandInput placeholder="Search…" />
        <CommandList>
          <CommandEmpty>No results found.</CommandEmpty>
          <CommandGroup heading="Workspace">
            <CommandItem page="projects" pageTitle="Projects">
              <IconFolder />
              Projects
            </CommandItem>
            <CommandItem page="members" pageTitle="Members">
              <IconUsers />
              Members
            </CommandItem>
            <CommandItem onSelect={() => setLast("New project")}>
              <IconFolderPlus />
              New project
            </CommandItem>
          </CommandGroup>
          <CommandPage id="projects">
            <CommandGroup heading="Projects">
              {projects.map((project) => (
                <CommandItem key={project} onSelect={setLast}>
                  <IconBrandGithub />
                  {project}
                </CommandItem>
              ))}
            </CommandGroup>
          </CommandPage>
          <CommandPage id="members">
            <CommandGroup heading="Members">
              {members.map((member) => (
                <CommandItem key={member} onSelect={setLast}>
                  <IconUsers />
                  {member}
                </CommandItem>
              ))}
            </CommandGroup>
          </CommandPage>
        </CommandList>
      </Command>
      <p className="text-sm text-muted-foreground">
        {last ? `Selected “${last}”.` : "Nothing selected yet."}
      </p>
    </div>
  )
}
```

## Props in this example

### CommandInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `placeholder` | `string` | – |  |

### CommandGroup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `ReactNode` | – |  |

### CommandItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `onSelect` | `(value: string) => void` | – | Runs on click, Enter or the item’s shortcut, after the confirm blink. |
| `page` | `string` | – | Opens the CommandPage with this id instead of running. |
| `pageTitle` | `string` | – | Title shown in the page chip. Defaults to the value. |

### CommandPage

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id` | `string` | – | Matches the page prop of the item that opens it. Its groups and items only render while it is the current page. |

## More Command examples

- [Basic](https://hextaui.com/docs/command/examples/basic.md)
- [Dialog](https://hextaui.com/docs/command/examples/dialog.md)
- [Scrollable](https://hextaui.com/docs/command/examples/scrollable.md)
- [Async results](https://hextaui.com/docs/command/examples/async.md)
- [Long content](https://hextaui.com/docs/command/examples/long-content.md)
- [Right to left](https://hextaui.com/docs/command/examples/rtl.md)
