File Type Icon
Show a file’s type as a document icon with its extension.
- file.pdf
- file.jpg
- file.mp4
- file.docx
- file.xlsx
- file.zip
- file.tsx
- file
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/file-type-iconComplete the one-time setup first. Registry JSON lists source files and dependencies.
Usage
import { FileTypeIcon } from "@/siteplane/components/file-type-icon";
<FileTypeIcon name="file.pdf" />;Supported types
The icon is chosen from the file’s extension. Each type has its own glyph on a document sheet that follows the theme, and a label that shows the extension in capitals. The label color comes from the kit and depends on the type. PDFs are red, spreadsheets green, and slides and archives orange. Documents, images, vector files, video and audio take the accent. Code and files of an unknown type are gray. The colors follow the theme, and a brand override of the accent reaches the label.
- PDFpdf
- Documentsdoc, docx, txt, md
- Spreadsheetsxls, xlsx, csv, ods
- Presentationsppt, pptx, odp
- Imagesjpg, png, gif, heic
- Vectorsvg, eps, dwg
- Videomp4, mov, avi, webm
- Audiomp3, wav, flac, m4a
- Archiveszip, gz, rar, 7z
- Codejs, ts, tsx, json
- Fontsttf, otf, woff
- 3D modelsobj, 3ds, skp
The glyphs come from react-file-icon, which the registry installs with the component. Fonts and 3D models show their own glyph on a gray label, and so do other types such as executables and disk images. An extension it does not know shows a plain document with a gray label.
The label shows up to five letters or digits. A name without a suffix, such as README, a dotfile such as .gitignore, and an extension that is longer or contains other characters show FILE. Only the last suffix counts, so archive.tar.gz is labeled GZ.
Sizes
There is no size prop. By default the icon fills a box 40 px high and 34 px wide, which matches the 5:6 proportion of the sheet. Resize the box with className, keeping that proportion, and the sheet, glyph and label scale with it. Below about 32 px the label becomes too small to read, so rely on the file name beside the icon.
- 24 px
- 32 px
- 40 px
- 48 px
- 64 px
In a file list
The icon is decorative and hidden from assistive technology. Always show the file name next to it.
- Quarterly-report.pdf2.4 MB
- Budget-2026.xlsx180 KB
- Brand-assets.zip48 MB
- Team-photo.jpg1.1 MB
Files without a suffix
Pass extension when the name does not carry the file type, such as a document title or a download name without its suffix. It replaces the extension in name; a leading dot and capital letters are ignored.
- Meeting notes
- Quarterly report
- Makefile
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
File | string | required | File name, with or without folders. The text after its last dot chooses the icon. |
File | string | unset | Extension that replaces the one in name, with or without the leading dot. |
File | string | unset | Classes for the icon box. Set its height and width to resize the icon. |
FileTypeIconProps has only these three props: the icon renders an aria-hidden span with a data-extension attribute around the SVG, and accepts no other native props or refs.
Usage notes
The icon takes its type from the name only; it does not read the file or its MIME type. For images and videos a thumbnail often identifies a file better, so keep the icon for lists and upload rows without a preview.
File Upload uses this icon for its rows, and the invoice in Inline CTA uses it as a detail icon.