pub struct TextArea { /* private fields */ }Expand description
A multi-line editable text area bound to a RwSignal<String> — the multi-line sibling of Input.
A base primitive: unstyled (wrap it in a box for a border/background), keyboard-driven, no soft-wrap (only
\n breaks lines, so long lines overflow horizontally). It requests focus on tap, positions the caret at
the click, edits the bound signal from key events (typing, Enter for a newline, Backspace/Delete joining
lines, arrows in all four directions, Home/End, Tab), and draws a caret. Its measured height grows with the
line count, so wrapping it in a LayoutScrollArea gives a scrolling editor.
Selection (Shift+arrows, Ctrl+A, shift-click) with copy, cut and paste, newlines and all. IME is not
yet supported.
Implementations§
Source§impl TextArea
impl TextArea
pub fn new( value: RwSignal<String>, layout_style: LayoutStyle, style_fn: impl Fn() -> TextStyle + 'static, ) -> Result<Self, LayoutError>
Sourcepub fn placeholder(self, p: impl Into<String>) -> Self
pub fn placeholder(self, p: impl Into<String>) -> Self
A muted hint shown while the value is empty.
Sourcepub fn request_focus(&self)
pub fn request_focus(&self)
Gives keyboard focus to this area (as a tap would), leaving the caret where it was. For programmatic focus — e.g. a container autofocusing the editor when its tab or window becomes active.
Sourcepub fn focus_handle(&self) -> FocusHandle
pub fn focus_handle(&self) -> FocusHandle
A Copy focus::FocusHandle to this area, so a caller that has moved it into a container can still
focus it later (e.g. autofocus on tab activation) without keeping a reference to the area itself.