HapplyUI

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-utils
  • tooltip

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.Sub>(Optional)</Label.Sub>
  <Label.InfoIcon />
</Label.Root>

Composed

Props-driven label with required, sub, and info.

<Label.Composed required sub="(Optional)" info="We will use this email to send you updates.">
  Email
</Label.Composed>

API Reference

Label.Root

The root label element built on Radix Label.

PropTypeDefaultDescription
disabledbooleanfalseDisable the label and apply disabled styling to all children

Label.Asterisk

Required field asterisk indicator in primary color.

PropTypeDefaultDescription

Label.Sub

Secondary text displayed after the label.

PropTypeDefaultDescription

Label.InfoIcon

Standalone info circle SVG icon with default w-5 h-5 and text-text-disabled-300 color. Override via className.

PropTypeDefaultDescription

Label.Info

Info icon wrapped in a tooltip. Pass tooltip text as children.

PropTypeDefaultDescription
childrenReact.ReactNode-Tooltip content
iconClassNamestring-Override the default icon className

Label.Composed

Props-driven label that renders Root, Asterisk, Sub, and Info based on props.

PropTypeDefaultDescription
requiredbooleanfalseShow asterisk indicator
subReact.ReactNode-Sub-text rendered after the label
infoReact.ReactNode-Info tooltip content
disabledbooleanfalseDisable the label

Previous
Input