Label
A form label that dims when its control is disabled.
Preview
Invite a teammate
Ines will get an email to join.
Install
Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.
npx shadcn@latest add https://pebbleui.com/r/label.jsonProps
| Prop | Type | Default | Description |
|---|---|---|---|
| htmlFor | string | — | id of the labelled control |
| required | boolean | false | Adds a decorative asterisk; set required on the control itself too |
| hint | ReactNode | — | Small text at the end of the label, such as "Optional" or a count |
| className | string | — | Merged over defaults |
Build notes
Radix Label renders a `<label>` and stops a double-click from selecting the
label text. Disabled dimming is pure CSS: `peer-disabled:` needs the control
to be an earlier sibling carrying the `peer` class (Checkbox, Radio Group
items and Switch already set `peer`), and
`group-data-[disabled=true]:` reads a `group` ancestor's `data-disabled`.
**Pebble (2026-11-03).** Kept the 14 px medium label and its peer/group disabled dimming; tightened tracking slightly. Added optional `required` (a muted, `aria-hidden` asterisk; the control carries `required` itself so assistive tech hears it once) and `hint` (12 px muted qualifier at the row end via `ms-auto`). A whitespace text node before the hint keeps the accessible name spaced ("Job title Optional"); flex layout drops it visually.
<!-- PEBBLE-LICENSE -->View source
registry/input/label/label.tsx
"use client";
/* PEBBLE-LICENSE
Built by Pebble. Component: label.
First-party license: MIT
The following first-party terms apply only to original Pebble material.
MIT License
Copyright (c) 2026 Praxys Solutions LLC (Pebble)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THIRD-PARTY NOTICES
These notices apply to identified upstream portions; Pebble terms do not replace or narrow their rights.
Upstream: https://raw.githubusercontent.com/shadcn-ui/ui/main/LICENSE.md
MIT License
Copyright (c) 2023 shadcn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */
import * as React from "react";
import { Label as LabelPrimitive } from "radix-ui";
import { cn } from "@/lib/utils";
export type LabelProps = React.ComponentProps<typeof LabelPrimitive.Root> & {
/**
* Adds a muted asterisk after the text. It is hidden from screen readers:
* mark the control itself `required` so assistive tech hears it once.
*/
required?: boolean;
/**
* A short muted qualifier pushed to the end of the row, such as
* "Optional" or "Max 2 MB". It is part of the label, so the control's
* accessible name includes it; keep it to a few words.
*/
hint?: React.ReactNode;
};
export function Label({ className, required = false, hint, children, ...props }: LabelProps) {
return (
<LabelPrimitive.Root
data-slot="label"
className={cn(
"flex items-center gap-2 text-sm leading-none font-medium tracking-[-0.005em] text-foreground select-none",
// Dim when the preceding peer control is disabled, or when an
// ancestor group is marked data-disabled="true".
"peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
"group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",
className,
)}
{...props}
>
{children}
{required && (
<span
data-slot="label-required"
aria-hidden
className="-ms-1.5 font-normal text-muted-foreground"
>
*
</span>
)}
{/* The space keeps the accessible name "Title Optional", not "TitleOptional"; flex drops it visually. */}
{hint != null && " "}
{hint != null && (
<span
data-slot="label-hint"
className="ms-auto text-xs font-normal text-muted-foreground tabular-nums"
>
{hint}
</span>
)}
</LabelPrimitive.Root>
);
}
