Components / TextField

TextField

Single-line text input with selection, clipboard, views inside and a clear button.

Example

The component itself, running in WebAssembly, beside its code in a playground. Try it.

Code

use ravenrs::prelude::*;

fn text_field() -> impl View {
    let name = State::new(String::new());
    let price = State::new(String::from("49,90"));
    let shown = name.clone();
    VStack::new((
        TextField::new(name.binding()).placeholder("Full name").icon(IconName::User).clearable(),
        TextField::new(price.binding())
            .placeholder("Price")
            .size(ButtonSize::Small)
            .prefix(Text::new("R$").foreground(Semantic::InkMuted))
            .suffix(Badge::new("per month")),
        Text::dynamic(move || format!("Hello, {}", shown.get())).foreground(Semantic::InkMuted),
    ))
    .spacing(12.0)
    .align(Align::Stretch)
}

Open in the playground, with every example →

Full API of TextField →