Skip to content

Field ​

Combine labels, controls, and help text to compose accessible form fields. Responsive fields put the label beside the control when the field itself is at least 480vp wide — no breakpoints.

Usage ​

Approximate web preview — the HarmonyOS rendering is the reference.

Responsive ​

Resize the window (or narrow the demo) — the field measures its own width.

Approximate web preview — the HarmonyOS rendering is the reference.

Horizontal ​

Checkbox, switch and label in a row.

Approximate web preview — the HarmonyOS rendering is the reference.

API ​

Extracted from the @Param / @Event / @BuilderParam declarations in the library sources.

SField ​

shadcn-vue Field: a label, control, description and error laid out together.

  • vertical: stacked (flex-col gap-3).
  • horizontal: in a row (flex-row items-center gap-3); SFieldLabel / SFieldContent / text controls share the free width.
  • responsive (default): measures its own width — beside each other from 480vp, stacked below (the container-query equivalent of shadcn's @md/field-group:flex-row).
PropTypeDefaultDescription
orientationFieldOrientation
FieldOrientation = 'vertical' | 'horizontal' | 'responsive'
'responsive'
invalidbooleanfalseError look: SFieldLabel turns destructive, SInput / STextarea show the invalid border.
disabledbooleanfalseDisabled look for the label (opacity 50%).

Slots: children (trailing closure)

SFieldLabel ​

Label of a field. Turns destructive when the field is invalid; fills the free width in horizontal fields.

PropTypeDefaultDescription
textResourceStr''
requiredbooleanfalse

SFieldContent ​

Groups a label and description next to a control (flex flex-1 flex-col gap-1.5).

Slots: children (trailing closure)

SFieldDescription ​

Helper text (text-muted-foreground text-sm).

PropTypeDefaultDescription
textResourceStr''

SFieldError ​

Validation message (text-destructive text-sm). Renders nothing while text is empty.

PropTypeDefaultDescription
textstring''

SFieldGroup ​

Stack of fields (flex w-full flex-col gap-7).

Slots: children (trailing closure)

SFieldSet ​

Semantic group of fields with an optional SFieldLegend (flex flex-col gap-6).

Slots: children (trailing closure)

SFieldLegend ​

Title of an SFieldSet: legend = text-base font-medium, label = text-sm font-medium.

PropTypeDefaultDescription
textResourceStr''
variantFieldLegendVariant
FieldLegendVariant = 'legend' | 'label'
'legend'

SFieldSeparator ​

Horizontal rule between field groups.

No props.

MIT Licensed