Tooltip
A CSS-only bubble that shows a short plain-text hint when the reader hovers the wrapped inline content or focuses an element inside it.
<Tooltip> wraps inline content (a word, a phrase, an icon) and shows its tip text in a small bubble. It is a daisyUI tooltip: plain CSS on a wrapper <span>, with no script, so it works in static HTML.
Plain tooltip
Hover the underlined word: MDX to see a definition.
import { Tooltip } from '@publier/primitives';
Hover the underlined word:<Tooltip tip="MDX is Markdown with JSX component support — you can mix prose and JSX in the same file."> <span style="text-decoration:underline dotted; cursor:help;">MDX</span></Tooltip> to see a definition.Position and colour
a bottom tooltip<Tooltip tip="Shown below the trigger, in the theme's info colour." position="bottom" color="info"> <span style="text-decoration:underline dotted; cursor:help;">a bottom tooltip</span></Tooltip>Always visible
Set open to show the bubble without hover or focus, for example to point at one element in a walkthrough.
<Tooltip tip="Start here" open> <span>Settings</span></Tooltip>Props
| Prop | Type | Default | Description |
|---|---|---|---|
tip | string | — | Text shown in the bubble. Required. Plain text: it is escaped into a data-tip attribute, so markup in it is shown literally. |
position | 'top' | 'bottom' | 'left' | 'right' | 'top' | Side of the trigger the bubble appears on. |
color | 'primary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | — | Bubble colour from the theme. Omit it for the neutral default. |
open | boolean | false | Keep the bubble visible without hover or focus. |
class | string | — | Extra classes on the wrapper <span>. |
Trigger content passes through as children.
Behaviour
- Renders
<span class="tooltip …" data-tip="…">around your content. CSS draws the bubble fromdata-tip. - The bubble shows on hover, and while an element inside the trigger has keyboard focus (
:focus-visible). - There is no headline, link or rich content. For a longer explanation use a Callout; for a “read more” path, link the term itself.
Accessibility notes
- The tip text lives in an attribute, not in the page’s text, and the wrapper has no role or tab stop. Put anything a reader must know in the page itself.
- To make the hint reachable by keyboard, wrap a link or a button in the tooltip; the bubble then shows while it has focus. More in Accessibility.