Label
A content-layer Liquid Glass label pairing accessible naming and click activation via explicit control associations.
Liquid Glass Label inherits the Base Label protocol as content-layer typography paired with translucent Liquid Glass controls, separating accessible naming (naming) from click activation (activation) with primary and secondary ink hierarchy.
For form fields, use the Field component for automatic
FieldLabel,FieldDescription, andFieldErrorassociations and validation.
Preview
Section titled “Preview”The preview pairs Liquid Glass Label with Liquid Glass Checkbox, Switch, Radio Group Item, Input, and Textarea controls over a tinted backdrop, covering standard, read-only, disabled, controlled, and naming-only cases:
<div
class="rounded-2xl bg-gradient-to-br from-sky-500/20 via-indigo-500/15 to-fuchsia-500/20 p-6"
>
<div
id="label-overview"
class="flex w-full max-w-xl flex-col gap-4"
>
<div class="flex items-center gap-2">
<wc-liquid-glass-checkbox-root data-pair="updates">
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root data-pair="updates">
Community updates
</wc-liquid-glass-label-root>
</div>
<div class="flex items-center gap-2">
<wc-liquid-glass-switch-root data-pair="notify">
<wc-liquid-glass-switch-thumb></wc-liquid-glass-switch-thumb>
</wc-liquid-glass-switch-root>
<wc-liquid-glass-label-root data-pair="notify">
Enable notifications
</wc-liquid-glass-label-root>
</div>
<div class="flex flex-col gap-2">
<wc-liquid-glass-label-root data-pair="project">
Project name
</wc-liquid-glass-label-root>
<wc-liquid-glass-input-root
data-pair="project"
default-value="Proto UI"
></wc-liquid-glass-input-root>
</div>
<div class="flex flex-col gap-2">
<wc-liquid-glass-label-root data-pair="notes">
Project notes
</wc-liquid-glass-label-root>
<wc-liquid-glass-textarea-root
data-pair="notes"
default-value="Share a brief summary of your project."
rows="3"
></wc-liquid-glass-textarea-root>
</div>
<div class="flex items-center gap-2">
<wc-liquid-glass-checkbox-root data-pair="passive">
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root
data-pair="passive"
activation="false"
>
Naming-only label (selectable text)
</wc-liquid-glass-label-root>
</div>
</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”Currently available from workspace source. Import directly from the workspace package:
import { labelRoot } from '@proto.ui/prototypes-liquid-glass/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 { LiquidGlassCheckboxIndicator, LiquidGlassCheckboxRoot, LiquidGlassLabelRoot,} from '../proto-ui/components/react';
export function TermsCheckbox() { const termsRef = useMemo(() => createControlLabelRef(), []);
return ( <div className="flex items-center gap-2"> <LiquidGlassCheckboxRoot instanceAssociations={{ controlLabel: termsRef }}> <LiquidGlassCheckboxIndicator /> </LiquidGlassCheckboxRoot> <LiquidGlassLabelRoot instanceAssociations={{ controlLabel: termsRef }}> Accept terms and conditions </LiquidGlassLabelRoot> </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 });Content-layer material and accessibility
Section titled “Content-layer material and accessibility”- Never stack glass on glass: Following Apple Liquid Glass HIG, plain control labels live in the content layer and never render a Liquid Glass plate next to translucent controls.
- Foreground hierarchy (
tone): Defaults totone="primary"(text-foreground) withtone="secondary"(text-muted-foreground) for quieter labels, maintaining legible opaque ink under Reduce Transparency, Increase Contrast, and Forced Colors. - Independent naming, activation, and selection: Configure
naming(defaulttrue),activation(defaulttrue), andselection(default'policy') independently.Labeladds no extraTabstop and ignores nested links/buttons, modified clicks, and drags.
Examples
Section titled “Examples”<div
class="rounded-2xl bg-gradient-to-br from-sky-500/20 via-indigo-500/15 to-fuchsia-500/20 p-6"
>
<div class="flex items-center gap-2">
<wc-liquid-glass-checkbox-root id="terms-checkbox">
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root id="terms-label">
Accept terms and conditions
</wc-liquid-glass-label-root>
</div>
</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="rounded-2xl bg-gradient-to-br from-sky-500/20 via-indigo-500/15 to-fuchsia-500/20 p-6"
>
<div class="flex w-full max-w-md flex-col gap-5">
<wc-liquid-glass-field-root required validation-mode="onBlur">
<wc-liquid-glass-field-label>
Email address
</wc-liquid-glass-field-label>
<wc-liquid-glass-field-control
placeholder="name@example.com"
></wc-liquid-glass-field-control>
<wc-liquid-glass-field-description>
We will use this address for account security notices.
</wc-liquid-glass-field-description>
<wc-liquid-glass-field-error></wc-liquid-glass-field-error>
</wc-liquid-glass-field-root>
<wc-liquid-glass-field-root>
<wc-liquid-glass-field-label>
Display name
</wc-liquid-glass-field-label>
<wc-liquid-glass-field-control
default-value="Alex Chen"
></wc-liquid-glass-field-control>
<wc-liquid-glass-field-description>
Shown alongside your comments and reviews.
</wc-liquid-glass-field-description>
</wc-liquid-glass-field-root>
<div class="flex items-center gap-2">
<wc-liquid-glass-checkbox-root
id="field-updates-checkbox"
default-checked
>
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root id="field-updates-label">
Send me product release notes
</wc-liquid-glass-label-root>
</div>
</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, Selection, and Tone
Section titled “Naming, Activation, Selection, and Tone”<div
class="rounded-2xl bg-gradient-to-br from-sky-500/20 via-indigo-500/15 to-fuchsia-500/20 p-6"
>
<div id="label-modes" class="flex w-full max-w-md flex-col gap-4">
<div class="flex items-center gap-2">
<wc-liquid-glass-checkbox-root data-pair="copyable">
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root
data-pair="copyable"
selection="text"
>
Weekly digest (clickable and selectable)
</wc-liquid-glass-label-root>
</div>
<div class="flex items-center gap-2">
<wc-liquid-glass-checkbox-root data-pair="naming-only">
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root
data-pair="naming-only"
activation="false"
>
Release policy notice (naming only)
</wc-liquid-glass-label-root>
</div>
<div class="flex flex-col gap-2">
<wc-liquid-glass-label-root
tone="secondary"
data-pair="activation-only"
naming="false"
>
Quick filter (activation only)
</wc-liquid-glass-label-root>
<wc-liquid-glass-input-root
data-pair="activation-only"
aria-label="Filter workspace items"
placeholder="Filter workspace items..."
></wc-liquid-glass-input-root>
</div>
<div class="flex items-center gap-2">
<wc-liquid-glass-checkbox-root
data-pair="unavailable"
disabled
>
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root data-pair="unavailable">
Unavailable option
</wc-liquid-glass-label-root>
</div>
</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
class="rounded-2xl bg-gradient-to-br from-sky-500/20 via-indigo-500/15 to-fuchsia-500/20 p-6"
>
<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-liquid-glass-checkbox-root data-pair="rtl-terms">
<wc-liquid-glass-checkbox-indicator></wc-liquid-glass-checkbox-indicator>
</wc-liquid-glass-checkbox-root>
<wc-liquid-glass-label-root data-pair="rtl-terms">
قبول الشروط والأحكام
</wc-liquid-glass-label-root>
</div>
<div class="flex flex-col gap-2">
<wc-liquid-glass-label-root data-pair="rtl-email">
البريد الإلكتروني
</wc-liquid-glass-label-root>
<wc-liquid-glass-input-root
data-pair="rtl-email"
placeholder="name@example.com"
></wc-liquid-glass-input-root>
</div>
</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 | Provides the accessible name for the paired target |
activation | boolean | true | Forwards eligible clicks to the paired target default action |
selection | 'policy' 'auto' 'text' 'none' | 'policy' | Text-selection policy; default suppresses selection only while actionable |
tone | 'primary' 'secondary' | 'primary' | Content-layer foreground ink hierarchy over translucent surfaces |
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.