# File browser

A controlled file-library block with native path navigation, search, sorting, row selection and consumer-owned detail content.

Access: pro. Category: Blocks. Kind: composite.

## When to use

- Use it when a page needs a controlled file-library block with native path navigation, search, sorting, row selection and consumer-owned detail content.
- Choose it inside an authenticated product surface when the host application owns routing, persistence, and service calls.

## Alternatives

- Choose empty-state instead when empty collections, search results and errors with a clear next action is the actual interface need, rather than file browser.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install File browser

```sh
npx shadcn@latest add @tidal-pro/file-browser
```

Stylesheets: `components/ui/tidal.css`, `components/ui/file-browser.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/file-browser.css";
import{TidalFileBrowser}from"./components/ui/file-browser";
export default()=><div className="tidal-scope"><TidalFileBrowser items={[{id:"example",kind:"folder",name:"Demo",accessibleName:"Demo"}]} path={[{id:"example",label:"Demo",accessibleLabel:"Demo"}]} title={"Demo"}/></div>;
```

## Structured props

- `TidalFileBrowser.items: ReadonlyArray<TidalFileBrowserItem>`: Required items value accepted by this exported component.
- `TidalFileBrowser.path: ReadonlyArray<TidalFilePathItem>`: Required path value accepted by this exported component.
- `TidalFileBrowser.title: ReactNode`: Required title value accepted by this exported component.
- `TidalFileBrowser.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalFileBrowser.detail?: ReactNode`: Optional detail value accepted by this exported component.
- `TidalFileBrowser.detailLabel?: string | undefined` (default "File details"): Optional detail label value accepted by this exported component.
- `TidalFileBrowser.emptyMessage?: ReactNode` (default "No files or folders match this view."): Optional empty message value accepted by this exported component.
- `TidalFileBrowser.eyebrow?: ReactNode` (default "File browser"): Optional eyebrow value accepted by this exported component.
- `TidalFileBrowser.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalFileBrowser.headingLevel?: "h2" | "h3" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalFileBrowser.labels?: Partial<TidalFileBrowserLabels> | undefined`: Optional labels value accepted by this exported component.
- `TidalFileBrowser.onOpenItem?: ((item: TidalFileBrowserItem, event: ReactMouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void) | undefined`: Callback invoked when the open item interaction is proposed.
- `TidalFileBrowser.onSelectionChange?: ((item: TidalFileBrowserItem, selected: boolean, event: ReactChangeEvent<HTMLInputElement>) => void) | undefined`: Callback invoked when the selection change interaction is proposed.
- `TidalFileBrowser.search?: TidalFileSearchControl | undefined`: Optional search value accepted by this exported component.
- `TidalFileBrowser.sort?: TidalFileSortControl | undefined`: Optional sort value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/file-browser.tsx) | [Manifest](https://tidalui.com/examples/file-browser.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useLayoutEffect, useMemo, useRef, useState } from "react";

import { FileText, Folder, FolderOpen, RotateCcw, X } from "lucide-react";

import { TidalFileBrowser, type TidalFileBrowserItem } from "./components/ui/file-browser";

import "./components/ui/file-browser.css";



const tidalExampleStyles = ".tidal-scope .file-browser-demo {\n  width: min(100%, 980px);\n  margin-inline: auto;\n}\n\n.tidal-scope .file-browser-demo-detail {\n  position: relative;\n  min-width: 0;\n}\n\n.tidal-scope .file-browser-demo-detail-mark {\n  display: grid;\n  width: 46px;\n  height: 46px;\n  margin-bottom: 34px;\n  place-items: center;\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border-radius: 12px;\n  box-shadow:\n    8px 8px 0 color-mix(in srgb, var(--t-surface) 18%, transparent),\n    0 0 0 1px color-mix(in srgb, var(--t-surface) 22%, transparent);\n}\n\n.tidal-scope .file-browser-demo-detail-close {\n  position: absolute;\n  inset-block-start: 0;\n  inset-inline-end: 0;\n  display: grid;\n  width: 44px;\n  height: 44px;\n  padding: 0;\n  place-items: center;\n  color: var(--t-surface);\n  background: transparent;\n  border: 1px solid color-mix(in srgb, var(--t-surface) 34%, transparent);\n  border-radius: var(--t-radius-control);\n  cursor: pointer;\n  transition:\n    background 140ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .file-browser-demo-detail-close:hover {\n  background: color-mix(in srgb, var(--t-surface) 14%, transparent);\n}\n\n.tidal-scope .file-browser-demo-detail-close:active {\n  transform: scale(0.96);\n}\n\n.tidal-scope\n  .file-browser-demo-detail\n  > span:not(.file-browser-demo-detail-static) {\n  display: block;\n  color: color-mix(in srgb, var(--t-surface) 67%, transparent);\n  font-size: 11px;\n  font-weight: 760;\n  letter-spacing: 0.13em;\n  text-transform: uppercase;\n}\n\n.tidal-scope .file-browser-demo-detail h3 {\n  margin: 8px 0 0;\n  overflow-wrap: anywhere;\n  font-size: clamp(20px, 2.3cqi, 27px);\n  line-height: 1;\n  letter-spacing: -0.045em;\n}\n\n.tidal-scope .file-browser-demo-detail p {\n  margin: 13px 0 0;\n  color: color-mix(in srgb, var(--t-surface) 72%, transparent);\n  font-size: 11px;\n  line-height: 1.55;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .file-browser-demo-detail dl {\n  display: grid;\n  grid-template-columns: repeat(2, minmax(0, 1fr));\n  gap: 1px;\n  margin: 20px 0;\n  background: color-mix(in srgb, var(--t-surface) 22%, transparent);\n  border: 1px solid color-mix(in srgb, var(--t-surface) 22%, transparent);\n  border-radius: 10px;\n  overflow: hidden;\n}\n\n.tidal-scope .file-browser-demo-detail dl > div {\n  min-width: 0;\n  padding: 10px;\n  background: var(--t-ink);\n}\n\n.tidal-scope .file-browser-demo-detail dt {\n  color: color-mix(in srgb, var(--t-surface) 59%, transparent);\n  font-size: 11px;\n  letter-spacing: 0.12em;\n  text-transform: uppercase;\n}\n\n.tidal-scope .file-browser-demo-detail dd {\n  margin: 4px 0 0;\n  overflow-wrap: anywhere;\n  font-size: 11px;\n}\n\n.tidal-scope .file-browser-demo-detail > a,\n.tidal-scope .file-browser-demo-detail-static {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  width: 100%;\n  min-height: 44px;\n  padding: 8px 12px;\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border-radius: var(--t-radius-control);\n  font-size: 11px;\n  font-weight: 760;\n  line-height: 1.25;\n  text-align: center;\n  text-decoration: none;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .file-browser-demo-detail > a:hover {\n  text-decoration: underline;\n  text-underline-offset: 3px;\n}\n\n.tidal-scope .file-browser-demo-detail-static {\n  color: color-mix(in srgb, var(--t-surface) 72%, transparent);\n  background: color-mix(in srgb, var(--t-surface) 10%, transparent);\n  border: 1px solid color-mix(in srgb, var(--t-surface) 22%, transparent);\n}\n\n.tidal-scope .file-browser-demo-empty {\n  display: grid;\n  gap: 4px;\n  justify-items: center;\n}\n\n.tidal-scope .file-browser-demo-empty strong {\n  color: var(--t-ink);\n  font-size: 12px;\n}\n\n.tidal-scope .file-browser-demo-empty span {\n  font-size: 11px;\n}\n\n.tidal-scope .file-browser-demo-footer {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 14px;\n}\n\n.tidal-scope .file-browser-demo-footer > span {\n  max-width: 64ch;\n}\n\n.tidal-scope .file-browser-demo-footer button {\n  display: inline-flex;\n  flex: 0 0 auto;\n  align-items: center;\n  justify-content: center;\n  gap: 7px;\n  min-width: 44px;\n  min-height: 44px;\n  padding: 8px 12px;\n  color: var(--t-ink);\n  background: var(--t-surface);\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  font: inherit;\n  font-size: 11px;\n  font-weight: 720;\n  cursor: pointer;\n  transition:\n    background 140ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .file-browser-demo-footer button:hover {\n  background: var(--t-wash);\n}\n\n.tidal-scope .file-browser-demo-footer button:active {\n  transform: scale(0.97);\n}\n\n.tidal-scope .file-browser-demo-status {\n  min-height: 1.4em;\n  margin: 11px 6px 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.4;\n  text-align: center;\n  overflow-wrap: anywhere;\n}\n\n@container tidal-file-browser (max-width: 470px) {\n  .tidal-scope .file-browser-demo-footer {\n    align-items: stretch;\n    flex-direction: column;\n  }\n\n  .tidal-scope .file-browser-demo-footer button {\n    width: 100%;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .file-browser-demo-detail-close:active,\n  .tidal-scope .file-browser-demo-footer button:active {\n    transform: none;\n  }\n}";

type FolderId = "workspace" | "launch";

type SortId = "name" | "recent";

interface SampleItem extends TidalFileBrowserItem {
  folderTarget?: FolderId;
  detail: string;
}

const FILES: Record<FolderId, readonly SampleItem[]> = {
  workspace: [
    {
      id: "launch",
      kind: "folder",
      name: "Product launch",
      accessibleName: "Product launch folder",
      subtitle: "Four sample documents",
      modified: "Today",
      modifiedDateTime: "2026-10-14",
      icon: <Folder size={17} />,
      folderTarget: "launch",
      detail: "A local folder containing the launch planning sample.",
    },
    {
      id: "research",
      kind: "folder",
      name: "Research notes",
      accessibleName: "Research notes folder",
      subtitle: "Empty fictional folder",
      modified: "Oct 11",
      modifiedDateTime: "2026-10-11",
      icon: <Folder size={17} />,
      detail: "An empty fictional folder included to demonstrate folder rows.",
      disabled: true,
    },
    {
      id: "workspace-readme",
      kind: "file",
      name: "Workspace readme.md",
      accessibleName: "Workspace readme markdown file",
      subtitle: "Fictional orientation note",
      size: "3 KB",
      modified: "Oct 9",
      modifiedDateTime: "2026-10-09",
      icon: <FileText size={17} />,
      detail:
        "This fictional note explains how the local sample workspace is organized.",
    },
  ],
  launch: [
    {
      id: "brief",
      kind: "file",
      name: "sample-project-brief.txt",
      accessibleName: "Sample project brief text file",
      subtitle: "Repository sample document",
      size: "2 KB",
      modified: "Today",
      modifiedDateTime: "2026-10-14",
      icon: <FileText size={17} />,
      detail:
        "The repository includes this fictional text file. Open or download it from the detail panel.",
    },
    {
      id: "checklist",
      kind: "file",
      name: "launch-checklist.md",
      accessibleName: "Launch checklist markdown file",
      subtitle: "Fictional checklist summary",
      size: "6 KB",
      modified: "Oct 13",
      modifiedDateTime: "2026-10-13",
      icon: <FileText size={17} />,
      detail:
        "A fictional checklist row. No file is created or read by this preview.",
    },
    {
      id: "assets",
      kind: "folder",
      name: "Approved assets",
      accessibleName: "Approved assets folder",
      subtitle: "Fictional folder",
      modified: "Oct 12",
      modifiedDateTime: "2026-10-12",
      icon: <Folder size={17} />,
      detail: "A fictional folder row with consumer-owned detail content.",
    },
    {
      id: "notes",
      kind: "file",
      name: "review-notes.txt",
      accessibleName: "Review notes text file",
      subtitle: "Fictional review notes",
      size: "4 KB",
      modified: "Oct 10",
      modifiedDateTime: "2026-10-10",
      icon: <FileText size={17} />,
      detail:
        "Fictional review notes supplied as display data only. No file access occurs.",
    },
  ],
};

export function FileBrowserDemo() {
  const [folder, setFolder] = useState<FolderId>("launch");
  const [query, setQuery] = useState("");
  const [sort, setSort] = useState<SortId>("recent");
  const [selected, setSelected] = useState<ReadonlySet<string>>(
    () => new Set(["brief"]),
  );
  const [detailId, setDetailId] = useState("brief");
  const [message, setMessage] = useState(
    "Product launch is open. One fictional file is selected.",
  );
  const searchRef = useRef<HTMLInputElement>(null);
  const rowActionRefs = useRef(new Map<string, HTMLButtonElement>());
  const pendingFocus = useRef<"search" | { rowId: string } | null>(null);

  const visibleItems = useMemo(() => {
    const normalizedQuery = query.trim().toLocaleLowerCase();
    return FILES[folder]
      .filter(
        (item) =>
          !normalizedQuery ||
          `${item.accessibleName} ${String(item.subtitle ?? "")}`
            .toLocaleLowerCase()
            .includes(normalizedQuery),
      )
      .slice()
      .sort((left, right) => {
        if (sort === "name") {
          return left.accessibleName.localeCompare(right.accessibleName);
        }
        return (right.modifiedDateTime ?? "").localeCompare(
          left.modifiedDateTime ?? "",
        );
      })
      .map((item) => ({
        ...item,
        selected: selected.has(item.id),
        buttonRef: (node: HTMLButtonElement | null) => {
          if (node) rowActionRefs.current.set(item.id, node);
          else rowActionRefs.current.delete(item.id);
        },
      }));
  }, [folder, query, selected, sort]);

  const detailItem = visibleItems.find((item) => item.id === detailId);

  useLayoutEffect(() => {
    const intent = pendingFocus.current;
    if (!intent) return;
    pendingFocus.current = null;
    const target =
      intent === "search"
        ? searchRef.current
        : rowActionRefs.current.get(intent.rowId);
    target?.focus({ preventScroll: true });
  }, [detailId, folder]);

  function openFolder(nextFolder: FolderId) {
    pendingFocus.current = "search";
    setFolder(nextFolder);
    setQuery("");
    setDetailId("");
    setMessage(
      nextFolder === "workspace"
        ? "Sample workspace opened locally."
        : "Product launch folder opened locally.",
    );
  }

  function reset() {
    setFolder("launch");
    setQuery("");
    setSort("recent");
    setSelected(new Set(["brief"]));
    setDetailId("brief");
    setMessage("File browser sample reset. No files or folders changed.");
    searchRef.current?.focus({ preventScroll: true });
  }

  return (
    <section className="file-browser-demo" aria-label="File browser preview">
      <TidalFileBrowser
        title="Project files"
        eyebrow={null}
        description="Browse fictional folders, search local rows, select files, and inspect one useful sample document."
        path={[
          {
            id: "workspace",
            label: "Workspace",
            accessibleLabel: "Open sample workspace",
            current: folder === "workspace",
            onNavigate:
              folder === "workspace"
                ? undefined
                : () => openFolder("workspace"),
          },
          ...(folder === "launch"
            ? [
                {
                  id: "launch",
                  label: "Product launch",
                  accessibleLabel: "Product launch folder",
                  current: true,
                },
              ]
            : []),
        ]}
        items={visibleItems}
        search={{
          value: query,
          label: "Search this folder",
          placeholder: "Search files and folders",
          inputRef: searchRef,
          inputProps: { name: "file-query", autoComplete: "off" },
          onValueChange: (nextQuery) => {
            setQuery(nextQuery);
            setMessage(
              nextQuery.trim()
                ? `Showing local matches for “${nextQuery.trim()}”.`
                : "File search cleared.",
            );
          },
        }}
        sort={{
          value: sort,
          label: "Sort rows",
          options: [
            { value: "recent", label: "Recently modified" },
            { value: "name", label: "Name" },
          ],
          onValueChange: (nextSort) => {
            setSort(nextSort as SortId);
            setMessage(
              nextSort === "name"
                ? "Rows sorted by name."
                : "Rows sorted by fictional modification date.",
            );
          },
        }}
        onSelectionChange={(item, nextSelected) => {
          setSelected((current) => {
            const next = new Set(current);
            if (nextSelected) next.add(item.id);
            else next.delete(item.id);
            return next;
          });
          setMessage(
            `${item.accessibleName} ${nextSelected ? "selected" : "unselected"}.`,
          );
        }}
        onOpenItem={(item) => {
          const sample = item as SampleItem;
          if (sample.folderTarget) {
            openFolder(sample.folderTarget);
            return;
          }
          setDetailId(item.id);
          setMessage(`${item.accessibleName} details opened.`);
        }}
        detail={
          detailItem ? (
            <FileDetail
              item={detailItem}
              onClose={() => {
                pendingFocus.current = { rowId: detailItem.id };
                setDetailId("");
                setMessage("File detail closed.");
              }}
            />
          ) : null
        }
        emptyMessage={
          <div className="file-browser-demo-empty">
            <FolderOpen size={22} aria-hidden="true" />
            <strong>No local matches</strong>
            <span>Clear the search to see this folder again.</span>
          </div>
        }
        footer={
          <div className="file-browser-demo-footer">
            <span>
              Fictional rows and local React state. No filesystem, upload,
              request, or storage access.
            </span>
            <button type="button" onClick={reset}>
              <RotateCcw size={14} aria-hidden="true" />
              Reset sample
            </button>
          </div>
        }
      />
      <p className="file-browser-demo-status" role="status" aria-live="polite">
        {message}
      </p>
    </section>
  );
}

function FileDetail({
  item,
  onClose,
}: {
  item: SampleItem;
  onClose: () => void;
}) {
  return (
    <div className="file-browser-demo-detail">
      <div className="file-browser-demo-detail-mark" aria-hidden="true">
        {item.kind === "folder" ? <Folder size={20} /> : <FileText size={20} />}
      </div>
      <button
        className="file-browser-demo-detail-close"
        type="button"
        aria-label={`Close ${item.accessibleName} details`}
        onClick={onClose}
      >
        <X size={16} aria-hidden="true" />
      </button>
      <span>Selected item</span>
      <h3>{item.name}</h3>
      <p>{item.detail}</p>
      <dl>
        <div>
          <dt>Type</dt>
          <dd>{item.kind}</dd>
        </div>
        <div>
          <dt>Size</dt>
          <dd>{item.size ?? "Folder"}</dd>
        </div>
      </dl>
      {item.id === "brief" ? (
        <a href="/sample-project-brief.txt" download>
          Download sample brief
        </a>
      ) : (
        <span className="file-browser-demo-detail-static">
          Display-only sample row
        </span>
      )}
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <FileBrowserDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

title, consumer-owned path and items are required. Path items support current, disabled, native href or composed native button navigation. Rows describe file or folder kind, accessibleName, ReactNode name/subtitle/size/modified/meta/icon, ISO dateTime, controlled selected state, disabled state, optional native href, row/link/button/selection attributes and refs. Optional controlled search and sort controls compose caller native handlers before higher callbacks; preventDefault suppresses the higher callback. Optional onSelectionChange and onOpenItem expose the original item and native event. labels, headingLevel, eyebrow, description, detail, detailLabel, emptyMessage, footer, native section attributes/ref and labelling remain consumer-owned. Links preserve modified-click behavior unless a consumer intercepts an unmodified primary click. The block performs no filesystem, upload, request, storage, route or persistence action.
