Skip to content

Component FilePathInput

MeowLynxSea edited this page Feb 13, 2026 · 6 revisions

FilePathInput

A file/folder path selector.

This control is read-only: users choose a path via the "Choose..." button.

FilePathInput always owns internal value state so it can immediately reflect the chosen path. You can still observe changes via on_change.

Example

use gpui::ElementId;
use yororen_ui::component::{file_path_input, FilePathStatus};

let view = file_path_input()
    .key(ElementId::from(("settings", "workspace_path")))
    .placeholder("/path/to/folder")
    .status(FilePathStatus::Ok)
    .on_change(|path, _window, _cx| {
        // path: PathBuf
    });

When to use

  • Settings screens where users choose a directory or executable
  • Anything that should use the OS path picker instead of free-form typing

Not a good fit:

  • Free-form path editing (use TextInput)

API

  • file_path_input(): constructor
  • id(...) / key(...): stable identity
  • value(PathBuf): initial value
  • placeholder("...")
  • localized(): use i18n placeholder (see Internationalization)
  • disabled(bool)
  • status(FilePathStatus):
    • Ok / Warning / Error
  • on_change(|path, window, cx| ...): fired when a new path is picked
  • Styling: bg/border/focus_border/text_color/height

Interaction and behavior

  • Clicking the button prompts for a single file or directory.
  • If status(...) is not set:
    • empty value: no status
    • non-empty value: treated as Ok

Notes

  • The button label in the UI is localized (currently "选择…").

Defaults

  • Height: 36px
  • Placeholder: "选择路径…"
  • Value state: always internal (updates immediately after picking)

Clone this wiki locally