FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Medium

File Explorer II

40 mins

Build a semi-accessible file explorer in React that displays files and directories in a hierarchical tree format with appropriate ARIA roles and properties.

Requirements:

  1. Display names of files and directories in a tree view.
  2. Directories:
    • Can contain other directories and files.
    • Should be expandable/collapsible by clicking.
    • Should be displayed before files and sorted alphabetically.
    • Can be empty.
  3. Files:
    • Are leaf nodes and cannot be expanded.
  4. Indent contents to represent hierarchy visually.
  5. Accessibility:
    • Use role="tree" for the container.
    • Use role="treeitem" for each node.
    • Directories should use aria-expanded to indicate state.
    • Nested content should have role="group".
    • Focus on correct roles/states, not keyboard navigation (semi-accessible).

Code Editor

React Component

00:00
Loading...

Live Preview

See your React component