Label
A chunky label that perks up with its field. Focus the field and the label
hops, turns sakura and draws a wavy underline. Mark it required and a little
star twinkles after the text, then spins while the field has focus. キラッ
Installation
❯ npx shadcn@latest add https://yan.moe/r/label.jsonUsage
import { Label } from "@/components/ui/label"<Label htmlFor="email" required>Email</Label>
<Input id="email" type="email" required />Accessibility
- Built on Radix Label: clicking it focuses the field named by
htmlFor, and double-clicking does not select its text. - The star is decoration and hidden from screen readers. Put
requiredon the field too. - The label follows focus only through
htmlFor. A field wrapped inside the label is not watched. - With
prefers-reduced-motion: reduce, the label changes colour without the hop, and the star stays still.
API
| Prop | Type | Default |
|---|---|---|
requiredShow a star after the text. | boolean | false |
intensitykawaii: hop, sakura ink, wavy underline and a spinning star on focus. subtle: sakura ink only. off: nothing changes. | "kawaii" | "subtle" | "off" | "kawaii" |
htmlForThe id of the field this label names and watches. | string | - |