- Docs
- System Components
- File Manager
File Manager
A set of file and folder display components for building file explorer interfaces. These components provide a visually rich way to display files and folders with support for thumbnails, icons, and user interactions.
Examples
File Manager Basics
Installation
pnpm dlx shadcn@latest add https://chatcn.me/c/system/file-manager
Usage
Basic Folder Display
import { FolderItem } from "@/components/chatcn/system/file-manager"
export default function Example() {
return (
<FolderItem
name="Documents"
onClick={() => console.log("Folder opened")}
/>
)
}Basic File Display
import { FileItem } from "@/components/chatcn/system/file-manager"
export default function Example() {
return (
<FileItem
name="image.png"
thumbnail="/path/to/thumbnail.png"
onClick={() => console.log("File opened")}
/>
)
}Building a File Grid
import { FolderItem, FileItem } from "@/components/chatcn/system/file-manager"
const folders = [
{ name: "Documents" },
{ name: "Pictures" },
]
const files = [
{ name: "photo.jpg", thumbnail: "/thumbnails/photo.jpg" },
{ name: "script.js" },
{ name: "README.md" },
]
export default function FileExplorer() {
return (
<div className="grid grid-cols-4 gap-2">
{folders.map((folder) => (
<FolderItem
key={folder.name}
name={folder.name}
onClick={() => console.log(`Open ${folder.name}`)}
/>
))}
{files.map((file) => (
<FileItem
key={file.name}
name={file.name}
thumbnail={file.thumbnail}
onClick={() => console.log(`Open ${file.name}`)}
/>
))}
</div>
)
}Props
FolderItem
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | - | The folder name to display |
onClick | () => void | - | Callback when folder is double-clicked |
className | string | "" | Additional CSS classes |
tabIndex | number | 0 | Tab index for keyboard navigation |
FileItem
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | - | The file name to display (extension determines icon) |
onClick | () => void | - | Callback when file is double-clicked |
className | string | "" | Additional CSS classes |
tabIndex | number | 0 | Tab index for keyboard navigation |
thumbnail | string | - | URL for thumbnail image (for images/videos) |
src | string | - | Source URL for the file |
Supported File Types
The FileItem component automatically detects file types based on extension and displays appropriate icons:
| Type | Extensions | Icon |
|---|---|---|
| Image | png, jpg, jpeg, gif, svg, webp | Image icon |
| Video | mp4, mov, avi, mkv, webm | Play icon overlay |
| Text | txt, md, markdown | Text file icon |
| Code | js, ts, jsx, tsx, py, java, c, cpp, cs, json, html, css | Code file icon |
| Other | Any other extension | Generic file icon |