ORIZEN/TUI
ComponentsFilePicker

FilePicker

stable

Directory navigator with extension filtering and keyboard navigation.

Browser preview is a simulation. The copied component runs in actual terminal apps.

file-picker.tsx
> ./bin/file
Pick a file:
>drwxr-xr-x128 Bbin
>drwxr-xr-x 64 Bbooks
>drwxr-xr-x 96 Bmovies
>drwxr-xr-x288 Bprojects

Installation

npx orizen-tui@latest add file-picker

if dependency install fails, run: npm install ink@^5.0.1 react@^18.3.1 @types/react@^18.3.18 orizen-tui-core@latest

Usage

file-picker.imports.tsx
file-picker.example.tsx

Examples

Usage

file-picker.example1.tsx
> ./bin/file
Pick a file:
>drwxr-xr-x128 Bbin
>drwxr-xr-x 64 Bbooks
>drwxr-xr-x 96 Bmovies
>drwxr-xr-x288 Bprojects

API Reference

FilePicker

initialDir"."
string

Directory to open on mount

extensionsundefined
string[]

File extension filter e.g. [".ts", ".tsx"]

onSelectundefined
(entry: FileEntry) => void

Called when a file is selected

onCancelundefined
() => void

Called when Escape is pressed

height10
number

Number of visible directory entries

widthundefined
number

Width of the file picker in columns

readDirundefined
(dir: string) => Promise<FileEntry[]>

Custom directory reader (useful for testing)

joinPathundefined
(base: string, name: string) => string

Custom path join function

focustrue
boolean

Whether to accept keyboard input

colorundefined
string

Text color