Tooltip

@sushindustries/ui

One line on hover and focus, in the markup rather than in title= - and never carrying controls.

5 min read
View as MarkdownEdit on GitHub

Props

PropTypeDefaultDoes
labelstring-The one line. A tooltip that needs two is a hover card.
childrenReactNode-

Notes

children takes whatever needs the label, wrapped in an inline-block span - text, an icon, a whole button. There is no disabled or open prop: the bubble's visibility is pure CSS, driven by :hover and :focus-within on the wrapper, so there is no state to get out of sync with the pointer.

The bubble is not wired to children with aria-describedby. A screen reader that announces it does so by convention on role="tooltip", not because this component built the association - if the label is information a screen reader user must not miss, give the child its own aria-label too rather than relying on the bubble alone.