navius

Label

Renders an accessible label associated with a control.

Click the label above to focus the field.

Features

  • Associates with a control via For so clicking the label focuses it.
  • Prevents text selection when the label is double-clicked.
  • Forwards any extra attributes onto the underlying <label>.

Installation

Install the brain, or copy just this primitive in with the CLI.

Anatomy

Import the part and assemble it.

API Reference

Contains the content of the label. Renders a label element.

Prop Type Default
For string? -
ChildContent RenderFragment? -
Data attribute Values
[data-navius-label] Present on the root element

Accessibility

Follows the native label element semantics. Set For to the id of the control so assistive technology announces the label as the control's accessible name.

The label has no keyboard interactions of its own. Activating it with the pointer moves focus to, and where applicable activates, the associated control.