Skip to main content
PolyUI/docs

Base

Label

A form label component designed to pair with inputs, checkboxes, and other form elements. Automatically styles for disabled peers.

Installation

bash
npx polyui add label

Basic

tsx
import { Label } from "@polyui/react/label"
import { Input } from "@polyui/react/input"
export function LabelBasic() {
  return (
    <div className="flex flex-col gap-4 w-full max-w-sm">
      <div className="flex flex-col gap-1.5">
        <Label htmlFor="basic-email">Email</Label>
        <Input id="basic-email" type="email" placeholder="Enter your email" />
      </div>
    </div>
  )
}

Disabled

tsx
import { Label } from "@polyui/react/label"
import { Input } from "@polyui/react/input"
export function LabelDisabled() {
  return (
    <div className="flex flex-col gap-4 w-full max-w-sm">
      <div className="flex flex-col gap-1.5">
        <Label htmlFor="disabled-field">Disabled</Label>
        <Input id="disabled-field" disabled placeholder="Read-only field" />
      </div>
    </div>
  )
}

Props

属性类型默认值说明
htmlForstringThe id of the associated form element (HTML for attribute)
classNamestringAdditional CSS class names
childrenReact.ReactNodeLabel text content