Components
Label
A label component with required asterisk indicator, optional sub-text, info tooltip, and a composed shorthand for common usage.
Installation
bunx @happlyui/cli@latest add label
Dependencies
npm packages
@radix-ui/react-label
Registry dependencies
These are automatically installed when you add this component.
happly-ui-utilstooltip
Usage
import * as Label from "@/components/ui/label"
<Label.Composed required sub="(Optional)" info="Helpful tooltip">
Field name
</Label.Composed>
Examples
Demo
Label with asterisk, sub-text, and info icon.
<Label.Root>
Last name
<Label.Asterisk />
<Label.InfoIcon />
</Label.Root>
Composed
Props-driven label with required, sub, and info.
<Label.Composed required sub="(Optional)" info="We use this address for account and billing updates.">
Email
</Label.Composed>
API Reference
Label.Root
The root label element built on Radix Label.
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disable the label and apply disabled styling to all children |
Label.Asterisk
Required-field asterisk. The glyph is aria-hidden and paired with visually hidden "(required)" text so assistive technology announces the state.
| Prop | Type | Default | Description |
|---|
Label.Sub
Secondary text displayed after the label.
| Prop | Type | Default | Description |
|---|
Label.InfoIcon
Standalone info circle SVG icon with default w-5 h-5 and text-text-disabled-300 color. Override via className.
| Prop | Type | Default | Description |
|---|
Label.Info
Info icon wrapped in a tooltip. Pass tooltip text as children.
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Tooltip content |
iconClassName | string | - | Override the default icon className |
label | string | 'More information' | Accessible name for the icon-only tooltip trigger |
Label.Composed
Props-driven label that renders Root, Asterisk, Sub, and Info based on props.
| Prop | Type | Default | Description |
|---|---|---|---|
required | boolean | false | Show asterisk indicator |
sub | React.ReactNode | - | Sub-text rendered after the label |
info | React.ReactNode | - | Info tooltip content |
infoLabel | string | 'More information' | Accessible name for the info tooltip trigger |
disabled | boolean | false | Disable the label |