Skip to Content
Cristal

Overlays

Tooltip

Short help text shown when a button or a link is hovered or focused.

<cr-tooltip>CrTooltip

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 through aria-description on 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

PropertyTypeDefaultDescription
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

SlotDescription
defaultLe 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) { … }

PartDescription
tooltipL'infobulle.

On this page