Field
Field wraps a single form control with a label, required indicator, and validation message area.
Child controls like Input and Select inherit id and name through context, while validation rules live on the control — not on Field — so Leptos signals drive error state reactively. Compose Field inside Leptos ActionForm or router Form roots; Orbital does not ship a separate Form component.
Form wrapper)Pick a Leptos form root, then compose Orbital inside it:
| Root | When | |---|---| | leptos_router::components::Form | GET navigation — filters/search in URL (?q=) | | leptos::form::ActionForm | Server action POST with progressive enhancement | | <form on:submit> + Action::dispatch | SPA controlled submit from Store |
Typical stack: form root → FieldContextProvider → Field → Input / Select → Button. Form values live in a Leptos Store (store.field()) or standalone RwSignals. Native Orbital inputs use FormBind (RwSignal | store field | plain initial value for previews).
- Any labeled control: Input, Select, checkbox groups
- Forms where validation errors should appear below the control
- Horizontal label layouts in compact settings rows
- Wrap each control in
<Field label="…">(setnamewhen posting native forms). - Place the control as the child — e.g. Input or Select.
- Add
ruleson the child control (InputRule,SelectRule, …) to drive validation messages — for exampleInput bind=InputBind { value: signal.into(), rules: vec![InputRule::required(required)], ..Default::default() }. - Set
required=truewhen the label should show a required indicator. - For multi-control forms, use
FieldContextProviderat the form root.
Vertical layout (default): the label stacks above the control and validation messages appear below the input.
When required=true, the label shows a required indicator. Add matching InputRule::required on the child so empty values produce validation text below the control.
orientation=Horizontal places the label beside the control. Validation and hint text still render below the input; label width is fixed (~33%) so stacked horizontal fields align.
Field can wrap any control — here a Select with SelectRule::required. The field shows the label, required marker, and validation message from the child rules.