Label
Accessible Brutalist control naming and click activation via explicit Proto UI instance associations.
Brutalist Label inherits the Base Label protocol with passive Brutalist typography from the Brutalist Design Contract (DM Sans 500, no shadow, no motion), pairing accessible naming and click activation with controls through an explicit reference.
For form fields, use the Field component for automatic
FieldLabel,FieldDescription, andFieldErrorwiring and validation.
Preview
Section titled “Preview”<div
id="label-overview"
class="flex w-full max-w-xl flex-col gap-4"
>
<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root data-pair="updates">
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root data-pair="updates">
Community updates
</wc-brutalist-label-root>
</div>
<div class="flex items-center gap-2">
<wc-brutalist-switch-root data-pair="notify">
<wc-brutalist-switch-thumb></wc-brutalist-switch-thumb>
</wc-brutalist-switch-root>
<wc-brutalist-label-root data-pair="notify">
Enable notifications
</wc-brutalist-label-root>
</div>
<div class="flex flex-col gap-2">
<wc-brutalist-label-root data-pair="project">
Project name
</wc-brutalist-label-root>
<wc-brutalist-input-root
data-pair="project"
default-value="Proto UI"
></wc-brutalist-input-root>
</div>
<div class="flex flex-col gap-2">
<wc-brutalist-label-root data-pair="notes">
Project notes
</wc-brutalist-label-root>
<wc-brutalist-textarea-root
data-pair="notes"
default-value="Share a brief summary of your project."
rows="3"
></wc-brutalist-textarea-root>
</div>
<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root data-pair="passive">
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root data-pair="passive" activation="false">
Naming-only label (selectable text)
</wc-brutalist-label-root>
</div>
</div>
<script type="module">
import { createControlLabelRef } from '@proto.ui/core';
import { setElementAssociations } from '@proto.ui/adapter-web-component';
const refs = new Map();
document
.querySelectorAll('#label-overview [data-pair]')
.forEach((el) => {
const key = el.getAttribute('data-pair');
if (!key) return;
const ref = refs.get(key) ?? createControlLabelRef();
refs.set(key, ref);
setElementAssociations(el, { controlLabel: ref });
});
</script>Installation
Section titled “Installation”
npx @proto.ui/cli@latest add wc brutalist-label
pnpm dlx @proto.ui/cli@latest add wc brutalist-label
Replace wc with react, vue, or vue2 to generate the local facade for your framework, or import labelRoot directly from @proto.ui/prototypes-brutalist/label.
Create one stable reference per pair with createControlLabelRef() from @proto.ui/core and pass it through the adapter association channel:
import { useMemo } from 'react';import { createControlLabelRef } from '@proto.ui/core';import { BrutalistCheckboxIndicator, BrutalistCheckboxRoot, BrutalistLabelRoot,} from '../proto-ui/components/react';
export function TermsCheckbox() { const termsRef = useMemo(() => createControlLabelRef(), []);
return ( <div className="flex items-center gap-2"> <BrutalistCheckboxRoot instanceAssociations={{ controlLabel: termsRef }}> <BrutalistCheckboxIndicator /> </BrutalistCheckboxRoot> <BrutalistLabelRoot instanceAssociations={{ controlLabel: termsRef }}> Accept terms and conditions </BrutalistLabelRoot> </div> );}In Web Components, bind both elements with setElementAssociations() from @proto.ui/adapter-web-component:
import { createControlLabelRef } from '@proto.ui/core';import { setElementAssociations } from '@proto.ui/adapter-web-component';
const termsRef = createControlLabelRef();setElementAssociations(checkboxEl, { controlLabel: termsRef });setElementAssociations(labelEl, { controlLabel: termsRef });Naming, activation, and accessibility
Section titled “Naming, activation, and accessibility”naming(defaulttrue): Links the renderedLabelas the target control’s accessible name. If the target already sets a non-emptyariaLabelorlabelledBy, setnaming={false}for activation-only pairing.activation(defaulttrue): Eligible clicks invoke the paired control’s default operation (togglingCheckbox/Switch, selecting aRadio Group Item, or focusingInput/Textarea). Setactivation={false}for a naming-only label.selection(default'policy'): Actionable labels suppress accidental text selection by default; setselection="text"to keep copyable text.- Interaction boundaries:
Labeladds no extraTabstop, ignores nested interactive descendants, modified clicks, and drags, and remains a flat passive label without shadow or translation.
Examples
Section titled “Examples”<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root id="terms-checkbox">
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root id="terms-label">
Accept terms and conditions
</wc-brutalist-label-root>
</div>
<script type="module">
import { createControlLabelRef } from '@proto.ui/core';
import { setElementAssociations } from '@proto.ui/adapter-web-component';
const termsRef = createControlLabelRef();
const checkbox = document.querySelector('#terms-checkbox');
const label = document.querySelector('#terms-label');
if (
checkbox instanceof HTMLElement &&
label instanceof HTMLElement
) {
setElementAssociations(checkbox, { controlLabel: termsRef });
setElementAssociations(label, { controlLabel: termsRef });
}
</script>Label in Field
Section titled “Label in Field”<div class="flex w-full max-w-md flex-col gap-5">
<wc-brutalist-field-root required validation-mode="onBlur">
<wc-brutalist-field-label>
Email address
</wc-brutalist-field-label>
<wc-brutalist-field-control
placeholder="name@example.com"
></wc-brutalist-field-control>
<wc-brutalist-field-description>
We will use this address for account security notices.
</wc-brutalist-field-description>
<wc-brutalist-field-error></wc-brutalist-field-error>
</wc-brutalist-field-root>
<wc-brutalist-field-root>
<wc-brutalist-field-label>
Display name
</wc-brutalist-field-label>
<wc-brutalist-field-control
default-value="Alex Chen"
></wc-brutalist-field-control>
<wc-brutalist-field-description>
Shown alongside your comments and reviews.
</wc-brutalist-field-description>
</wc-brutalist-field-root>
<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root
id="field-updates-checkbox"
default-checked
>
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root id="field-updates-label">
Send me product release notes
</wc-brutalist-label-root>
</div>
</div>
<script type="module">
import { createControlLabelRef } from '@proto.ui/core';
import { setElementAssociations } from '@proto.ui/adapter-web-component';
const updatesRef = createControlLabelRef();
const checkbox = document.querySelector(
'#field-updates-checkbox'
);
const label = document.querySelector('#field-updates-label');
if (
checkbox instanceof HTMLElement &&
label instanceof HTMLElement
) {
setElementAssociations(checkbox, { controlLabel: updatesRef });
setElementAssociations(label, { controlLabel: updatesRef });
}
</script>Naming, Activation, and Selection
Section titled “Naming, Activation, and Selection”<div id="label-modes" class="flex w-full max-w-md flex-col gap-4">
<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root data-pair="copyable">
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root data-pair="copyable" selection="text">
Weekly digest (clickable and selectable)
</wc-brutalist-label-root>
</div>
<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root data-pair="naming-only">
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root
data-pair="naming-only"
activation="false"
>
Release policy notice (naming only)
</wc-brutalist-label-root>
</div>
<div class="flex flex-col gap-2">
<wc-brutalist-label-root
data-pair="activation-only"
naming="false"
>
Quick filter (activation only)
</wc-brutalist-label-root>
<wc-brutalist-input-root
data-pair="activation-only"
aria-label="Filter workspace items"
placeholder="Filter workspace items..."
></wc-brutalist-input-root>
</div>
<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root data-pair="unavailable" disabled>
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root data-pair="unavailable">
Unavailable option
</wc-brutalist-label-root>
</div>
</div>
<script type="module">
import { createControlLabelRef } from '@proto.ui/core';
import { setElementAssociations } from '@proto.ui/adapter-web-component';
const refs = new Map();
document
.querySelectorAll('#label-modes [data-pair]')
.forEach((el) => {
const key = el.getAttribute('data-pair');
if (!key) return;
const ref = refs.get(key) ?? createControlLabelRef();
refs.set(key, ref);
setElementAssociations(el, { controlLabel: ref });
});
</script><div
id="label-rtl"
dir="rtl"
class="flex w-full max-w-sm flex-col gap-4"
>
<div class="flex items-center gap-2">
<wc-brutalist-checkbox-root data-pair="rtl-terms">
<wc-brutalist-checkbox-indicator></wc-brutalist-checkbox-indicator>
</wc-brutalist-checkbox-root>
<wc-brutalist-label-root data-pair="rtl-terms">
قبول الشروط والأحكام
</wc-brutalist-label-root>
</div>
<div class="flex flex-col gap-2">
<wc-brutalist-label-root data-pair="rtl-email">
البريد الإلكتروني
</wc-brutalist-label-root>
<wc-brutalist-input-root
data-pair="rtl-email"
placeholder="name@example.com"
></wc-brutalist-input-root>
</div>
</div>
<script type="module">
import { createControlLabelRef } from '@proto.ui/core';
import { setElementAssociations } from '@proto.ui/adapter-web-component';
const refs = new Map();
document
.querySelectorAll('#label-rtl [data-pair]')
.forEach((el) => {
const key = el.getAttribute('data-pair');
if (!key) return;
const ref = refs.get(key) ?? createControlLabelRef();
refs.set(key, ref);
setElementAssociations(el, { controlLabel: ref });
});
</script>| Prop | Type | Default | Description |
|---|---|---|---|
naming | boolean | true | Associates this rendered label as the paired target accessible name |
activation | boolean | true | Requests the paired target default action when the label is clicked |
selection | 'policy' 'auto' 'text' 'none' | 'policy' | Text-selection policy; default suppresses selection only while actionable |
Association helpers
Section titled “Association helpers”createControlLabelRef(): Imported from@proto.ui/coreto create a stable one-to-one opaque reference.instanceAssociations: Adapter prop accepting{ controlLabel: ref }in React, Vue, and Vue 2.setElementAssociations(element, { controlLabel: ref }): Imported from@proto.ui/adapter-web-componentfor Web Components.