Create

Form

Field

Copy page View as Markdown Open in ChatGPT Open in Claude

Combine labels, controls, and help text to compose accessible form fields and grouped inputs.

Usage#

app.component.ts
import { WDS_FIELD } from '@wds/angular/field';

Examples#

Input#

wds-field links wds-field-label and wds-field-description with the control, also across the shadow DOM of wds-* controls.

Username Choose a unique username for your account. Password Must be at least 8 characters long.

Textarea#

Feedback Share your thoughts about our service.

Fieldset#

wds-field-set is a group named by its wds-field-legend; a description right after the legend describes the group.

Address Information We need your address to deliver your order. Street Address
City Postal Code

Checkbox#

orientation="horizontal" puts the control next to the label. wds-field-content stacks a label and a description.

Show these items on the desktop Select the items you want to show on the desktop. Hard disks External disks CDs, DVDs, and iPods Sync Desktop & Documents folders Your Desktop & Documents folders are being synced with iCloud Drive. You can access them from other devices.

Radio#

Subscription Plan Yearly and lifetime plans offer significant savings. Monthly ($9.99/month) Yearly ($99.99/year) Lifetime ($299.99)

Switch#

Multi-factor authentication Enable multi-factor authentication. If you do not have a two-factor device, you can use a one-time code sent to your email.

Choice card#

Compute Environment Select the compute environment for your cluster. Kubernetes Run GPU workloads on a K8s configured cluster. Virtual Machine Access a VM configured cluster to run GPU workloads.

Field group#

wds-field-group stacks fields and sets; wds-field-separator divides them.

Responses Get notified when a response to a long request, like research, is ready. Push notifications Tasks Get notified when tasks you've created have updates. Manage tasks Push notifications Email notifications

Responsive#

orientation="responsive" is vertical in a narrow wds-field-group and horizontal once the group is at least 28rem wide (a container query).

Name Provide your full name for identification. or Nickname Shown instead of your name.

Validation#

invalid on wds-field colors the label and sets invalid on the control. wds-field-error is linked to the control as a description; in Angular it takes errors() from Signal Forms, in HTML and React the validationMessage of the control.

UsernameAt least 3 characters.

API References#

wds-field#

A form field: label, control, description and error in one layout. It links the label, description and error with the control (also across the shadow DOM of wds-* controls).

Attributes

AttributeTypeDefaultDescription
orientationWdsFieldOrientation'vertical'Layout: vertical, horizontal, or horizontal once the wds-field-group is at least 28rem wide.
invalidbooleanfalseError state: red label and invalid on the control.
disabledbooleanfalseDims the label (set disabled on the control itself).

Slots

SlotDescription
(default)wds-field-label, the control, wds-field-content, wds-field-description, wds-field-error.

CSS custom properties

PropertyDescription
--wds-field-gapGap between the parts (default 12px).

wds-field-label#

Field label. A click moves focus to the control (and toggles a checkbox or a switch). The control is the element with the ID from for, or the first control in the same wds-field.

Attributes

AttributeTypeDefaultDescription
for.htmlForstring''ID of the control (like for on <label>).

Slots

SlotDescription
(default)Label text.

wds-field-description#

Helper text of a field. wds-field links it to the control as its description.

Slots

SlotDescription
(default)Text (may contain links).

CSS parts (::part)

PartDescription
baseThe text.

wds-field-error#

Error message of a field: one message, a list (errors, e.g. from Signal Forms) or slotted content. Hidden when there are no errors. wds-field links it to the control as a description.

Properties

PropertyDescription
errorsReadonlyArray<WdsFieldErrorItem>Errors to show (repeated messages are skipped).

Slots

SlotDescription
(default)Custom message (instead of errors).

wds-field-content#

The text part of a field (label or title and description) in a horizontal layout.

Slots

SlotDescription
(default)wds-field-label or wds-field-title, and wds-field-description.

wds-field-title#

A non-clickable field title (when the control itself is the label).

Slots

SlotDescription
(default)Text.

wds-field-set#

A group of fields with a legend (like <fieldset>: role group named by the legend). A wds-field-description right after the legend describes the group (aria-describedby).

Slots

SlotDescription
(default)wds-field-legend, wds-field-description, fields, groups.

wds-field-legend#

Legend of wds-field-set. The label variant is for groups of inline controls (checkbox, radio).

Attributes

AttributeTypeDefaultDescription
variantWdsFieldLegendVariant'legend'legend is a section heading; label has the size of a field label.

Slots

SlotDescription
(default)Text.

CSS parts (::part)

PartDescription
baseThe text.

wds-field-group#

A group of fields with vertical spacing. The container query context for orientation="responsive". With the data-checkbox-group attribute the spacing is tighter (a list of checkboxes).

Slots

SlotDescription
(default)Fields, wds-field-set, wds-field-separator, nested groups.

wds-field-separator#

A horizontal line between sections, optionally with text in the middle (e.g. "or").

Slots

SlotDescription
(default)Text on the line.

CSS parts (::part)

PartDescription
baseThe line with the text.

Accessibility#

Screen reader#

wds-field-label names the control of its wds-field: a native control through aria-labelledby, a wds-* control through aria-label forwarded into its shadow DOM. for points the label to a control with that ID instead.

wds-field-description and wds-field-error describe the control (aria-describedby or aria-description). wds-field-error has role="alert", so a new message is announced.

wds-field-set has role="group" named by wds-field-legend and described by the wds-field-description right after the legend. wds-field-separator has role="separator".

invalid on wds-field sets invalid (and aria-invalid) on the control. disabled only dims the label: disable the control itself.

Keyboard support#

The field has no keyboard interaction of its own. A click on wds-field-label moves focus to the control and toggles a checkbox or a switch.

Footer