Label
Field 之外的控件名称,沿用 Field 标签的斜体字。
安装
# once per project: where @zzzui items come frompnpm dlx shadcn@latest registry add @zzzui=https://zzzui.catforest.dev/r/{name}.jsonpnpm dlx shadcn@latest add @zzzui/label示例
复选框与开关旁的标签
import { Checkbox } from "@/components/zero/checkbox";import { Label } from "@/components/zero/label";import { Switch } from "@/components/zero/switch";export default function LabelBasic() { return ( <div className="grid gap-4"> <Label> <Checkbox defaultChecked /> Rush jobs only </Label> <Label> <Switch /> Radio on </Label> <Label> <Checkbox disabled /> Locked jobs (none today) </Label> </div> );}行为
将控件包在其中,或通过 htmlFor 指向控件。内部的控件禁用时,标签随之变暗。在 Field 中请改用 FieldLabel,它还会响应聚焦与校验错误。