block · field
Field and validation
A native field composition for labels, descriptions and application-owned validation messages.
Install with
npx @madojs/ui@latest add field.
Block
Field and validation
Composition
- Group a visible label, one native control, supporting description and conditional error. Use fieldset/legend for related choices.
Public API
-
class
mado-ui-field / label / description / error - Single-control field composition.
-
class
mado-ui-fieldset / mado-ui-field-legend - Native related-control grouping.
-
attribute
data-invalid - Visual hook on the field wrapper; it does not set control validity.
-
attribute
aria-invalid / aria-describedby - Application-owned control state and description/error references.
Detected public classes
.mado-ui-field.mado-ui-field-description.mado-ui-field-error.mado-ui-field-label.mado-ui-field-legend.mado-ui-fieldset
Detected public CSS properties
--mado-ui-color-danger--mado-ui-color-danger-text--mado-ui-color-text--mado-ui-color-text-muted--mado-ui-field-description-color--mado-ui-field-error-accent--mado-ui-field-error-color--mado-ui-field-gap--mado-ui-field-invalid-label-color--mado-ui-field-label-color--mado-ui-fieldset-gap--mado-ui-space-1--mado-ui-space-2--mado-ui-space-3
Accessibility contract
- The label uses for/id or native wrapping, and every referenced description/error id must exist while referenced.
- Expose an error only after the chosen validation lifecycle; include useful text rather than relying on color.
Keyboard
- The recipe adds no composite keyboard model; native interactive descendants keep their browser-defined keys and Tab order.
Focus
- Validation keeps focus on the invalid control or moves it deliberately after submit; the wrapper and messages remain outside Tab order.
Fallback
- Without the copied stylesheet, the semantic source HTML remains readable and operable.
Installation graph
Direct dependencies
-
Mado UI theme
theme
Resolved install order
-
Mado UI theme
theme
Copied source
The CLI resolves each registry source path into the configured project target. Links below point to the exact catalog build tag.
-
blocks/field/mado-ui-field.css{styles}/mado-ui-field.css