Label
Pairs a label with a target control via an explicit reference to provide independent accessible naming and pointer activation.
Base Label binds one-to-one with a target control through an explicit reference—no manual DOM IDs required—giving you independent control over accessible naming and pointer activation.
Preview
Section titled “Preview”The preview pairs Base Label with Checkbox, Switch, Radio Group Item, Input, and Textarea, covering actionable labels, naming-only labels (activation={false}), read-only focus, and disabled controls.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. Import from @proto.ui/prototypes-base/label or generate wrappers in the workspace with the base-label CLI target (wc, react, vue, vue2).
Independent naming and activation
Section titled “Independent naming and activation”naming(defaulttrue): associates the target control’s accessible name with the rendered Label (if the target already provides a non-emptyariaLabel/labelledBy, that explicit name takes precedence).activation(defaulttrue): clicking a paired Label triggers the target’s native action—toggling Checkbox / Switch, selecting a Radio Group Item, or focusing Input / Textarea (including read-only inputs). Setactivation={false}for passive naming only.selection(default'policy'): prevents accidental text selection on actionable labels; setselection="text"if the label text should remain copyable.- Label adds no
buttonrole or extra Tab stop, and ignores nested interactive elements, modified clicks, drags, and canceled clicks.
Pairing a label and control
Section titled “Pairing a label and control”Create a stable reference with createControlLabelRef() from @proto.ui/core for each label–control pair (each reference pairs one live Label with one live target):
- React / Vue / Vue 2: pass
instanceAssociations: { controlLabel: ref }to both components (handled at the adapter boundary outside ordinary props). - Web Components: call
setElementAssociations(el, { controlLabel: ref })from@proto.ui/adapter-web-componenton both the target and the Label.
Supported target controls: Checkbox, Switch, Radio Group Item, Input, Textarea, Button, Toggle, and Toggle Group Item.
Root Props
Section titled “Root Props”| Prop | Type | Default |
|---|---|---|
naming | boolean | true |
activation | boolean | true |
selection | 'policy' 'auto' 'text' 'none' | policy |