File browser
Folders and files with a folder tree, breadcrumbs, search, list and grid views, selection, a context menu, renaming and drag and drop.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
items | FileBrowserItem[] | [] | Every known folder and file, flat. JSON in markup. |
folder | string | — | The open folder's id; empty for the root. |
root-label | string | — | The root folder's name. Defaults to the "My files" message. |
label | string | — | The browser's accessible name. Defaults to the "Files" message. |
view | FileBrowserView | list | list (the default) or grid. |
sort | FileBrowserSort | name | The column the items are sorted by. Folders always come first. |
sort-direction | FileBrowserSortDirection | asc | asc (the default) or desc. |
selection | FileBrowserSelection | multiple | multiple (the default) or single. |
value | string[] | [] | The selected ids. |
actions | FileBrowserAction[] | [] | The commands of the context menu and the selection bar. JSON in markup. |
search | 'local' | 'remote' | local | local (the default) filters the open folder by name; remote fires search for the app to answer. |
locale | string | — | The locale for dates and sizes; the nearest lang when empty. |
Slots
| Name | Description |
|---|---|
empty | Replaces the empty-folder panel. |
Events
| Name | Type | Description |
|---|---|---|
load-error | CustomEvent<FileBrowserLoadErrorDetail> | loadChildren rejected. |
folder-change | CustomEvent<FileBrowserFolderChangeDetail> | The user opened another folder. |
item-open | CustomEvent<FileBrowserItemDetail> | The user opened a file (double-click or Enter). |
selection-change | CustomEvent<FileBrowserSelectionChangeDetail> | The user changed the selection. Does not bubble. |
item-action | CustomEvent<FileBrowserItemActionDetail> | The user picked an action for the selected items. |
item-rename | CustomEvent<FileBrowserItemRenameDetail> | The user renamed an item in place. |
files-drop | CustomEvent<FileBrowserFilesDropDetail> | The user dropped files from the desktop. |
item-move | CustomEvent<FileBrowserItemMoveDetail> | The user dropped items on a folder. |
search | CustomEvent<FileBrowserSearchDetail> | With search="remote", the query to run. |
sort-change | CustomEvent<FileBrowserSortChangeDetail> | The user changed the sort order. |
view-change | CustomEvent<FileBrowserViewChangeDetail> | The user switched between the list and the grid. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
toolbar | The bar with the breadcrumbs, search, sort and view controls. |
tree | The folder pane. |
content | The scrolling list or grid. |
item | Each item of the list or grid. |
selection-bar | The bar shown while items are selected. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-file-browser--height | length | 440px | The browser's height. |
--c2-file-browser--border | border | 1px solid #e4e4e7 | |
--c2-file-browser--border-radius | radius | 8px | |
--c2-file-browser--background-color | color | #ffffff | |
--c2-file-browser--color | color | #18181b | |
--c2-file-browser--font-size | font-size | 14px | |
--c2-file-browser--narrow-width | length | 560px | Below this width the folder pane hides. |
--c2-file-browser__divider--border | border | 1px solid #e4e4e7 | Lines between the panes, the toolbar and the rows. |
--c2-file-browser__tree--width | length | 220px | |
--c2-file-browser__tree--background-color | color | #fafafa | |
--c2-file-browser__muted--color | color | #52525b | Column headers, dates, sizes and kinds. |
--c2-file-browser__row--height | length | 36px | |
--c2-file-browser__row__hover--background-color | color | #f4f4f5 | |
--c2-file-browser__row__selected--background-color | color | #edf1fe | |
--c2-file-browser__accent--color | color | rgb(2, 101, 220) | Check boxes, the focus mark and drop targets. |
--c2-file-browser__check__checked--color | color | #ffffff | |
--c2-file-browser__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-file-browser__tile--min-width | length | 128px | The narrowest a grid tile gets. |
--c2-file-browser__tile--border-radius | radius | 8px | |
--c2-file-browser__thumbnail--background-color | color | #f4f4f5 | |
--c2-file-browser__selection-bar--background-color | color | #27272a | |
--c2-file-browser__selection-bar--color | color | #fafafa | |
--c2-file-browser__icon__folder--color | color | #e0a526 | |
--c2-file-browser__icon__pdf--color | color | #dc2626 | |
--c2-file-browser__icon__image--color | color | #0d9488 | |
--c2-file-browser__icon__video--color | color | #db2777 | |
--c2-file-browser__icon__audio--color | color | #9333ea | |
--c2-file-browser__icon__archive--color | color | #a16207 | |
--c2-file-browser__icon__document--color | color | #2563eb | |
--c2-file-browser__icon__spreadsheet--color | color | #16a34a | |
--c2-file-browser__icon__presentation--color | color | #ea580c | |
--c2-file-browser__icon__code--color | color | #7c3aed | |
--c2-file-browser__icon__file--color | color | #71717a | Text and unknown files. |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under file-browser, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
files | Files | — |
root | My files | — |
folders | Folders | — |
path | Folder path | — |
searchIn | Search in {0} | {0} folder |
contents | Contents of {0} | {0} folder |
up | Parent folder | — |
view | View | — |
listView | List view | — |
gridView | Grid view | — |
sort | Sort | — |
sortedBy | Sort: {0}, {1} | {0} column {1} direction |
ascending | Ascending | — |
descending | Descending | — |
name | Name | — |
modified | Modified | — |
size | Size | — |
kind | Kind | — |
sortBy | {0}, sorted {1} | {0} column {1} direction |
itemName | {0}, {1}, {2}, modified {3} | {0} name {1} kind {2} size {3} modified |
actions | Actions | — |
more | More actions for {0} | {0} name |
selected | {0} selected · {1} | {0} count {1} size |
clearSelection | Clear selection | — |
rename | Rename {0} | {0} name |
empty | This folder is empty | — |
emptyHint | Drop files here to add them. | — |
noResults | No results for “{0}” | {0} query |
noResultsHint | Try another name. | — |
loading | Loading… | — |
opened | {0}, {1} items | {0} folder {1} count |
moving | Moving {0} items to {1} | {0} count {1} folder |
dropping | Adding {0} files to {1} | {0} count {1} folder |
kindFolder | Folder | — |
kindPdf | — | |
kindImage | {0} image | {0} format |
kindVideo | {0} video | {0} format |
kindAudio | {0} audio | {0} format |
kindArchive | {0} archive | {0} format |
kindDocument | Document | — |
kindSpreadsheet | Spreadsheet | — |
kindPresentation | Presentation | — |
kindText | Text | — |
kindCode | {0} | {0} format |
kindFile | {0} file | {0} format |