Components
Tooltip
Short hover and focus hint, with the portal, positioner and popup folded into one Content part.
import { Button, Tooltip } from "@openperf/deft";
import { IconPlus } from "@tabler/icons-react";
<Tooltip.Root>
<Tooltip.Trigger render={<Button.Root aria-label="Add project" shape="square" />}>
<IconPlus />
</Tooltip.Trigger>
<Tooltip.Content>Add project</Tooltip.Content>
</Tooltip.Root>;When to use
| Need | Component |
|---|---|
| Name an icon-only button, or add a detail of a line or two | Tooltip |
| A title with longer text, or anything the user clicks | Popover |
Do not put information in a tooltip that the user cannot get any other way.
Anatomy
<Tooltip.Provider>
{/* the provider goes once per app and shares the open delay */}
<Tooltip.Root>
<Tooltip.Trigger /> {/* a <button> unless render is passed */}
<Tooltip.Content /> {/* portal, positioner and popup in one part */}
</Tooltip.Root>
</Tooltip.Provider>Tooltip.Provider is optional and belongs with the root providers: after one tooltip is shown, the ones next to it open at once.
Trigger
Pass a Button to render for an action, or a plain element such as <span /> to attach a tooltip to text. The tooltip does not label its trigger, so an icon-only trigger still needs its own aria-label.
Placement
Tooltip.Content opens 6px from the trigger, above it unless side is set. It is at most 320px wide and wraps longer text.
API
Tooltip.Root, Tooltip.Trigger and Tooltip.Provider are the Base UI parts, as are the rest of its exports: Tooltip.Portal, Tooltip.Positioner, Tooltip.Popup, Tooltip.Arrow, Tooltip.Viewport, Tooltip.createHandle and Tooltip.Handle.
Tooltip.Content
Prop
Type