Skip to content
Twentyfirst UIHalo

File Browser

Data · FileBrowser, BulkActionBar, Breadcrumb

View as Markdown

A folder's folders and files as a grid or a list: breadcrumbs, search, preview, upload with progress, new folder, rename, move, trash and a selection with the bulk action bar. Your app keeps the files and does the uploads; the component shows them and asks.

  • items are the current folder's contents (kind: "folder" or a file kind; without it the kind comes from mime or the extension). path is the breadcrumb trail; onNavigate(id) opens a folder or a crumb (crumbs with href are links, with linkAs for your router).
  • A file with an image or PDF preview URL opens in a drawer; onOpen(item) gets every file. The kit loads only the URLs you give it.
  • onUpload(files) adds Upload and accepts dropped files. Pass uploads with progress (and part / parts for large files uploaded in pieces) to show each file's state; onCancelUpload adds a stop button.
  • onCreateFolder, onRename (in place, also F2), onMove with a folders tree (a picker dialog), onTrash (after a confirmation) and onDownload. Each may return a Promise.
  • Keyboard: arrow keys move between items, Enter opens, Space selects, F2 renames, Delete trashes, ⌘/Ctrl+A selects all, Escape clears the selection.
  • view, selected, query and preview work controlled or uncontrolled. Below 560px the toolbar wraps, the grid gets two columns and the list shows size and date under the name.
  • launch-video.mp4184 MB · Part 7 of 18 · 38%
Files

Props

FileBrowser

PropTypeNotes
surface?Surface`"glass"` for a translucent surface over a map, photo or video; `"solid"` opts out inside a glass provider.
itemsFileBrowserItem[]The current folder's folders and files.
path?{ id: string; name: string; href?: string }[]Breadcrumbs from the root to the current folder (`href` makes them links).
onNavigate?(folderId: string) => voidA folder or a breadcrumb was opened.
onOpen?(item: FileBrowserItem) => voidA file was opened (files with an image or PDF `preview` also open the preview drawer).
previewOnOpen?booleanSet `false` to open files only through `onOpen`.
linkAs?ElementTypeRouter link for breadcrumbs and "Open" (default `a`, or the provider's `linkAs`).
view?"grid" | "list"
defaultView?"grid" | "list"
onViewChange?(view: "grid" | "list") => void
selected?string[]
defaultSelected?string[]
onSelectedChange?(ids: string[]) => void
query?string
defaultQuery?string
onQueryChange?(query: string) => void
localSearch?booleanFilters `items` by name as you type (default); `false` when your server searches.
search?boolean`false` hides the search field.
searchPlaceholder?string
preview?string | nullThe id of the file shown in the preview drawer.
defaultPreview?string | null
onPreviewChange?(id: string | null) => void
onUpload?(files: File[]) => voidShows Upload and accepts dropped files; upload them yourself and pass `uploads`.
accept?stringFile types for the picker (`accept`).
uploads?FileBrowserUpload[]
onCancelUpload?(id: string) => void
onCreateFolder?(name: string) => void | Promise<void>
onRename?(id: string, name: string) => void | Promise<void>
onMove?(ids: string[], folderId: string) => void | Promise<void>With `folders`: Move opens a folder picker.
folders?FileBrowserFolder[]The folder tree for the move picker.
onTrash?(ids: string[]) => void | Promise<void>
onDownload?(ids: string[]) => void
foldersFirst?booleanFolders before files (default true).
loading?boolean
emptyText?string
label?stringAccessible name (default "Files").
actions?ReactNodeMore controls in the toolbar.
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.

BulkActionBar

PropTypeNotes
countnumberHow many items are selected; the bar hides at 0 (unless `keepOpen`).
actions?BulkActionBarAction[]
onClear?() => voidShows "Clear" and is called by it.
label?stringAccessible name of the toolbar (default "Bulk actions").
keepOpen?booleanStays visible with 0 selected (e.g. while an exit animation runs in your list).
floating?booleanDefault: the bar floats, sticky at the bottom of its scroll area (as in DataTable). `false` keeps it in the flow, e.g. at the top of a mail list.
children?ReactNodeMore controls after the actions (a menu, a select).
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.

Breadcrumb

PropTypeNotes
items(string | Crumb)[]The trail; the last one is the current page. Items with `href` are links, with `onClick` buttons.
linkAs?ElementTypeThe element links render as (default `a`), e.g. Next.js `Link`.
onNavigate?(index: number) => voidMakes every crumb but the last a button; receives its index.
label?stringAccessible name of the navigation (default "Breadcrumb").
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.