# File Icons

File-type illustrations for attachments, upload rows, and file cards.

File icons are the folded-sheet illustrations inside [File Card](/components/file-card/). Each icon stamps a short label on a paper sheet, and the label band takes its color from the file family. The same illustration is what an attachment list uses to tell a PDF from a spreadsheet at a glance.

```tsx
import { FileCard, Stack, Text } from "@zentara-co/zenos-ui";

const fileIconTypes = [
  { label: "PDF", type: "pdf" },
  { label: "Document", type: "document" },
  { label: "Spreadsheet", type: "spreadsheet" },
  { label: "Presentation", type: "presentation" },
  { label: "Archive", type: "archive" },
  { label: "Image", type: "image" },
  { label: "Video", type: "video" },
  { label: "Audio", type: "audio" },
  { label: "Code", type: "code" },
  { label: "Other", type: "default" },
] as const;

function FileIconCatalogExample() {
  return (
    <div className="grid w-full grid-cols-2 gap-x-4 gap-y-6 sm:grid-cols-5">
      {fileIconTypes.map((file) => (
        <Stack key={file.type} align="center" gap="2">
          <FileCard.Icon type={file.type} />
          <Text size="s" color="subtle">
            {file.label}
          </Text>
        </Stack>
      ))}
    </div>
  );
}
```

## Import

```tsx
import { FileCard, fileTypeFromName } from "@zentara-co/zenos-ui";
```

## Usage

Pass a family with `type`, or derive it from a filename. The icon is decorative: the filename beside it names the file. Pass `aria-label` only when the icon stands alone.

```tsx
<FileCard.Icon type="pdf" />
<FileCard.Icon type={fileTypeFromName("Q3 revenue.xlsx")} />
<FileCard.Icon type="code" label="TSX" />
```

`label` replaces the short stamp. Use it when a product-specific extension should read differently from the family default, such as `TSX` on a code file. Leave it unset for the family's own label.

## Categories

`fileTypeFromName` reads the extension, ignores letter case, and returns one of ten families. An unknown extension, or a name with no extension, returns `default`. Prefer a trusted MIME type when the filename may be incomplete.

| Family         | Stamp | Tone    | Extensions                                           |
| -------------- | ----- | ------- | ---------------------------------------------------- |
| `pdf`          | PDF   | Red     | pdf                                                  |
| `document`     | DOC   | Blue    | doc, docx, odt, rtf, txt                             |
| `spreadsheet`  | XLS   | Green   | csv, ods, xls, xlsx                                  |
| `presentation` | PPT   | Orange  | key, odp, ppt, pptx                                  |
| `archive`      | ZIP   | Yellow  | 7z, gz, rar, tar, zip                                |
| `image`        | IMG   | Purple  | gif, heic, jpeg, jpg, png, svg, webp                 |
| `video`        | VID   | Magenta | avi, mkv, mov, mp4, webm                             |
| `audio`        | AUD   | Teal    | aac, flac, m4a, mp3, ogg, wav                        |
| `code`         | CODE  | Indigo  | css, html, js, json, jsx, md, py, ts, tsx, yaml, yml |
| `default`      | FILE  | Gray    | Anything else                                        |

Tones use accent tokens, so they follow the active theme.

## In a file card

[File Card](/components/file-card/) places the icon at the start of a row or at the top of a tile. Pass the derived type and keep the real filename in `FileCard.Name`. The card page covers progress, upload state, and actions.

```tsx
import { FileCard, fileTypeFromName, Stack } from "@zentara-co/zenos-ui";

function FileIconContextExample() {
  const files = [
    { meta: "PDF · 4.2 MB", name: "Brand guidelines.pdf" },
    { meta: "Spreadsheet · 860 KB", name: "Q3 revenue.xlsx" },
    { meta: "Video · 128 MB", name: "Launch film.mp4" },
  ] as const;

  return (
    <Stack gap="3" className="w-full max-w-xl">
      {files.map((file) => (
        <FileCard key={file.name} variant="outline">
          <FileCard.Icon type={fileTypeFromName(file.name)} />
          <FileCard.Content>
            <FileCard.Name>{file.name}</FileCard.Name>
            <FileCard.Meta>{file.meta}</FileCard.Meta>
          </FileCard.Content>
        </FileCard>
      ))}
    </Stack>
  );
}
```

Inside a card, the icon size follows the card layout and density. A comfortable row uses the larger sheet; compact rows and tiles scale it with the card. Override the frame with `className` when the icon needs a different box outside that layout.

Source: https://zenos-ui.pages.dev/foundations/file-icons/