Guide / Controls and forms

Keep the value outside the control that edits it.

LumaFlow inputs are controlled by explicit state. Native UI Toolkit handles focus, keyboard input and accessibility while your application owns the value.

One state value, one source of truth.

Programmatic changes refresh the control without replaying the user callback. This keeps validation and domain updates in one predictable direction.

ProjectForm.cs
private readonly State<string> _name = new("");

new TextField(
  _name,
  label: "Project name",
  placeholder: "Enter a name",
  onChanged: value => SaveDraft(value));

Model validation as owned form state.

Keep validation close to the field or form owner. Submit only after the form has validated its fields; error presentation remains part of the control contract.

Do not rebuild a form to reset it.

Reset owned field values deliberately. Rebuilding a widget tree is not a substitute for deciding what application data should change.

Style controls through a theme, then override with intent.

ThemeData supplies component defaults. A local style can override only the values it needs while retaining the rest of the active theme.

ApplicationTheme.cs
new Theme(
  theme,
  new Button("Save project", Save, ButtonVariant.Primary));
Return to the guides