Label

An accessible label for form controls.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/label.json

Usage

import { Label } from "@/components/ui/label"

Examples

Default

htmlFor has to match the control's id. That pairing is what lets a click on the label focus the field, and what a screen reader reads out with the control.

API Reference

PropTypeDefaultDescription
htmlForstringNoneThe id of the form control this label describes. Clicking the label moves focus to that control.
htmlForstringThe id of the form control this label describes. Clicking the label moves focus to that control.