Travelling Tooltip, animated React component
One tooltip for a whole toolbar. The first hover waits a beat, then it glides from button to button with no delay, resizing to each label and showing the shortcut.
- Pro
- Motion Effects
- Hover
- Spring
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Hover one button, then slide along the bar
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| tools | TravellingTooltipTool[] | TRAVELLING_TOOLTIP_TOOLS | The toolbar buttons: id, label, keys (the shortcut shown as a keycap) and d (SVG path data for a 24 x 24 stroke icon). Defaults to a six-button text formatting bar. |
| label | string | "Formatting" | Accessible name of the toolbar. |
| openDelay | number | 450 | How long the first hover waits before the tooltip appears, in ms. After that it travels with no delay. |
| warmMs | number | 600 | How long the tooltip stays warm after the pointer leaves the bar, in ms. Re-enter within this time and it appears at once. |
| hint | string | "Hover one button, then slide along the bar" | Caption under the toolbar. Pass an empty string to hide it. |
| onSelect | (tool: TravellingTooltipTool) => void | — | Called when a button is pressed. |
| autoplay | boolean | false | Walks the tooltip along the bar by itself until someone points at or focuses the bar. Pauses off screen and never runs under reduced motion. |
| className | string | — | Extra classes for the wrapper. |