shadcn.io is not affiliated with official shadcn/ui
Label examples · Standard
Label with Tooltip for React
A label with an info button that opens a tooltip explaining the field.
Keep a technical caption short and put the explanation one hover or focus away. The Label says API Key, and a ghost icon button beside it opens a Tooltip that reads Your secret API key for authentication. Use it when a description under the field would crowd the form.
Preview
Installation
FAQ
What does the info control open?
A tooltip that says Your secret API key for authentication. The label says API Key, and the label and the button sit in a row with flex items-center gap-1.
How is the info control marked up?
It is a Button with variant="ghost", size="icon-xs" and aria-label="About the API key". The icon is aria-hidden and uses text-muted-foreground. It sits beside the Label, not inside it, so a click on the caption doesn't land on the button.
How is that control attached to the tooltip?
TooltipTrigger receives the button through render. A TooltipProvider wraps the tooltip.
How do I change how soon the tooltip opens?
This demo leaves the delay at the default. Set it on the trigger or the provider.
Use delay and closeDelay on TooltipTrigger, or delay on a TooltipProvider.
Does this tooltip open on a touch screen?
Not from a hover. Touch screens have no hover, so it shows when the trigger is focused. For a note people must be able to read on a phone, use a Toggle Tooltip, which opens on tap.
Related
- Label with DescriptionA label with a line of muted helper text
- Required LabelA label with a destructive asterisk that
- Simple TooltipAn outline button that shows a one-line
- Label with BadgeA label with a secondary badge that marks
- Input with LabelA text input with a label above it
- Error LabelA label in the destructive color with an