Skip to main content

OutlinedTextField

Function OutlinedTextField 

Source
pub fn OutlinedTextField(
    modifier: Modifier,
    value: String,
    on_value_change: impl Fn(String) + 'static,
    config: OutlinedTextFieldConfig,
) -> View
Expand description

M3 Outlined Text Field with floating label, leading/trailing icons, and error state.

The label floats up when value is non-empty or when the field is focused. Note: focus-based floating is approximated via animated float_t - the label begins floating once on_value_change fires (i.e. when the user types). For strict focus-on-tap floating, pair with an external focus signal.

§Example

let text = remember(|| signal(String::new()));
OutlinedTextField(
    Modifier::new().fill_max_width().padding(16.0),
    text.get(),
    { let t = text.clone(); move |v| t.set(v) },
    OutlinedTextFieldConfig {
        label: Some("Email".into()),
        placeholder: Some("user@example.com".into()),
        ..Default::default()
    },
);