# V command 7

> With Recent And Favorites Sections

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/v-command-7).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/v-command-7
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/cnippet/v-command-7-light-53ff3aed018d372a.png
- Registry item: https://ui.cnippet.dev/r/v-command-7.json
- Categories: command
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/v-command-7.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/command`

## Files

### `registry/default/variants/v-command-7.tsx`

```tsx
"use client";

import {
  BookOpenIcon,
  ClockIcon,
  LifeBuoyIcon,
  MessageSquareIcon,
  StarIcon,
} from "lucide-react";
import { Fragment, useState } from "react";
import { Button } from "@/registry/default/ui/button";
import {
  Command,
  CommandCollection,
  CommandDialog,
  CommandDialogPopup,
  CommandDialogTrigger,
  CommandEmpty,
  CommandGroup,
  CommandGroupLabel,
  CommandInput,
  CommandItem,
  CommandList,
  CommandPanel,
  CommandSeparator,
} from "@/registry/default/ui/command";

type Item = {
  value: string;
  label: string;
  time?: string;
  icon: "star" | "clock" | "book" | "lifebuoy" | "message";
};

type Group = { value: string; label: string; items: Item[] };

const groups: Group[] = [
  {
    items: [
      { icon: "star", label: "Design System", value: "design-system" },
      { icon: "star", label: "API Documentation", value: "api-documentation" },
    ],
    label: "Starred",
    value: "starred",
  },
  {
    items: [
      {
        icon: "clock",
        label: "Dashboard Analytics",
        time: "2m ago",
        value: "dashboard-analytics",
      },
      {
        icon: "clock",
        label: "User Settings",
        time: "15m ago",
        value: "user-settings",
      },
      {
        icon: "clock",
        label: "Team Members",
        time: "1h ago",
        value: "team-members",
      },
      {
        icon: "clock",
        label: "Billing & Plans",
        time: "2h ago",
        value: "billing-plans",
      },
    ],
    label: "Recent",
    value: "recent",
  },
  {
    items: [
      { icon: "book", label: "Documentation", value: "documentation" },
      { icon: "lifebuoy", label: "Help & Support", value: "help-support" },
      { icon: "message", label: "Contact Us", value: "contact-us" },
    ],
    label: "Help",
    value: "help",
  },
];

const icons: Record<Item["icon"], React.ReactNode> = {
  book: <BookOpenIcon className="size-4 shrink-0" />,
  clock: <ClockIcon className="size-4 shrink-0 text-muted-foreground" />,
  lifebuoy: <LifeBuoyIcon className="size-4 shrink-0" />,
  message: <MessageSquareIcon className="size-4 shrink-0" />,
  star: <StarIcon className="size-4 shrink-0 text-yellow-500" />,
};

export default function Component() {
  const [open, setOpen] = useState(false);

  return (
    <CommandDialog onOpenChange={setOpen} open={open}>
      <CommandDialogTrigger render={<Button variant="outline" />}>
        Search Everything
      </CommandDialogTrigger>
      <CommandDialogPopup>
        <Command items={groups}>
          <CommandInput placeholder="Search or jump to..." />
          <CommandPanel>
            <CommandEmpty>No results found.</CommandEmpty>
            <CommandList>
              {(group: Group, index: number) => (
                <Fragment key={group.value}>
                  {index > 0 && <CommandSeparator />}
                  <CommandGroup items={group.items}>
                    <CommandGroupLabel>{group.label}</CommandGroupLabel>
                    <CommandCollection>
                      {(item: Item) => (
                        <CommandItem
                          className="gap-2"
                          key={item.value}
                          value={item.value}
                        >
                          {icons[item.icon]}
                          <span>{item.label}</span>
                          {item.time && (
                            <div
                              className="ml-auto"
                              data-slot="command-shortcut"
                            >
                              <span>{item.time}</span>
                            </div>
                          )}
                        </CommandItem>
                      )}
                    </CommandCollection>
                  </CommandGroup>
                </Fragment>
              )}
            </CommandList>
          </CommandPanel>
        </Command>
      </CommandDialogPopup>
    </CommandDialog>
  );
}
```
