FieldControl
A form row that inherits the surrounding FormGroup's disabled and validation state, and hands its control a generated id via render prop.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | Label for the form control. |
children | ReactNode | (({ id, disabled, invalid }) => ReactNode) | — | The control or a render prop receiving id, disabled, and invalid from context. |
hint | ReactNode | — | Dim helper line. Replaced by message when validation is active. |
tone | ValidationTone | — | Overrides the group's tone for this row only. |
message | ReactNode | — | Validation message for this row. Overrides the group's message. |
required | boolean | — | Appends a red asterisk to the label. |
disabled | boolean | — | Disables the row. Defaults to the group's disabled state. |
labelMeta | ReactNode | — | Right-aligned meta next to the label. |
FieldControl extends HTMLAttributes<HTMLDivElement>.
Usage
Basic
With render prop
With validation
import { FieldControl } from "@solarius/onset";
import type { FieldControlProps } from "@solarius/onset";
<FieldControl label="API key">
<Input placeholder="sk_live_..." />
</FieldControl>
<FieldControl label="Endpoint URL" required>
{({ id, invalid }) => (
<Input id={id} invalid={invalid} placeholder="https://" />
)}
</FieldControl>