Overlays
Tooltip
Short help text shown when a button or a link is hovered or focused.
Example
cr-tooltip wraps a single focusable element (native button or link, cr-button) and adds a short help text to it, text. The tooltip grows out of the side set by placement (top by default, bottom, start or end) with a slight bounce.
import { CrButton, CrTooltip } from '@cristal-ui/react';
export default function TooltipBasic() {
return (
<>
<CrTooltip text="Copies the page address">
<CrButton variant="outline">Copy link</CrButton>
</CrTooltip>
<CrTooltip text="From the delivery date" placement="bottom">
<a href="#accessibility">30-day returns</a>
</CrTooltip>
</>
);
}For an icon-only button, use the icon button instead: it already shows its label as a tooltip. A tooltip only holds text: for a link or a button, use a popover.
If the user asked their system to reduce motion, the tooltip appears at full size straight away, without growing.
Accessibility
- W3C tooltip pattern:
role="tooltip", and the text describes the trigger (read after its name). Since an id cannot cross the shadow DOM, the description goes througharia-descriptionon the trigger. - The tooltip opens immediately on keyboard focus and after 0.3 s on hover; it can be hovered without disappearing, and Escape closes it even when focus is elsewhere (WCAG criterion 1.4.13).
- No tooltip after a simple tap on a touch screen or after a click: the information must not rely on the tooltip alone.
- Light text on a dark background, contrast above 4.5:1; visible border in high contrast mode.
API
Properties
| Property | Type | Default | Description |
|---|---|---|---|
placement | "bottom" | "end" | "start" | "top" | 'top' | Côté où s'ouvre l'infobulle. |
text (obligatoire) | string | — | Texte de l'infobulle, court et sans lien ni bouton (obligatoire). |
Slots
| Slot | Description |
|---|---|
| default | Le déclencheur, un seul élément focalisable : bouton ou lien natif, ou cr-button. |
CSS parts
To style it from outside: cr-tooltip::part(name) { … }
| Part | Description |
|---|---|
tooltip | L'infobulle. |