Skip to content

Component PasswordInput

MeowLynxSea edited this page Jun 18, 2026 · 5 revisions

PasswordInput

A single-line text input that masks its value. State is internal; the renderer paints a mask_char for each character.

use yororen_ui::headless::password_input::password_input;

password_input("password")
    .placeholder("Password")
    .mask_char('•')
    .max_length(128)
    .on_change({
        let entity = cx.entity();
        move |new: &str, _, cx| entity.update(cx, |s, _| s.password = new.to_string());
    })
    .on_submit({
        let entity = cx.entity();
        move |_, _, cx| entity.update(cx, |s, _| s.attempting_sign_in = true);
    })
    .render(cx, window)

Props

Method Purpose
placeholder(text) Hint shown when empty.
mask_char(c) Character painted for each input char. Default '•'.
max_length(n) Hard cap on the value's UTF-8 byte length.
disabled(v) Disable interaction.
on_change(closure) Fn(&str, &mut Window, &mut App) + 'static + Send + Sync. Fires on every accepted change.
on_submit(closure) Fn(&str, &mut Window, &mut App) + 'static + Send + Sync. Fires on Enter.
has_custom_bg(v) / custom_bg(hsla) Override background.
has_custom_border(v) / custom_border(hsla) Override border.
has_custom_focus_border(v) / custom_focus_border(hsla) Override focus border.
custom_text_color(hsla) Override text color.

Factory takes (id) only. .render(cx, window) returns AnyElement. The on_change and on_submit callbacks receive the real &str — never log it, never paint it. The boot step from TextInput (text_input::init(cx)) also covers this component.

See also: TextInput, SearchInput, Form.

Clone this wiki locally