|$ curl https://forge-ai.dev/api/markdown?path=docs/components/tooltips
$cat docs/tooltips.md
updated Recently·16 min read·published

Tooltips

CSSHTMLTailwindBootstrapUIIntermediate🎯Free Tools
Introduction

Tooltips are compact overlay messages that reveal supplementary information on hover or focus. This guide covers production-ready tooltip patterns in plain HTML/CSS, Tailwind CSS, and Bootstrap — including positioning, arrows, colors, sizes, rich content, icon triggers, and accessibility.

info

Always pair tooltips with keyboard-focusable triggers. Use aria-describedby to associate the tooltip text with its trigger for screen readers.
Position Variants

Tooltips positioned above, below, left, and right of the trigger element using CSS data attributes.

positions
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="tooltip-wrap" data-tooltip="Top tooltip">
3 <button class="trigger">
4 Top
5 </button>
6 </div>
7 <div class="tooltip-wrap bottom" data-tooltip="Bottom tooltip">
8 <button class="trigger">
9 Bottom
10 </button>
11 </div>
12 <div class="tooltip-wrap left" data-tooltip="Left tooltip">
13 <button class="trigger">
14 Left
15 </button>
16 </div>
17 <div class="tooltip-wrap right" data-tooltip="Right tooltip">
18 <button class="trigger">
19 Right
20 </button>
21 </div>
22</div>
preview
Arrow Styles

Classic arrow, filled arrow, no arrow, and soft shadow variants for different visual contexts.

arrows
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="tip arrow" data-tooltip="Default arrow">
3 Default
4 </div>
5 <div class="tip filled" data-tooltip="Filled arrow">
6 Filled
7 </div>
8 <div class="tip no-arrow" data-tooltip="No arrow">
9 No Arrow
10 </div>
11 <div class="tip shadow" data-tooltip="Soft shadow">
12 Shadow
13 </div>
14</div>
preview
Color Variants

Semantic tooltip colors for success, info, warning, and danger states.

colors
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="tip success" data-tooltip="Operation successful">
3 Success
4 </div>
5 <div class="tip info" data-tooltip="Additional context">
6 Info
7 </div>
8 <div class="tip warning" data-tooltip="Proceed with caution">
9 Warning
10 </div>
11 <div class="tip danger" data-tooltip="Critical error">
12 Danger
13 </div>
14</div>
preview
Sizes

Compact, default, and large tooltips for different information density needs.

sizes
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="tip sm" data-tooltip="Compact hint">
3 Small
4 </div>
5 <div class="tip md" data-tooltip="Default tooltip size">
6 Default
7 </div>
8 <div class="tip lg" data-tooltip="Large tooltip with more space">
9 Large
10 </div>
11</div>
preview
Rich Content

Tooltips with headers, body text, footer metadata, badges, and inline SVG icons.

rich
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="rich-tip">
3 <button class="trigger">
4 System status
5 </button>
6 <div class="rich-content">
7 <div class="rich-header">
8 <svg viewBox="0 0 24 24" fill="none" stroke="#00FF41" stroke-width="2" width="14" height="14">
9 <circle cx="12" cy="12" r="10"/>
10 <line x1="12" y1="16" x2="12" y2="12"/>
11 <line x1="12" y1="8" x2="12.01" y2="8"/>
12 </svg>
13 <span>
14 Information
15 </span>
16 </div>
17 <p class="rich-body">
18 This tooltip supports multiple lines of content with detailed explanations and visual elements.
19 </p>
20 <div class="rich-footer">
21 <span class="badge">
22 Updated
23 </span>
24 <span>
25 2 mins ago
26 </span>
27 </div>
28 </div>
29 </div>
30 <div class="rich-tip left">
31 <button class="trigger">
32 Security
33 </button>
34 <div class="rich-content">
35 <div class="rich-header">
36 <svg viewBox="0 0 24 24" fill="none" stroke="#00FF41" stroke-width="2" width="14" height="14">
37 <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
38 </svg>
39 <span>
40 Status
41 </span>
42 </div>
43 <p class="rich-body">
44 All systems operational. No incidents reported in the last 24 hours.
45 </p>
46 </div>
47 </div>
48</div>
preview
Icon Triggers

Compact icon buttons that reveal labels on hover. Essential for toolbars and navigation.

icons
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="icon-tip" data-tooltip="Copy">
3 <button aria-label="Copy">
4 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
5 <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
6 <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
7 </svg>
8 </button>
9 </div>
10 <div class="icon-tip" data-tooltip="Settings">
11 <button aria-label="Settings">
12 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
13 <circle cx="12" cy="12" r="3"/>
14 <path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/>
15 </svg>
16 </button>
17 </div>
18 <div class="icon-tip" data-tooltip="Delete">
19 <button aria-label="Delete">
20 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
21 <polyline points="3 6 5 6 21 6"/>
22 <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
23 </svg>
24 </button>
25 </div>
26</div>
preview
Interactive Delay

Tooltips with show/hide delay for better UX — instant on desktop, delayed on mobile.

delay
Live
untitled.html
HTML
1<div class="wrapper">
2 <div class="delay-tip" data-delay="200">
3 <button class="trigger">
4 200ms delay
5 </button>
6 <span class="delay-msg">
7 Appears after 200ms
8 </span>
9 </div>
10 <div class="delay-tip" data-delay="500">
11 <button class="trigger">
12 500ms delay
13 </button>
14 <span class="delay-msg">
15 Appears after 500ms
16 </span>
17 </div>
18 <div class="delay-tip" data-duration="3000">
19 <button class="trigger">
20 Auto-hide 3s
21 </button>
22 <span class="delay-msg">
23 Hides after 3 seconds
24 </span>
25 </div>
26</div>
preview
Accessibility

Tooltips must be discoverable and readable for all users. A tooltip that only works on hover fails keyboard and screen-reader users.

  • Attach tooltips to focusable triggers only — use <button> or <a> elements, not divs.
  • Link the tooltip text to the trigger with aria-describedby so screen readers announce it.
  • Ensure the tooltip is visible on keyboard focus, not only on mouse hover.
  • Keep tooltip text concise; move complex content to a popover, modal, or inline help panel.
  • Maintain color contrast ratios of at least 4.5:1 between tooltip text and background.
  • Icon-only triggers require an aria-label on the button and a descriptive tooltip.
  • Avoid relying solely on title attributes; they are inconsistent across browsers and screen readers.
Motion

Subtle motion makes a tooltip feel like it originates from the trigger. Fade the overlay in while translating it a few pixels toward the trigger, and let the arrow settle with the same easing curve. Keep the duration short — around 200 ms — so the hint feels instant, not decorative.

📝

note

Respect prefers-reduced-motion. When the user has requested reduced motion, skip the translate/scale and switch to an instant opacity fade or disable the transition entirely.
motion
Live
untitled.html
HTML
1<div class="motion-demo">
2 <div class="motion-tip">
3 <button class="motion-btn" aria-label="Copy">
4 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
5 <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
6 <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
7 </svg>
8 </button>
9 <span class="motion-box">
10 Copy
11 <span class="motion-arrow">
12 </span>
13 </span>
14 </div>
15 <div class="motion-tip">
16 <button class="motion-btn" aria-label="Save">
17 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
18 <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/>
19 <polyline points="17 21 17 13 7 13 7 21"/>
20 <polyline points="7 3 7 8 15 8"/>
21 </svg>
22 </button>
23 <span class="motion-box">
24 Save
25 <span class="motion-arrow">
26 </span>
27 </span>
28 </div>
29 <div class="motion-tip">
30 <button class="motion-btn" aria-label="Delete">
31 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
32 <polyline points="3 6 5 6 21 6"/>
33 <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
34 </svg>
35 </button>
36 <span class="motion-box">
37 Delete
38 <span class="motion-arrow">
39 </span>
40 </span>
41 </div>
42</div>
preview

Community

Get help on Slack, Discord or VIP

Stuck on a guide? Join the community and ask.