Skip to documentation

Design system / Molecules

Molecule / Field help

LabelWithInfo

LabelWithInfo combines a persistent field label with a separate tooltip trigger. The caller supplies the control ID and optional explanatory content; value and validation remain outside the component.

Live example

Live preview

Current component with fictional data. Example changes are not persisted.

Responsibility

Label and the separate tooltip trigger complete one field-labeling concern. The control, validation and form lifecycle remain outside this molecule. The component does not expose Label or Tooltip's complete prop APIs.

Public contract

The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.

Maintained component API notes; current source is authoritative
Prop / partTypeRequirementResponsibility
htmlForstringRequiredMatches the ID of a control supplied by the consumer.
infoReactNodeRequiredContent for the help tooltip.
childrenReactNodeRequiredVisible label content.

API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.

State and behavior

Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.

Tooltip primitives own their open/focus behavior. This wrapper exposes no open-state, disabled or error prop. The consumer owns field value, validation, control ID and help copy; no dedicated behavior hook is used here.

Dependencies

  • Label
  • Button (ghost / icon-xs)
  • Tooltip, TooltipTrigger, TooltipContent, TooltipProvider
  • Lucide Info

Token and styling contract

These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.

text-label
Label typography role; mapped by the existing theme bridge.
text-muted-foreground
Info icon uses the muted text role.
bg-foreground / text-background
Inherited Tooltip content roles, independent of the field’s value.
ghost / icon-xs, ml-1, max-w-xs, text-xs
Explicit trigger treatment and help geometry. The label remains outside TooltipTrigger.

Boundaries and limitations

  • No className, tooltip placement, delay, disabled or error prop is exposed by LabelWithInfo itself.
  • FieldInfo is private to the file. The provider is set to delayDuration={0}; the help trigger uses “More info” as screen-reader text.
  • The Tooltip uses Radix and a portal. An HTML disclosure cannot reproduce its positioning, focus and hover contracts.

Where to make a change

Change common label/help arrangement in field-label.tsx. Shared Label or ghost/icon-xs Button changes can reach this composition; Tooltip API/portal changes can alter help behavior. Change field-specific help text, required state and validation in the consumer. Keep htmlFor and control ID aligned.

Selected real uses

ProgramOperations

The edition-title field supplies public-title help and htmlFor=edition-create-title, alongside an Input with that ID. This is a use in one route, not a separately named product instance.

Repository path: src/app/(tenants)/console/[tenantCode]/admin/programs/[programCode]/program-operations.tsx

These traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.

Usage contract

import { LabelWithInfo } from "@/components/ui/field-label";
import { Input } from "@/components/ui/input";

<LabelWithInfo htmlFor="edition-title" info="The public display title for this Edition.">
  Edition title
</LabelWithInfo>
<Input id="edition-title" name="title" />

Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.

All molecules
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.