Label
FreeThe visible name for a field, tied to it so a click focuses the control.
pnpm dlx shadcn@latest add https://caliperui.site/r/label.jsonWhen to use #
Use it for
- Every input, select and textarea that does not already carry its own label.
- Pair it with htmlFor and the field's id.
Skip it when
- The control is labelled by its own text, like a button.
- A placeholder is the only name; placeholders disappear as you type.
Installation #
terminal
pnpm dlx shadcn@latest add https://caliperui.site/r/label.json
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage #
This is the code behind the preview above.
example.tsx
import { Label } from "@/components/ui/label" export function RegionLabel() { return ( <div className="grid w-full max-w-xs gap-1.5"> <Label htmlFor="docs-name">Project name</Label> <input id="docs-name" defaultValue="Atlas platform" className="h-[var(--control-height)] rounded-lg border border-border bg-background px-3 text-sm" /> </div> ); }
API reference #
Label
component
No props of its own; it accepts the native props of its root element.
Accessibility #
It is built on native elements, so roles and focus come from the browser.
No custom key handling; Tab and the native activation keys do the work.
Motion #
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.