Component guideEditable source

Label

A visible native label associated with one form control.

Original component docs
On this page4 sectionsBack to top

Use Label to name an input, checkbox, switch, or select trigger. It renders a native label and does not create a field, validation state, or layout by itself.

Live preview
Loading preview...

#Installation

Complete the base setup, then install or copy this source:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/label.json

The preview and Usage example additionally use Input. Install it before copying either example:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/input.json

#Usage

import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";

export default function DisplayName() {
  return (
    <div className="grid max-w-sm gap-2">
      <Label htmlFor="display-name">Display name</Label>
      <Input id="display-name" name="displayName" autoComplete="nickname" />
    </div>
  );
}

#API reference

PropPurposeDefault
htmlForAssociated control IDUnset
childrenVisible field name—
classNameTypography and layoutTheme styling
Native label propsStandard HTML attributesForwarded

#Accessibility

Match htmlFor to a unique control ID. Keep the label visible while the user types. Use a fieldset and legend to name a set of related controls. Do not put unrelated links or buttons inside a label, and do not substitute placeholder text for an actual field name.