Tooltip
A short label on hover or keyboard focus. It waits a beat the first time, opens instantly on a neighbour, flips at the screen edge, and Escape dismisses it. Overlays.
Open playgroundAbout
Tooltip is a React component in the Overlays category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Tooltip } from "@ashutoshswamy/smoui" and set content, shortcut, side among its 4 props.
Install
npm i @ashutoshswamy/smouiUsage
import { Tooltip } from "@ashutoshswamy/smoui";
<Tooltip content="Copy link" shortcut="C">
<button>Share</button>
</Tooltip>Props 4
- content
The text. Keep it to a sentence.
ReactNode- shortcut
Keycap shown after the text.
string- side
Preferred side. It flips when there is no room.
"top""bottom"default"top"- delay
Wait before the first tooltip opens, in ms.
numberdefault450
More overlays components
- CommandPaletteCmd+K palette. Type to filter, arrows move one highlight that stretches between rows, Enter runs.
- ConfirmPopoverA small are-you-sure that opens beside its button instead of taking over the page. A failed action stays open and says so.
- ContextMenuRight-click, long-press or press the Menu key for a menu that opens out of the exact point you pressed. It flips to stay on screen and moves with the arrow keys.
- DialogA modal that grows out of its trigger, traps focus and keeps its header and footer in view while long content scrolls. Alert mode guards destructive decisions; the confirm button handles async work and failure itself.
- DropdownA menu with one highlight that stretches between rows. Arrow keys, Home and End move it, Enter picks, Escape closes.
- HoverCardA card that opens when you rest on a name, stays while you move onto it and closes when you leave.