pub struct TextInput<'a> { /* private fields */ }Expand description
A styled single-line text input.
let mut email = String::new();
ui.add(TextInput::new(&mut email).label("Email").hint("you@example.com"));§Ids, focus, and flash state
Flash animations, focus, and cursor state are keyed off the widget’s
egui id. Without id_salt, the id is derived from
egui’s auto-id counter, which is layout-dependent — if a sibling
appears or disappears above this input between frames, the id shifts
and any in-flight flash, focus, or cursor state is lost. Any input
you flash via ResponseFlashExt should pin
its id with id_salt.
Implementations§
Source§impl<'a> TextInput<'a>
impl<'a> TextInput<'a>
Sourcepub fn label(self, text: impl Into<WidgetText>) -> Self
pub fn label(self, text: impl Into<WidgetText>) -> Self
Show a label above the input.
Sourcepub fn hint(self, text: &'a str) -> Self
pub fn hint(self, text: &'a str) -> Self
Show placeholder-style hint text when the field is empty.
Sourcepub fn dirty(self, dirty: bool) -> Self
pub fn dirty(self, dirty: bool) -> Self
Mark the input as having unsaved changes. Shows a sky-coloured accent bar down the left side.
Sourcepub fn desired_width(self, width: f32) -> Self
pub fn desired_width(self, width: f32) -> Self
Desired width (points) for the editor portion of the widget.
Sourcepub fn id_salt(self, id: impl Hash) -> Self
pub fn id_salt(self, id: impl Hash) -> Self
Supply a stable id salt. Useful when two inputs share the same label.
Sourcepub fn compact(self, compact: bool) -> Self
pub fn compact(self, compact: bool) -> Self
Render with reduced vertical padding so the input matches the
height of RemovableChip and small-size
controls. Useful for inline path / chip rows where a full-height
input would dominate. Default: false (standard control height).