Skip to content

Component TextArea

MeowLynxSea edited this page Jun 13, 2026 · 4 revisions

TextArea

A multi-line text input. Paste keeps newlines (unlike text_input, which replaces them with spaces).

Import

use yororen_ui::headless::text_area::text_area;

Minimal example

use yororen_ui::headless::text_area::text_area;

text_area("bio")
    .placeholder("Tell us about yourself…")
    .max_length(2048)
    .on_change({
        let entity = cx.entity();
        move |new: &str, _window, cx| {
            entity.update(cx, |s, _cx| s.bio = new.to_string());
        }
    })
    .render(cx, window)

Props

Method Purpose
placeholder(text) Hint shown when empty.
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.
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.
  • Paste with newlines is preserved; text_input strips them.
  • on_change receives &str, not SharedString. Convert with .to_string().
  • The state is minted internally by the renderer via window.use_keyed_state(...).

See also

TextInput, SearchInput, Form

Clone this wiki locally