Skip to content

Tooltip

A lightweight popup that shows contextual information when hovering or focusing a trigger element.

Preview

Create a new project
Save your changes

Features

  • Four positions -- top, right, bottom, left. The tooltip auto-positions its arrow.
  • Configurable delay -- defaults to 300 ms (the --motion-duration-slow token). Set to 0 for instant display.
  • Max width -- constrained to 240 px to keep text scannable.
  • Arrow -- a 6 px arrow pointing toward the trigger.

Props

PropTypeDefaultDescription
contentReact.ReactNode--Tooltip text or content
position'top' | 'right' | 'bottom' | 'left''top'Preferred placement
delaynumber300Show delay in milliseconds
classNamestring--Additional CSS classes on the tooltip
childrenReact.ReactElement--Trigger element (must accept ref)

Code example

React

tsx
import { Tooltip, Button } from '@thepace/lexicon/components';

function Toolbar() {
  return (
    <div style={{ display: 'flex', gap: 'var(--space-2)' }}>
      <Tooltip content="Create a new project" position="bottom">
        <Button variant="ghost" size="sm">New</Button>
      </Tooltip>

      <Tooltip content="Save your changes" position="bottom" delay={0}>
        <Button variant="ghost" size="sm">Save</Button>
      </Tooltip>

      <Tooltip content="Open settings" position="left">
        <Button variant="ghost" size="sm">Settings</Button>
      </Tooltip>
    </div>
  );
}

Vanilla HTML

html
<div class="lex-tooltip-wrapper">
  <button class="lex-button lex-button--ghost lex-button--sm">New</button>
  <div class="lex-tooltip lex-tooltip--bottom" role="tooltip">
    Create a new project
    <div class="lex-tooltip__arrow"></div>
  </div>
</div>

CSS class reference

ClassPurpose
.lex-tooltip-wrapperPositioning container
.lex-tooltipTooltip element
.lex-tooltip--topTop position
.lex-tooltip--rightRight position
.lex-tooltip--bottomBottom position
.lex-tooltip--leftLeft position
.lex-tooltip__arrowArrow indicator

Accessibility

  • The tooltip uses role="tooltip" and is linked to the trigger via aria-describedby.
  • The trigger element receives focus handling so keyboard users can access the tooltip content.
  • The tooltip is hidden from the accessibility tree when not visible (aria-hidden="true").
  • Content is text-only by design to remain accessible to screen readers.

Released under the MIT License. A product by the pace.