For AI agents: the complete documentation index is available at https://a3s-lab.github.io/UI/v0.4.1/en/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/UI/v0.4.1/en/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/UI/v0.4.1/en/components/file-explorer.md.

File Explorer

File Explorer combines workspace identity, file search, hierarchical navigation, file state, and contextual actions in one bounded tool. Filesystem reads, writes, authorization, and source control remain the trusted host's responsibility.

Live preview

Project files

release-dashboard
5
src3
components
App.tsxM
Status.tsxA
main.ts
package.json
5 files · 2 changesmain

Usage

File Explorer reuses Tree for focus, selection, disclosure, and typeahead. Context Menu supplies contextual commands.

<section class="file-explorer" aria-labelledby="files-title">
  <header>
    <div data-file-explorer-identity>
      <h2 id="files-title">Project files</h2>
    </div>
  </header>
  <div data-file-explorer-toolbar>
    <input
      class="input"
      type="search"
      data-file-explorer-search
      aria-label="Filter files"
    />
  </div>
  <div data-file-explorer-viewport>
    <div class="tree" role="tree" aria-label="Project file tree">...</div>
  </div>
  <footer><span data-file-explorer-summary>5 files</span></footer>
</section>

Parameters

APIPurpose
data-file-explorer-identityWorkspace or directory name and optional path
data-file-explorer-toolbarSearch, refresh, create, and collapse commands
data-file-action="command"Stable host command; write commands are removed in read-only mode
data-file-explorer-viewportThe file tree's only scroll owner
data-file-statusadded, modified, deleted, or conflict, with an accessible name
data-file-dirtyUnsaved marker; it does not replace text status or leave confirmation
data-file-editorController-created inline rename input
data-file-filter-count / data-file-filter-emptyMatched leaf-file count and recoverable no-match state
data-file-explorer-state="state"Loading, empty, error, or permission feedback

JavaScript API

Load the runtime before Tree, Context Menu, and File Explorer controllers, or use the complete bundle.

const explorer = document.querySelector(".file-explorer");
explorer.select("src/components/App.tsx");
explorer.setFilter("status");
explorer.setReadonly(false);
explorer.beginRename();

explorer.addEventListener("a3s:file-rename", async ({ detail }) => {
  try {
    await renameFile(detail.value, detail.name);
  } catch (error) {
    explorer.setRenameError(error.message);
  }
});

getSelection() and select() control one file without bypassing unsaved-change guards. getFilter(), setFilter(), and clearFilter() preserve expansion state, reveal matching ancestors, announce the match count, and restore the original tree when cleared. getState(), setState(), and setReadonly() control loading, error, permission, and write visibility. beginRename(), commitRename(), cancelRename(), and setRenameError() provide a reversible optimistic rename; runAction() and refresh() complete the host integration.

Cancelable hooks are a3s:file-before-selection-change, a3s:file-before-filter-change, a3s:file-before-action, and a3s:file-before-rename. Completed selection, filter, action, rename, rename-cancel, and state events include the source, original event, stable file value, and relevant snapshots. The host may reject navigation with unsaved work, reject a write synchronously, or reopen the editor with an asynchronous error.

States and variants

Read-only mode preserves selection, filtering, copy path, and open actions while removing write commands instead of disabling everything. Filter counts include leaf files rather than directory nodes. Rename uses data-file-editor in the current row: F2 starts rename on the focused or selected item, Enter submits and returns focus to the item, Escape cancels, and blur commits unless data-rename-blur="cancel" is set. Context Menu rename remains available for pointer users. The controller rejects empty names and path separators; the host validates duplicates, platform rules, authorization, and persistence.

Source status may appear as a short trailing file marker. Commit, stage, branch creation, and remote synchronization are separate workflows composed from Toolbar, Tree, Alert, and Dialog; they do not belong in File Explorer's base public contract.

Accessibility

Follow Tree's roving tabindex and arrow-key contract. A cancelable selection hook protects unsaved work before focus or selection moves. Filtering announces the count and keeps focus in search when a focused result disappears. Rename errors stay associated with the inline input. Show async loading or error state inside the affected branch. A trusted host performs every file write.