---
title: "File Icon"
description: "The icon of a file: a neutral page with a folded corner, a sketch of what is inside, and one colored type tag."
url: https://gelatinui.com/components/file-icon
markdown_url: https://gelatinui.com/components/file-icon.md
access: free
install: "npx shadcn@latest add @gelatin-ui/file-icon"
registry_item: https://gelatinui.com/r/file-icon.json
version: "2026-11-16"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# File Icon

> The icon of a file: a neutral page with a folded corner, a sketch of what is inside, and one colored type tag.

Page: https://gelatinui.com/components/file-icon

## When to use it

Best for: Show the kind and type of a file next to its name, from 16px chips to 128px previews.

- Use it beside a file name: pass `file` with the `name` and the MIME `type`, and the kind and the tag come from them.
- Use `kind` when you have no file, or to override the kind that the name gives.
- Use 40px and up for the full sketch and the labeled tag; use 17 to 39px in rows, and 16px or less in chips.

## When not to use it

- To show the file itself with its name, size, and actions, use an [Attachment](https://gelatinui.com/components/attachment.md).
- To show a photo of the file content, use an [Image](https://gelatinui.com/components/image.md).

## Notes for agents

- Pass `file={{ name, type }}`: the kind comes from the MIME type first, then the extension. A file with neither shows the neutral `file` kind.
- `pixelSize` sets the height in px; the width is 0.8 of it. The tag shows text only at 40px and up.
- The children are the tag text, 5 letters at most. A longer word, or none, shows the type word of the file, else the kind word (PDF, DOC, XLS, IMG).
- The icon is hidden from assistive tech: always put the file name next to it as text.
- The tag hangs past the start edge of the box by about a tenth of the size: leave that space free.

## Anatomy

```text
FileIcon
```

## API reference

### FileIcon

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `file` | `Readonly` |  | The file to draw: its kind and its type tag come from the name and the MIME type. |
| `kind` | `"archive" \| "audio" \| "code" \| "data" \| "design" \| "document" \| "file" \| "image" \| "pdf" \| "sheet" \| "slides" \| "video"` |  | The kind, when there is no file (or to override it). |
| `children` | `string` |  | The tag at 40px and up; default the file's type ("PDF"), else the kind's word. 5 letters at most. |
| `pixelSize` | `number` | 40 | The height in px; the width is 0.8 of it. Default 40. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| FileIcon | `file-icon` |  | `--file-icon-hue` |  |

## Usage

Give each file row its icon from the name and the MIME type. The tag shows the extension, and the sketch and the hue show the kind.

```tsx title="recent-files.tsx"
import { FileIcon } from "@/components/files/file-icon";

const files = [
  { name: "Q4-board-deck.pdf", type: "application/pdf" },
  { name: "Sales-2026.xlsx", type: "" },
  { name: "Cabin-exterior.jpg", type: "image/jpeg" },
  { name: "Brand-assets.zip", type: "application/zip" },
];

export function RecentFiles() {
  return (
    <ul className="flex flex-col gap-2">
      {files.map((file) => (
        <li key={file.name} className="flex items-center gap-3 ps-1">
          <FileIcon file={file} pixelSize={40} />
          <span className="truncate text-sm font-medium">{file.name}</span>
        </li>
      ))}
      <li className="flex items-center gap-3 ps-1">
        <FileIcon kind="document" pixelSize={40}>
          DOCX
        </FileIcon>
        <span className="truncate text-sm font-medium">Offer letter</span>
      </li>
    </ul>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/file-icon
```

It adds 7 registry items: 7 files, 946 lines, and the npm packages `clsx`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [File Size](https://gelatinui.com/components/file-size.md)
- [Badge](https://gelatinui.com/components/badge.md)
- [Attachment](https://gelatinui.com/components/attachment.md)
- [Dropzone](https://gelatinui.com/components/dropzone.md)

## Accessibility

The icon is an `svg` with `aria-hidden`: it is decoration. The file name beside it names the file.

The kind shows in three ways at 40px and up: the sketch, the tag text, and the hue. Below 40px the sketch and the hue still differ by kind.

## Motion

| Part | Motion |
| --- | --- |
| Motion | none · the icon is still: it changes at once when the file or the size changes |
