Examples

Operations file browser

Preview
  • Inbox

Choose a file to preview.

Example.tsx
import { FileExplorer, type FileExplorerEntry } from '@reactloom/files';
import { useState } from 'react';

export default function Example() {
  const [entries] = useState<FileExplorerEntry[]>(() => [
    { id: 'reports', label: 'Reports', children: [
      { id: 'daily', label: 'Daily reconciliation', file: new File(['Order,Total\n1042,830'], 'reconciliation.csv', { type: 'text/csv' }) },
    ] },
    { id: 'inbox', label: 'Inbox', children: [] },
  ]);
  return <FileExplorer label="Operations files" entries={entries} />;
}

Controlled document selection

Preview
  • Incident notes
  • Handover checklist

Incident notes

Example.tsx
import { useState } from 'react';
import { FileExplorer } from '@reactloom/files';

const entries = [{ id: 'incident', label: 'Incident notes' }, { id: 'handover', label: 'Handover checklist' }];

export default function Example() {
  const [selected, setSelected] = useState<string | null>('incident');
  return <FileExplorer label="Support documents" entries={entries} selectedId={selected} onOpen={(entry) => setSelected(entry.id)} />;
}

API reference

FileExplorer props
PropTypeDefault
entries
Nodes with IDs and labels. Folders supply children and files can supply a browser File.
readonly FileExplorerEntry[]—
label
Name the explorer and its tree.
string—
selectedId · defaultSelectedId
Controlled or initial selection.
string | null—
onOpen
Called when a file is activated.
(item: FileExplorerEntry) => void—
emptyMessage
Prompt displayed before selecting a file.
string—

Keyboard interaction

Keyboard interactions
KeyAction
Up / DownMove through visible folders and files
Left / RightCollapse or expand a folder in reading order
Enter / SpaceToggle a folder or open a file
TabMove to the selected file’s download link

Usage guidelines

The root explorer accepts className, style, and a ref.

Do

  • Supply stable IDs and fetch file content in the consuming app when using a remote filesystem.

Don’t

  • Avoid using filenames as IDs when separate folders can contain files with the same name.