Skip to content

    Browse components

    Label

    Form label with a required asterisk, optional tag and hint text that lights up while its control has focus.

    Open
    Customize

    Installation

    npx shadcn@latest add @glint-ui/label

    First time using @glint-ui? Add the registry to components.json once, or install by URL: npx shadcn@latest add https://glintui.vercel.app/r/label.json

    Usage

    import { Label } from "@/components/ui/label";
    
    <Label htmlFor="email" required hint="We never share it.">Email</Label>
    <input id="email" required aria-describedby="email-hint" />

    Props

    PropTypeDefaultDescription
    childrenstring"Work email"Label text.
    requiredbooleanfalseShow the required marker (also set required on the input).
    optionalbooleanfalseShow an "Optional" tag instead.
    hintstring"We only use this to send your invoice."Helper text, id is `${htmlFor}-hint`.
    disabledbooleanfalseDimmed, not-allowed cursor.
    htmlForReactNode—Id of the control. Also used to light up on focus and to build the hint id.
    classNamestring—Extra classes for the root element.