Field API
- Component status:
deprecated
import { Field } from "@stratakit/bricks";// ORimport * as Field from "@stratakit/bricks/Field";Field.Root Deprecated
Section titled âField.Root DeprecatedâA container for form controls. It manages ID associations, and provides a consistent layout and spacing.
Example:
<Field.Root> <Field.Label>Label</Field.Label> <Field.Control render={<TextBox.Input />} /></Field.Root>Supports a layout prop, which can be set to inline to align the label and
control horizontally.
Should contain a Field.Label component paired with a form control.
Supported form controls include:
TextBox.InputTextBox.TextareaCheckboxRadioSwitch
"inline" | undefined(optional)Allows overriding the default block layout for text controls.
Additional props
Section titled âAdditional propsâField.Label Deprecated
Section titled âField.Label DeprecatedâA label for the fieldâs control element. This is automatically associated
with the controlâs id.
Additional props
Section titled âAdditional propsâField.Description Deprecated
Section titled âField.Description DeprecatedâA description for the fieldâs control element. This is automatically associated with the control.
Should not include content without an adequate text alternative (e.g. interactive elements).
Additional props
Section titled âAdditional propsâField.Control Deprecated
Section titled âField.Control DeprecatedâThe control component for the field.
Use the render prop to render the control component.
<Field.Control render={<TextBox.Input />} />If the rendered component uses a compositional API, then use a function
within render to apply the controlProps to the correct sub-component:
<Field.Control render={(controlProps) => ( <TextBox.Root> <TextBox.Icon href={svgPlaceholder} /> <TextBox.Input {...controlProps} /> </TextBox.Root> )}/>If you need a custom id set for the control, set it on this component
instead of the control component within render.
<Field.Control id="custom" render={<TextBox.Input />} />Element | ((props: Omit<HTMLAttributes<any> & { ref?: Ref<any> | undefined; }, "children">) => ReactNode)(required)string | undefined(optional)The unique ID of the item. This will be used to register the item in the
store and for the elementâs id attribute. If not provided, a unique ID
will be automatically generated.
Field.ErrorMessage Deprecated
Section titled âField.ErrorMessage DeprecatedâAn associated error message for a field. When used within <Field.Root>, the
associated form control will be rendered with aria-invalid="true".
Example:
<Field.Root> <Field.Label>Label</Field.Label> <Field.Control render={<TextBox.Input />} /> <Field.ErrorMessage>Something is wrong!</Field.ErrorMessage></Field.Root>