Fusuma

Components / Composite

form_field

A label, the control it names, and under it a hint (a rule, an example) or, when error is not empty, the error in the colour of a danger.

Try it

This is the Text page of the gallery, running in your browser: form_field is on it, and it is the real widget. Press Run, then use it.

Live: Text, where form_field is usedOpen full size

Also on this pagetext_field

A label, the control it names, and under it a hint (a rule, an example) or, when error is not empty, the error in the colour of a danger. The hint and the error are one line of text that is kept: it changes, it is never removed.

Signature

pub fn form_field<'a, M: Clone + 'a, V: View<M> + 'a>( label: &'a str, control: V, hint: &'a str, error: &'a str, ) -> impl View<M> + 'a

Example

use fusuma::{form_field, text_field};
let email = "ada@";
let error = if email.contains('.') { "" } else { "Not an email address" };
let view = form_field("Email", text_field(email).on_input(|_| ()), "We never share it", error);
let built = fusuma::doc::built::<(), _>(&view);
assert!(built.texts().contains(&"Email"));

All components · Source