Build a VS Code-style file explorer with tree view, folder expand/collapse, file icons…
- User
Build a VS Code-style file explorer with tree view, folder expand/collapse, file icons by type, multi-select, and right-click context menu.
Assistant
Let me build a complete VS Code-style file explorer. I'll create several components.
Let me rethink the context menu approach. I'll update both components to properly pass mouse coordinates.
Now let me update the App.tsx to render the FileExplorer.
The project builds successfully. Let me verify the final structure:
The VS Code-style file explorer is complete and builds successfully. Here's what was built:
Project Structure
src/ ├── components/ │ ├── FileExplorer.tsx # Main container with state management │ ├── FileTree.tsx # Recursive tree view with expand/collapse │ ├── FileIcon.tsx # File type icons (TS, JS, CSS, JSON, images, etc.) │ └── ContextMenu.tsx # Right-click context menu ├── data/ │ └── files.ts # Mock file system data ├── types.ts # TypeScript types └── App.tsx # VS Code-like layout (activity bar, sidebar, editor)Features Implemented
-
Tree View with Expand/Collapse — Folders have chevrons that rotate when expanded. Click a folder to toggle it, or double-click. The
srcfolder starts expanded. -
File Icons by Type — Custom SVG icons for:
- 📘 TypeScript (
.ts,.tsx) - 🟨 JavaScript (
.js,.jsx,.cjs) - 🔷 CSS (
.css,.scss) - 🟣 JSON (
.json) - 🔶 HTML (
.html) - 🔵 Markdown (
.md) - 🟢 Images (
.png,.jpg,.svg) - 🟠 Config files
- 🔴 Lock files
- 🟤 Folders (open/close variants)
- 📘 TypeScript (
-
Multi-Select —
- Ctrl/Cmd+Click — Toggle individual items in/out of selection
- Shift+Click — Add to selection range
- A status bar shows the count of selected items
-
Right-Click Context Menu — With:
- New File / New Folder
- Copy / Cut / Paste (Paste disabled)
- Rename / Delete
- Copy Path
- Auto-positions to stay within viewport
- Closes on Escape or outside click
-
VS Code-Themed UI — True VS Code color scheme (
#1e1e1e,#252526,#333333) with an activity bar, editor tabs, and a centered welcome screen.
Files built:
index.html,src/types.ts,src/data/files.ts,src/components/FileIcon.tsx,src/components/ContextMenu.tsx,src/components/FileTree.tsx,src/components/FileExplorer.tsx,src/App.tsx-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.