Form control provides context such as filled/focused/error/required for form inputs.

This is a help text
rc.form_control(
    rc.form_label("First Name", html_for="email"),
    rc.checkbox("Example"),
    rc.form_helper_text("This is a help text"),
    is_required=True,
)

The example below shows a form error when then name length is 3 or less.

Name should be more than four characters
import reflex_chakra as rc
import reflex as rx


class FormErrorState(rx.State):
    name: str

    @rx.var
    def is_error(self) -> bool:
        return len(self.name) <= 3


def form_state_example():
    return rc.vstack(
        rc.form_control(
            rc.input(
                placeholder="name",
                on_blur=FormErrorState.set_name,
            ),
            rx.cond(
                FormErrorState.is_error,
                rc.form_error_message(
                    "Name should be more than four characters"
                ),
                rc.form_helper_text("Enter name"),
            ),
            is_invalid=FormErrorState.is_error,
            is_required=True,
        )
    )

rc.FormControl

Provide context to form components.

PropType | ValuesDefault
is_disabled
bool
is_invalid
bool
is_read_only
bool
is_required
bool
label
str

Event Triggers

See the full list of default event triggers

rc.FormLabel

A form label component.

PropType | ValuesDefault
html_for
str

rc.FormErrorMessage

A form error message component.

Props

No component specific props

rc.FormHelperText

A form helper text component.

Props

No component specific props