cv-field
Form-field wrapper that standardizes label, description, error, required, disabled, and invalid linkage for one slotted control.
Headless: None (UIKit-only component)
Usage
Anatomy
text
<cv-field>
├── <label part="label"><slot name="label"></slot></label>
├── <div part="control"><slot></slot></div>
├── <div part="description"><slot name="description"></slot></div>
└── <div part="error"><slot name="error"></slot></div>Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
for | String | auto | Explicit id of the control to label |
required | Boolean | false | Propagated to supported direct child controls |
disabled | Boolean | false | Propagated to supported direct child controls |
invalid | Boolean | false | Propagated as invalid and aria-invalid="true" |
size | small | medium | large | "medium" | Density hint exposed for composed field styling |
orientation | vertical | horizontal | "vertical" | Layout orientation |
Slots
| Slot | Description |
|---|---|
label | Visible label content |
(default) | One direct control owned by the field wrapper |
description | Helper text linked through aria-describedby |
error | Validation text linked only while invalid |
CSS Parts
| Part | Element | Description |
|---|---|---|
label | <label> | Label wrapper |
control | <div> | Default slot wrapper |
description | <div> | Helper text wrapper |
error | <div> | Error text wrapper |
CSS Custom Properties
| Property | Default | Description |
|---|---|---|
--cv-field-gap | var(--cv-space-1, 4px) | Vertical spacing between parts |
--cv-field-horizontal-gap | var(--cv-space-3, 12px) | Horizontal layout column gap |
--cv-field-label-color | var(--cv-color-text, #e8ecf6) | Label text color |
--cv-field-label-font-size | var(--cv-font-size-sm, 13px) | Label text size |
--cv-field-meta-font-size | var(--cv-font-size-xs, 12px) | Description and error size |
--cv-field-description-color | var(--cv-color-text-muted, #9aa6bf) | Description text color |
--cv-field-error-color | var(--cv-color-danger, #ff6b6b) | Error text color |
Accessibility Contract
- When the label slot has content, the control receives
aria-labelledby. - When the description slot has content, the control receives
aria-describedby. - When
invalidand the error slot both exist, the error id is appended toaria-describedby. - The error wrapper receives
role="alert"only while the field is invalid. - If the slotted control has no id,
cv-fieldassigns one so the label can target it.
Events
None.
Boundary
cv-field owns only form-field anatomy and ARIA linkage. Validation rules and business state remain in consumers or form controls.