Component reference
Label
Visible field labels in a sign-in composition.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Sign in
Labels linked to their fields with htmlFor.
Invite
The optional hint makes the requirement explicit.
Width adapts to the available space
"use client";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
Label,
Input,
Button
} from "@pimolu/react";
export function DemoExample() {
return (
<div
className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-6 min-w-0 items-start"
>
<Card>
<CardHeader>
<CardTitle>Sign in</CardTitle>
<CardDescription>Labels linked to their fields with htmlFor.</CardDescription>
</CardHeader>
<CardContent>
<div className="grid gap-5 min-w-0">
<div className="grid gap-5 min-w-0">
<Label htmlFor="login-email" required>Email</Label>
<Input id="login-email" type="email" placeholder="you@example.com" />
</div>
<div className="grid gap-5 min-w-0">
<Label htmlFor="login-password" required>Password</Label>
<Input id="login-password" type="password" placeholder="••••••••" />
</div>
<Button>Sign in</Button>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Invite</CardTitle>
<CardDescription>
The optional hint makes the requirement explicit.
</CardDescription>
</CardHeader>
<CardContent>
<div className="grid gap-5 min-w-0">
<div className="grid gap-5 min-w-0">
<Label htmlFor="invite-email" required>Email</Label>
<Input
id="invite-email"
type="email"
placeholder="teammate@example.com"
/>
</div>
<div className="grid gap-5 min-w-0">
<Label htmlFor="invite-message" optional optionalLabel="Optional">Message</Label>
<Input id="invite-message" placeholder="Welcome to the team" />
</div>
<Button appearance="outline">Send invitation</Button>
</div>
</CardContent>
</Card>
</div>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
States
Required, optional and disabled labels; the asterisk is hidden from screen readers.
Sizes
Enumerated from labelVariantMap: sm, md and lg.
Sign in
A sign in composition using Label.
Usage
Associate each Label with the exact input id; labels do not implement form state.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluLabelProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
required | boolean | undefined | false | Show a required asterisk. |
optional | boolean | undefined | false | Show the optional hint after the label. |
optionalLabel | string | undefined | "Optional" | Text of the optional hint. Defaults to "Optional". |
disabled | boolean | undefined | false | Mute the label when its control is disabled. |
size | "sm" | "md" | "lg" | undefined | "md" | Font size. Defaults to "md". |
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLLabelElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLLabelElement> | undefined | — | Standard React/HTML attribute. |
requiredboolean | undefinedDefault: false
Show a required asterisk.
optionalboolean | undefinedDefault: false
Show the optional hint after the label.
optionalLabelstring | undefinedDefault: "Optional"
Text of the optional hint. Defaults to "Optional".
disabledboolean | undefinedDefault: false
Mute the label when its control is disabled.
size"sm" | "md" | "lg" | undefinedDefault: "md"
Font size. Defaults to "md".
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLLabelElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLLabelElement> | undefinedNo default extracted.
Standard React/HTML attribute.
Accessibility
- Clicking a label should focus its control. Do not replace it with placeholder text.