# V command 4

> Command With File Search

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

- Page, with a live preview: https://shadcn.exchange/r/cnippet/v-command-4
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/cnippet/v-command-4-light-62798021cae7cf5e.png
- Registry item: https://ui.cnippet.dev/r/v-command-4.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-4.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-4.tsx`

```tsx
"use client";

import { FileIcon, SearchIcon } from "lucide-react";
import { useState } from "react";
import { Badge } from "@/registry/default/ui/badge";
import { Button } from "@/registry/default/ui/button";
import {
  Command,
  CommandDialog,
  CommandDialogPopup,
  CommandDialogTrigger,
  CommandEmpty,
  CommandInput,
  CommandItem,
  CommandList,
  CommandPanel,
} from "@/registry/default/ui/command";
import { Kbd } from "@/registry/default/ui/kbd";

const files = [
  { name: "page.tsx", path: "src/app/page.tsx", type: "tsx" },
  { name: "layout.tsx", path: "src/app/layout.tsx", type: "tsx" },
  { name: "globals.css", path: "src/styles/globals.css", type: "css" },
  { name: "utils.ts", path: "src/lib/utils.ts", type: "ts" },
  { name: "api.ts", path: "src/lib/api.ts", type: "ts" },
  { name: "button.tsx", path: "src/components/ui/button.tsx", type: "tsx" },
  { name: "package.json", path: "package.json", type: "json" },
  { name: "README.md", path: "README.md", type: "md" },
];

type File = (typeof files)[number];

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

  return (
    <CommandDialog onOpenChange={setOpen} open={open}>
      <CommandDialogTrigger
        render={<Button className="w-52" variant="outline" />}
      >
        <SearchIcon className="size-4 shrink-0" />
        Search files...
        <Kbd className="ml-auto">⌘K</Kbd>
      </CommandDialogTrigger>
      <CommandDialogPopup>
        <Command items={files}>
          <CommandInput placeholder="Search files by name..." />
          <CommandPanel>
            <CommandEmpty>No files found.</CommandEmpty>
            <CommandList>
              {(file: File) => (
                <CommandItem
                  className="gap-2"
                  key={file.path}
                  value={file.name}
                >
                  <FileIcon className="size-4 shrink-0" />
                  <div className="flex flex-1 items-center gap-2 overflow-hidden">
                    <span className="font-medium">{file.name}</span>
                    <span className="truncate text-muted-foreground text-xs">
                      {file.path}
                    </span>
                  </div>
                  <div className="ml-auto" data-slot="command-shortcut">
                    <Badge size="sm" variant="outline">
                      {file.type}
                    </Badge>
                  </div>
                </CommandItem>
              )}
            </CommandList>
          </CommandPanel>
        </Command>
      </CommandDialogPopup>
    </CommandDialog>
  );
}
```
