shadcn.io is not affiliated with official shadcn/ui
Showcase File Explorer Hero Block for React
A showcase hero for a code editor: a centred headline, a Shine Button and three ticks above a wide editor window in a hairline frame, with a working file tree beside a sketched editor pane.
Installation
Overview
A showcase hero for Kiln, a code editor. An announcement link, the headline, a line of copy, a Shine Button with an outline second action and three ticks are centred at the top. Below them a wide editor window, held in a hairline frame with + marks on its corners, runs on past the first screen. Its file explorer is our TreeView: a project's src folder with its components, pages and lib folders open, files with an icon per type, and the open file marked with a bar. Pick another file and the path in the title bar and the editor's tab follow; fold a folder and its files tuck away. Beside the tree a sketched editor pane shows line numbers and code as greyscale bars that fade at their foot, and a status bar names the branch and counts the files and folders. The block follows the theme. For code editors, monorepo tools, documentation platforms, project scaffolders and code search products.
FAQ
How do I change the files in the explorer?
Edit the collection at the top of the file. Each node has an id and a name; a folder also has children. Give each node its path as its id (src/components/Button.tsx): the title bar shows the open file's path from it, and the file icons are matched on its extension. List every folder you want open on load in FOLDERS, set the file open on load in OPEN_FILE, and update the counts in the status bar if you add or remove files.
Does the tree really work?
Yes. The arrow keys move through it (right opens a folder, left closes it or goes up to its parent), Enter or a click picks a file, and typing a letter jumps to the next name that starts with it. The title bar's path and the editor's tab follow the file you pick. Tab enters the tree on the open file and leaves it in one step, so the tree is a single stop in the tab order.
How are the file icons chosen?
The tree takes a map of icons by extension, made with createFileIcons (.tsx, .ts, .json, .md), and picks one for each file from its name; folders show an open or closed folder. All of them are in the muted foreground tone, so the Shine Button stays the only colour on the page. Add an extension to the map to give it its own icon.
How does a screen reader read the explorer?
The window is a figure named "Code editor with a file explorer", holding a tree named after the workspace (my-app). Each folder is announced as expanded or collapsed with its level, and the open file as selected. The title bar and the editor pane are decoration: hidden from screen readers and out of the tab order. The status bar is read as plain text.
How does the window fit on a phone?
The text stays centred and the Shine Button on the first screen. Below sm the editor pane steps aside and the tree takes the whole width of the window, so every file stays readable. The path in the title bar shortens with an ellipsis, and each level of the tree indents by a small step, so the deepest file still fits at 320 px.
What moves, and can I turn it off?
The copy fades and rises in on load, and the window fades and settles in just after it. Folders slide open and shut, and their chevrons turn. It's all CSS, with no animation library. With reduced motion on, everything appears in place and folders open and close at once.
Related
- --++Pro
Split Layout Code Diff Hero
Code and terminalA showcase hero for a code review tool: a centred headline, a Shine Button, a second action and three ticks over a wide pull request window in a hairline frame, with a diff whose changes play out line by line.
- #--Pro
Split Markdown Editor Hero
Product windowsA reverse split hero: a two-pane markdown editor in a hairline frame with + marks on its corners, then a divider, the headline, three checks and a Shine Button.
- Pro
Split Layout Dark Terminal Hero
Code and terminalA split hero for an API: the headline, a Shine Button and three ticks beside a dark terminal with a request, a status and a JSON response that writes itself out, above a band of three figures.
- Pro
Split Layout Commit Graph Hero
Code and terminalA reverse split hero for a code host: a commit history drawn as a branch graph in a hairline frame on the start side, then an announcement link, the headline, a Shine Button and three ticks.
- Pro
Pull Request Showcase Hero
Code and terminalA showcase hero for a merge queue: a two-part header with a Shine Button, over a ruled band where a pull request page rises and fades out, with its diff, reviewers, checks and queue position.
- Pro
Split Layout GraphQL Query Hero
Code and terminalA showcase hero for a GraphQL gateway: the headline and the pitch with a Shine Button above a wide editor window in a hairline frame, with a schema explorer, a query that types itself in and its response.