Primitives
Label
Uppercase technical form label.
● LIVE
"use client";import { Input } from "@/registry/okibi/ui/input";import { Label } from "@/registry/okibi/ui/label";export default function LabelDemo() { return ( <div className="grid w-full max-w-xs gap-2"> <Label htmlFor="label-demo-sector">Sector ID</Label> <Input id="label-demo-sector" placeholder="Enter sector" /> </div> );}npx shadcn@latest add https://okibi.cndr.dev/r/label.jsonInstallation
Install the theme first, then add the component:
npx shadcn@latest add https://okibi.cndr.dev/r/label.jsonInstall the required dependencies:
npm install @radix-ui/react-labelCopy the source from the Code tab above into components/ui/label.tsx. It uses the cn helper and the okibi theme tokens — install the theme first if you haven't.
Usage
import { Label } from "@/components/ui/label"
<Label htmlFor="callsign">Callsign</Label>Accessibility
- Wraps Radix
Label, so associating it (htmlFor/idor nesting the control) names the field and makes the label a click target. - Clicking the label moves focus to and toggles its control — a larger, easier hit area.
- It dims to 60% opacity and goes non-interactive when its
peer-disabled control or adata-disabledgroup is disabled. text-muted-foregroundis body-weight secondary text that clears AA contrast in both themes.- No built-in required marker — append a trailing
aria-hiddenglyph and setaria-requiredon the field.
Guidelines
Do
- Bind every label to its control with
htmlFormatching the fieldid, or nest the control inside. - Lean on the click-to-focus behavior to enlarge the touch target for small controls.
- Mark required fields with a trailing
aria-hiddencue plusaria-requiredon the input. - Keep label text short and uppercase-stable — it sets the field's accessible name.
Don't
- Don't leave a label unbound — an orphan label names nothing.
- Don't substitute a placeholder for a label.
- Don't hand-dim the label for disabled state — it already follows its
peer/group. - Don't pack interactive controls inside the label beyond the one it names.