Label
Independent control naming and activation through an explicit Proto UI association.
Ordinary demos on this page explicitly use Shadcn Rhea, with matching examples. This does not change public compatibility defaults or imply complete browser, native-host or visual acceptance. Neutral Surface/Text atoms retain their own public semantics; the consumer composition supplies the family presentation theme.
This Label remains draft. The shadcn projection shares the independent Base Label protocol. Proto UI is an independent project; design references inform a deliberate projection rather than becoming project authority.
The demo pairs Shadcn Label with Shadcn Checkbox, Switch, Radio Group Item, Input and Textarea, including their Indicator and Thumb parts. Actionable labels use the public defaults; the naming-only example sets activation={false}. “On/Off” reads each target’s exposed state. “Requests” counts the controlled Checkbox’s ordinary checkedChange proposals while its application owner keeps checked={false}. Label does not forward DOM clicks or own another control value. Input and Textarea remain native text editors; their read-only examples can receive focus from the Label while retaining their text. The disabled choice keeps its name and rejects activation and focus.
Two independent effects
Section titled “Two independent effects”namingdefaults totrue. The target refers to the actual rendered Label using an accessibility relationship. Do not add a hidden copy of the same name.activationdefaults totrue. Once explicitly paired, an eligible pointer or trusted non-pointer action requests the target’s existing operation. Setactivation={false}for a naming-only label; setting it back totrueor removing the Prop restores activation. Checkbox and Switch keep their controlled/disabled behavior; Radio Item delegates to its Group; Input and Textarea request focus without editing or moving the selection themselves.- Label adds no button role, Tab stop or separate keyboard action. Keyboard input remains on the control. Nested links/buttons, modified pointer input, pointercancel and drag gestures are not forwarded.
- Naming-only labels and long descriptions remain copyable. A short actionable Label declares its own selection affordance. The controlled example deliberately keeps its value off after proposals; this is the application’s ownership decision.
Activation stays in the originating click turn so editor focus is not delayed to a timer. Cancellation already observed by the host click listener is respected; a later listener cannot undo a committed operation. Cancelling pointerup alone is not click cancellation. This is a bounded custom Label protocol, not a claim to reproduce every native HTML label default-action detail. Actual assistive-technology behavior remains to be verified.
Upgrade note: previously paired labels that omitted activation now activate by default. Declare activation={false} to retain passive naming. With selection='policy', actionable labels suppress accidental text selection; use selection='text' when an actionable label must also be copyable. Unpaired labels never search for a parent or nearby control.
Explicit association, outside JSON Props
Section titled “Explicit association, outside JSON Props”Create one stable createControlLabelRef() from @proto.ui/core for each pair. Keep it for the row’s logical lifetime. In React, Vue and Vue 2, pass instanceAssociations: { controlLabel: ref } as the Adapter-owned input to both components. It is removed before raw/resolved Proto Props, even with a custom getProps projection.
In WC, call setElementAssociations(target, { controlLabel: ref }) and the same setter for the Label from @proto.ui/adapter-web-component. Use normal Props only for naming, activation and the control’s values. Attribute strings, JSON-cloned references and unknown association keys are rejected. DemoSpec expresses associations: { controlLabel: 'row-key' }; each render instance materializes an independent public reference for that key.
Exactly one live Label and one live target are supported per reference. Missing/duplicate/stale endpoints fail closed. Explicitly paired siblings are allowed; Web views must also share Document and tree root. A reference does not authorize cross-document or cross-shadow-root matching, DOM lookup or arbitrary commands. A nonempty explicit ariaLabel/labelledBy keeps naming ownership and diagnoses a conflicting Label naming request; use an explicit activation-only Label when appropriate.
Consumption and limits
Section titled “Consumption and limits”Import from @proto.ui/prototypes-shadcn/label. CLI component shadcn-label generates WC, React, Vue and Vue 2 facades.
The declared association target set is Checkbox, Switch, Radio Group Item, Input, Textarea, Button, Toggle and Toggle Group Item. Icon-only commands can use an independent Label through the same association. Button keeps its click signal; Toggle keeps activeChange; Toggle Group Item delegates selection to its Group. Each target declares its own participation and is exercised through the Prototype packages and their Adapters. Among these targets, the private Compiler admits Button, Toggle and the Label to standalone Web source and keeps an explicit unsupported diagnostic for the others, including Toggle Group Root and Item. Form submission, validation, multiple-label ordering and native-platform/assistive-technology certification are not provided by this association. Browser acceptance is tracked separately from source and synthetic host tests.
Install
Section titled “Install”
npx @proto.ui/cli@latest add wc shadcn-label
Replace wc with react, vue or vue2 to generate the facade for that host.
| Prop | Type | Default |
|---|---|---|
naming | boolean | true |
activation | boolean | true |
selection | 'policy' 'auto' 'text' 'none' | policy |
These props belong to Root. policy suppresses accidental selection only while the label is actionable.