# FileExplorer

Browse files as folders, a detailed list or a directory tree.

- **Use it for**: Browsing a file tree and opening files.
- **Not for**: Showing one file. Try [CodeTabs](https://unseenui.com/components/code-tabs/).

## Good to know

- Only the metadata the server supplies is shown; nothing is inferred from the name.

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { FileExplorer } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<FileExplorer variant="folders" files={files} context={snapshot} selection={selection} expandedPaths={folders} onExpandedPathsChange={setFolders} onRequestOpen={requestOpen} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `className` | `string` | Added to the root element, after the component's own classes. |
| `context` | `WorkspaceFileSnapshot` |  |
| `error` | `string` |  |
| `expandedPaths` (required) | `readonly string[]` |  |
| `files` (required) | `readonly WorkspaceFile[]` |  |
| `onExpandedPathsChange` | `((paths: string[]) => void)` |  |
| `onPageChange` | `((index: number, context?: WorkspaceFileSnapshot) => void)` |  |
| `onQueryChange` | `((query: string) => void)` |  |
| `onRefresh` | `((context?: WorkspaceFileSnapshot) => void)` |  |
| `onRequestOpen` | `((request: FileOpenRequest) => void)` |  |
| `onSelect` | `((file: WorkspaceFile) => void)` | Legacy unscoped callback; onRequestOpen takes precedence when supplied. |
| `pagination` | `FilePage` |  |
| `query` | `string` |  |
| `selectedId` | `string` |  |
| `selection` | `FileOpenRequest` |  |
| `status` | `"unknown" \| "ready" \| "loading" \| "denied" \| "unavailable" \| "error" \| "stale" \| "refreshing"` |  |
| `title` | `string` |  |
| `variant` | `"list" \| "compact" \| "folders"` |  |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[CodeTabs](https://unseenui.com/components/code-tabs/), [Snippet](https://unseenui.com/components/snippet/), [Commit](https://unseenui.com/components/commit/), [EnvironmentVariables](https://unseenui.com/components/environment-variables/), [PackageInfo](https://unseenui.com/components/package-info/), [SchemaDisplay](https://unseenui.com/components/schema-display/), [StackTrace](https://unseenui.com/components/stack-trace/), [WebPreview](https://unseenui.com/components/web-preview/), [Image](https://unseenui.com/components/image/), [CodeDiff](https://unseenui.com/components/code-diff/), [TerminalOutput](https://unseenui.com/components/terminal-output/), [TestResults](https://unseenui.com/components/test-results/)

Page: https://unseenui.com/components/file-explorer/
