Skip to content

Component FormField

MeowLynxSea edited this page Jun 18, 2026 · 1 revision

FormField

A labelled wrapper around one input. Pairs with Form but can be used standalone.

use yororen_ui::headless::form_field::form_field;
use yororen_ui::headless::text_input::text_input;

form_field("settings-email", "email", &mut *cx)
    .label("Email")
    .required(true)
    .help("Used for sign-in.")
    .error(self.email_error.as_deref())
    .input(
        text_input("settings-email-input")
            .placeholder("you@example.com")
            .on_change({
                let entity = cx.entity();
                move |new: &str, _, cx| entity.update(cx, |s, _| s.email = new.to_string());
            })
            .render(cx, window)
    )
    .render(cx)

Props

Method Purpose
label(text) Field label.
required(v) Mark the field as required.
help(text) Helper line below the input.
error(text) Error message below the input.
input(el) The input element (typically a rendered text input / select).

Factory takes (id, name, _cx). The name is the field's key — Form::value("email", …) and Form::error("email", …) match by this string. .render(cx) returns Stateful<Div>.

See also: Form, TextInput.

Clone this wiki locally