Tooltip
A hover/focus hint on Ark UI's Tooltip — ARIA-wired (role="tooltip" + aria-describedby), portaled and animated. Drops into running text or wraps any element.
Tooltip is the kit's lightweight hint — the hover/focus counterpart to Popover's clickable panel. It's a styled layer over Ark UI's Tooltip: Ark owns the open/close state, the open/close delays, positioning, and the accessibility wiring — role="tooltip" on the bubble, aria-describedby on the trigger, Esc to dismiss, and no focus trap. The kit adds the portaled, animated, inverted bubble.
It opens on pointer hover and keyboard focus, so it's accessible by default.
import { Tooltip } from '@42-central/ui-react/tooltip';
// Inline in text — children become a focusable trigger
<p>Validate the <Tooltip label="A graded project.">Norm</Tooltip> first.</p>
// Wrap an element — asChild makes the child the trigger
<Tooltip label="Delete" asChild>
<ActionIcon aria-label="Delete"><Trash2 /></ActionIcon>
</Tooltip>On a button
The common case: wrap any interactive element with asChild. The tooltip names or expands on the control.
Code
<Tooltip label="Saved automatically every few seconds" asChild>
<Button>Hover or focus me</Button>
</Tooltip>On an icon-only control
Pair it with an ActionIcon. Keep the aria-label on the icon — that's the accessible name; the tooltip is the visible echo for sighted users.
Code
<Tooltip label="Delete" asChild>
<ActionIcon aria-label="Delete" variant="subtle" color="neutral">
<Trash2 />
</ActionIcon>
</Tooltip>Inline in text
Without asChild, the children are wrapped in a <button type="button"> reset to plain inline text that inherits the surrounding font — so a tooltip drops straight into a <p> (a button is phrasing content), screen readers meet a real control rather than a role-less focusable span, and the term stays selectable, copyable prose (a drag across the sentence copies it in Chromium, WebKit and Firefox alike). Use variant="text" for a dotted-underline glossary look, or the default variant="inline" to leave the text unstyled; classNames.trigger overrides either. To attach a hint to an element you already have (a link, an icon button), use asChild so that element becomes the trigger. Without asChild, keep the children to text and inline phrasing content: a button can't contain another control, so wrapping a Button or a link without asChild nests one interactive element in another (and React reports the invalid nesting).
Every cadet must validate the before moving on to the next milestone.
Code
<p>
Every cadet must validate the{" "}
<Tooltip label="A graded project in the 42 curriculum." variant="text">
Norm
</Tooltip>{" "}
before moving on to the next milestone.
</p>Positioning
position sets the placement and offset the gap; the bubble flips and shifts to stay in view (Ark / Floating UI). Prefer the logical, RTL-aware sides start / end — they resolve to left / right based on the active direction, so the tooltip mirrors automatically under dir="rtl". (Physical left / right and Ark's aligned variants like top-start still work.)
Code
<Tooltip label="Placed start" position="start" asChild>
<Button>start</Button>
</Tooltip>
<Tooltip label="Placed top" position="top" asChild>
<Button>top</Button>
</Tooltip>
<Tooltip label="Placed bottom" position="bottom" asChild>
<Button>bottom</Button>
</Tooltip>
<Tooltip label="Placed end" position="end" asChild>
<Button>end</Button>
</Tooltip>With an arrow
Pass withArrow to grow a small arrow that points back at the trigger — a clearer visual tie when the bubble sits away from its anchor. It inherits the inverted surface, flips with the placement, and tucks behind the bubble so only the tip shows. In the compound form, compose a Tooltip.Arrow inside Tooltip.Content instead; restyle it with classNames.arrow (or the part's own className).
Code
<Tooltip label="Points back at the trigger" withArrow asChild>
<Button>Hover or focus me</Button>
</Tooltip>Playground
Tooltip
Dir
Presets
Props
Code
<Tooltip
label="Saved automatically"
position="top"
variant="inline"
openDelay={400}
closeDelay={150}
/>Anatomy
Tooltip— the convenience form: alabelplus a single child trigger.Tooltip.Root— wraps Ark'sTooltip.Root; owns open state, delays, and positioning.Tooltip.Trigger— the trigger; useasChildto wrap your own element.Tooltip.Content— the portaled, animated bubble (role="tooltip").Tooltip.Arrow— an optional arrow pointing at the trigger; place it insideTooltip.Content. Other props (id,data-*,aria-*) land on the arrow element.
Tooltip.Root is a headless provider with no DOM node of its own, so it takes no testId. Tooltip.Content (the bubble) and Tooltip.Arrow each take their own testId; the convenience <Tooltip testId="..."> shorthand routes its testId to the rendered content bubble too. Tooltip.Trigger is a raw Ark re-export and was left alone: Ark already forwards an arbitrary data-testid straight through natively. See Testing.
<Tooltip.Root position="end">
<Tooltip.Trigger asChild>
<Button>Hover</Button>
</Tooltip.Trigger>
<Tooltip.Content>
<Tooltip.Arrow />
Rich <strong>content</strong>
</Tooltip.Content>
</Tooltip.Root>API
Tooltip props (the convenience form; Tooltip.Root takes the same props minus label / asChild / withArrow / classNames):
Prop
Type
Accessibility
- The bubble has
role="tooltip"; Ark sets the trigger'saria-describedbyto it while it's shown, so the hint is read as the trigger's description, never its name. An icon-only trigger still needs its ownaria-label. - The default (non-
asChild) trigger is a<button type="button">, so it's in the tab order with a role, and opens on keyboard focus like it does on hover. Escdismisses it, and it never traps focus. Don't put anything interactive inside a tooltip — usePopoverfor that.
Changelog
- #389
The default trigger is a
<button>(it was a focusable<span>); useasChildwhen the tooltip wraps a control
- #294
asChildis a compile error onCombobox.Control,Group,Content,PanelandItem,Drawer/Modal.Positioner,Drawer.Grabber,Popover.ContentandTooltip.Arrow
- #135
Opened inside a
ModalorDrawer, an overlay portals into it, so it always paints above its host
- #34
onClosefires alongsideonOpenChange, as on Modal
- #3
withArrowpoints the tooltip at its trigger
Tooltip: a hint on hover and focus
Popover
A floating panel on Ark UI's Popover — portaled, width-matched to the trigger, animated, with composable Header / Body / Footer slots.
HoverCard
A rich preview panel on Ark UI's HoverCard — delayed, portaled and animated. Hover a trigger, see a card; add HoverCard.Group so a row of triggers shares one card that slides between them.