---
title: "Files"
description: "A file tree with collapsible folders, for showing a project's structure in MDX."
url: https://docscn.dev/docs/components/files
lastModified: 2026-10-09T09:13:37.000Z
---

# Files (/docs/components/files)

> A file tree with collapsible folders, for showing a project's structure in MDX.

<Files>
  <Folder name="app">
    <File name="layout.tsx" />

    <Folder name="docs">
      <File name="layout.tsx" />

      <File name="[[...slug]]/page.tsx" />
    </Folder>
  </Folder>

  <File name="package.json" />
</Files>

## Installation [#installation]

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx shadcn@latest add @docscn/files
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx shadcn@latest add @docscn/files
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx shadcn@latest add @docscn/files
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun x shadcn@latest add @docscn/files
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Usage [#usage]

```mdx
import { File, Files, Folder } from "@/components/docs/components/files";

<Files>
  <Folder name="app" defaultOpen>
    <File name="layout.tsx" />
  </Folder>
  <File name="package.json" />
</Files>
```

The `docs` block adds `Files`, `Folder` and `File` to your MDX components, which Fumadocs' opt-in `remark-mdx-files` plugin needs: it turns `files` code blocks into these components.

## Props [#props]

| Component | Prop          | Type        | Description                   |
| --------- | ------------- | ----------- | ----------------------------- |
| `Folder`  | `name`        | `string`    | The folder's name.            |
| `Folder`  | `defaultOpen` | `boolean`   | Open the folder at first.     |
| `Folder`  | `disabled`    | `boolean`   | Keep the folder from opening. |
| `File`    | `name`        | `string`    | The file's name.              |
| `File`    | `icon`        | `ReactNode` | Replace the file icon.        |

Folders are built on shadcn/ui `collapsible`.