Skip to content

Component FilePathInput

MeowLynxSea edited this page Jun 13, 2026 · 6 revisions

FilePathInput

A text input specialised for file paths. Has a leading folder icon and a trailing "Browse" button. Clicking Browse fires on_browse — typically the caller opens a native file picker and writes the picked path back via on_change.

Import

use yororen_ui::headless::file_path_input::file_path_input;

Minimal example

use yororen_ui::headless::file_path_input::file_path_input;

file_path_input("config-path")
    .placeholder("/path/to/config.toml")
    .value(self.config_path.clone())
    .on_change({
        let entity = cx.entity();
        move |new: &str, _window, cx| {
            entity.update(cx, |s, _cx| s.config_path = new.to_string());
        }
    })
    .on_browse(|_picked: &str, _window, _cx| {
        // Renderer has already written the picked path into the input's
        // state and fired `on_change`; this hook is for caller extras.
    })
    .render(cx, window)

Props

Method Purpose
placeholder(text) Hint shown when empty.
value(s) Current value (String-like).
disabled(v) Disable interaction (and the Browse button).
on_change(closure) Fn(&str, &mut Window, &mut App) + 'static + Send + Sync.
on_browse(closure) Fn(&str, &mut Window, &mut App) + 'static + Send + Sync. The Browse button was clicked. The argument is the current value.
has_custom_bg(v) / custom_bg(hsla) Override the background.
has_custom_border(v) / custom_border(hsla) Override the border.
has_custom_focus_border(v) / custom_focus_border(hsla) Override the focus border.
custom_text_color(hsla) Override the text color.

Notes

  • Factory takes (id) only — no cx argument.
  • .render(cx, window) is two-arg and returns AnyElement. The window is required for IME / paste.
  • The headless layer does not open a file picker — it only fires on_browse. The caller is expected to use gpui's Window::open_file_dialog (or platform equivalent) and write the result back through the input's state.
  • The state is minted internally by the renderer.

See also

TextInput, SearchInput, PasswordInput

Clone this wiki locally