Tooltip

Alpha

A lightweight, accessible tooltip that appears on hover or focus. Uses role='tooltip' with proper aria-describedby wiring.

Import

import { Tooltip } from "@compa11y/react";

Usage

Example.tsx
import { Tooltip, Button } from "@compa11y/react";

function Example() {
  return (
    <div style={{ display: "flex", gap: "16px" }}>
      <Tooltip label="Save your changes">
        <Button>Save</Button>
      </Tooltip>

      <Tooltip label="Delete this item permanently" side="bottom">
        <Button variant="danger">Delete</Button>
      </Tooltip>

      <Tooltip label="Copy to clipboard" side="right">
        <Button variant="ghost">Copy</Button>
      </Tooltip>
    </div>
  );
}

Features

  • role='tooltip' with aria-describedby on the trigger
  • Opens on hover and keyboard focus
  • Configurable open/close delay
  • Placement options: top, right, bottom, left
  • Escape key to dismiss
  • Respects prefers-reduced-motion

Props

Tooltip component props
PropTypeDefaultDescription
label*string-Tooltip text content
side'top' | 'right' | 'bottom' | 'left''top'Preferred placement
align'start' | 'center' | 'end''center'Alignment along the side axis
delayOpennumber300Delay in ms before showing
delayClosenumber100Delay in ms before hiding
disabledbooleanfalsePrevents the tooltip from showing
children*ReactNode-Trigger element

Keyboard Interactions

Accessibility
All keyboard interactions follow WAI-ARIA best practices and work without any additional configuration.
Keyboard shortcuts for Tooltip
KeyAction
Tab (focus)Shows the tooltip when the trigger receives keyboard focus
EscapeDismisses the tooltip