Skip to main content

explorer

Creates a file explorer dialog. Wraps the folder component with a navigation bar, context menu, and dialog integration.

Usage

Modular:

import { explorer, filePickerOpen, filePickerSave, folderPicker } from "/42/ui/desktop/explorer.js"
//Or
const { explorer } = sys42

const el = await explorer("~/documents")
const { ok, directory, selection } = await filePickerOpen("~/documents")
const { ok, directory, selection } = await filePickerSave("~/documents")
const { ok, directory } = await folderPicker("~/documents")

Props

PropertyTypeDescription
valueStringThe path to display. Default is "/". If a file path is given, it navigates to the parent directory and selects the file.
globBooleanWhether to use glob pattern matching for filtering.
multiselectableBooleanWhether more than one item can be selected. Default is true.

Properties

PropertyTypeDescription
valueStringGet or set the current directory path. Setting a file path navigates to its parent and selects it.
globBooleanGet or set glob pattern matching on the folder.
filterStringGet or set the file filter (e.g. "*.txt").
filterTypeStringGet or set the filter type (e.g. "disable" to show disabled files).
multiselectableBooleanGet or set whether multiple items can be selected.
selectionArrayGet or set the currently selected items.
isPickerBooleanWhether the explorer is in file-picker mode.
showDisabledFilesOptionBooleanWhether to show the "Show Disabled Files" option in the context menu.
titlePrefixStringPrefix for the dialog title (e.g. "Open File — ").
titleStringOverride the dialog title entirely.
pictoStringOverride the dialog pictogram icon.

Methods

MethodDescription
selectAll()Select all items in the folder.
folderUp()Navigate to the parent directory.
go(path)Navigate to a path. If already at that path, refreshes the folder.
close(ok)Close the parent dialog. Pass true to confirm, false to cancel.

Events

EventDescription
ui:explorer.navigateDispatched when the folder renders a new directory.

explorer(path?, options?)

Opens an explorer dialog.

ParameterTypeDescription
pathStringThe directory to open. Default is "/".
optionsObjectAdditional options (see below).

Options

PropertyTypeDescription
signalAbortSignalSignal to abort the dialog.
pictoStringDialog pictogram icon.
isPickerBooleanWhether the explorer is in file-picker mode.

Returns a Promise<ExplorerComponent>.

filePickerOpen(path?, options?)

Opens a file-picker dialog for opening files.

const { ok, directory, selection, files } = await filePickerOpen("~/documents", {
types: [{ accept: { "text/plain": [".txt"] }, description: "Text Files" }],
multiple: true,
})
ParameterTypeDescription
pathStringThe directory to start in. Default is the home directory.
optionsObjectAdditional options (see below).

Options

PropertyTypeDescription
typesArrayArray of file type filters with accept and description.
acceptStringComma-separated MIME types or extensions (converted to types internally).
multipleBooleanAllow selecting multiple files. Default is false.
returnFilesBooleanReturn File objects in the result. Default is false.
showDisabledFilesBooleanShow the "Show Disabled Files" toggle. Default is false.
excludeAcceptAllOptionBooleanExclude the "All Files" option from the filter dropdown.
agreeString/ObjectLabel or config for the confirm button. Default is "Open".
declineString/ObjectLabel or config for the cancel button. Default is "Cancel".
signalAbortSignalSignal to abort the dialog.

Returns a Promise<{ ok, directory, selection, files? }>.

PropertyDescription
okWhether the dialog was confirmed.
directoryThe directory the dialog was in when confirmed.
selectionArray of selected file paths.
filesArray of File objects (only if returnFiles is true).

filePickerSave(path?, options?)

Opens a file-picker dialog for saving files.

const { ok, directory, selection } = await filePickerSave("~/documents", {
suggestedName: "document.txt",
})
ParameterTypeDescription
pathStringThe directory to start in. Default is the home directory.
optionsObjectAdditional options (see below).

Options

PropertyTypeDescription
suggestedNameStringPre-filled filename. Default is a timestamp-based name.
suggestedNamePrefixStringPrefix for the suggested name (e.g. "document" becomes "document_2026-07-22_123456").
agreeString/ObjectLabel or config for the confirm button. Default is "Save".
declineString/ObjectLabel or config for the cancel button. Default is "Cancel".
signalAbortSignalSignal to abort the dialog.

Returns a Promise<{ ok, directory, selection }>.

If the selected file already exists, a confirmation dialog appears asking to overwrite or rename.

PropertyDescription
okWhether the dialog was confirmed.
directoryThe directory the dialog was in when confirmed.
selectionArray with the chosen file path.

folderPicker(path?, options?)

Opens a folder-picker dialog.

const { ok, directory } = await folderPicker("~/documents")
ParameterTypeDescription
pathStringThe directory to start in. Default is the home directory.
optionsObjectAdditional options (see below).

Options

PropertyTypeDescription
agreeString/ObjectLabel or config for the confirm button. Default is "Choose".
declineString/ObjectLabel or config for the cancel button. Default is "Cancel".
returnPathsBoolean/ObjectIf set, includes all file paths in the selected directory (recursive).
signalAbortSignalSignal to abort the dialog.

Returns a Promise<{ ok, directory, paths? }>.

PropertyDescription
okWhether the dialog was confirmed.
directoryThe selected directory path (including the chosen name if typed).
pathsArray of file paths (only if returnPaths is set).