QdsField

Layout and text container for a single form control. Owns the vertical rhythm of label / control / hint / error and nothing else.

Overview

The qds-field component provides consistent layout for labelled form controls. It manages the visual arrangement of a label, the slotted control, helper text (hint), and an error message. It is convenience, not correctness – every control is fully accessible without it.

qds-field does NOT own the accessibility tree. It renders label text visually, but the slotted control renders its own real <label for> and wires aria-describedby / aria-invalid / aria-required inside its own shadow root. The required marker (*) is aria-hidden="true" because the required state reaches assistive technology through the control’s own aria-required.

When the slotted control declares static qdsFieldConsumer = true, qds-field automatically pushes its label, hint, error-text, required, invalid, disabled, and size attributes down to the control – only for attributes the field actually has. It also listens for qds-validity-change events from the control and mirrors validity into its own invalid and error-text when no explicit error-text was set.

Usage

<qds-field label="Email" hint="We will never share your email" required>
  <qds-text-input></qds-text-input>
</qds-field>

For horizontal layout:

<qds-field label="Username" orientation="horizontal">
  <qds-text-input></qds-text-input>
</qds-field>

API Reference

Attributes

CSS Parts

CSS Custom Properties

Events

None of its own. Control events bubble through qds-field untouched. The field listens for qds-validity-change (bubbles, composed) from the slotted control and mirrors detail.valid into invalid and detail.message into error-text when no explicit error-text is set.

Example

<qds-field
  label="Password"
  hint="At least 8 characters with a number"
  required
  size="md"
>
  <qds-text-input></qds-text-input>
</qds-field>

<qds-field label="Remember me" orientation="horizontal" size="sm">
  <qds-checkbox></qds-checkbox>
</qds-field>

<qds-field
  label="Email"
  hint="We will never share your email"
  error-text="Please enter a valid email address"
  invalid
  reserve-message
>
  <qds-text-input></qds-text-input>
</qds-field>