Currently brewing — dede is in beta: a first set of components, with more to come. The API may still change.

Tooltip

A short line of text beside a control, naming what it does.

import { Tooltip } from "@dede-style/ui/tooltip", then put the control inside it: <Tooltip content="Add to favourites"><IconButton … /></Tooltip>. The tooltip attaches to the control it wraps, so there is nothing else to connect.

Rest the pointer on the star, or move to it with the Tab key, and its name appears above it.

Tooltip is a wrapper. The control goes inside it, and the tooltip attaches to that control. Any single control that can take focus works, but the usual one is an IconButton, because it has no visible words of its own.

It shows straight away when the control gets keyboard focus, and after a short delay when the pointer rests on it, so a pointer passing over a row of buttons does not set off a tooltip on each one. It never shows on a touch screen, because there a tap belongs to the control. It hides as soon as the pointer or focus leaves, the control is pressed, or Escape is pressed.

import { Tooltip } from "@dede-style/ui/tooltip"
import { IconButton } from "@dede-style/ui/button"
import { iconArrowRight } from "@dede-style/ui/icons"

<Tooltip content="Matching">
    <IconButton glyph={iconArrowRight} label="Next: Matching" href="/matching" />
</Tooltip>

Placement

The four sides a tooltip can sit on. Point at each button, or tab through them, to see its tooltip.

placement is above by default. The other choices are below, start and end. Start and end follow the reading direction: in a right-to-left language, start is on the right.

Choose the side that covers the least of what the reader needs next. A button in a top bar usually wants its tooltip below, so it does not hang off the top of the window.

Align

Where the tooltip lines up along its side of the button.

align is center by default. With start, the tooltip’s start edge lines up with the button’s start edge and the text runs towards the end. With end, it is the other way round. On a tooltip at the start or end side, the same choice lines it up with the button’s top or bottom edge.

Lining up with an edge is useful for a button near the edge of the page, where a centred tooltip would stick out past it.

A toolbar

Move the pointer slowly along the toolbar, then quickly across it.

These tooltips sit below their buttons. A toolbar along the top of the screen wants its tooltips below, so they do not hang off the top of the window or cover what is above the toolbar. Elsewhere, the default of above is usually right.

A pointer that only passes over the toolbar shows nothing, because a tooltip waits for the pointer to rest. The wait is the token --tooltip-delay, 200ms by default, rather than a prop, so it is the same for every tooltip on a site. Set it on :root to change it everywhere.

Once one tooltip has shown, the next button’s tooltip opens without waiting, as long as the pointer reaches it within the same delay. So someone reading along a toolbar sees each name in turn.

At the edge of the window

A tooltip that would go off screen moves to the opposite side, and one inside a scrolling box is never cut off by it.

The first button asks for its tooltip on its end side. In a wide window there is room, so that is where it shows. On a phone, or in a narrow window, there is no room to the right of the button, so the tooltip shows on its left instead. A tooltip above a button that is scrolled to the top of the window moves below it in the same way. The browser does this with CSS anchor positioning; there is no script measuring the page.

The second button sits in a small box that hides whatever overflows it, as a scrolling table does. Its tooltip still shows in full, because a tooltip is drawn in the browser’s top layer, above the rest of the page.

Anchor positioning is in Chrome and Edge 129 and later, Safari 26 and Firefox 147. In an older browser the tooltip shows on the side you chose and does not move at an edge.

Accessibility

Screen readers do not read the tooltip. They read the control’s own accessible name, such as an IconButton’s label. The tooltip is a visual copy of that name, so a screen reader would otherwise say it twice. This means the name must carry everything the tooltip says. A tooltip can say less than the name, such as “Matching” on a button named “Next: Matching”, but never more.

Keyboard users see it too. It shows when focus arrives by the keyboard, and Escape hides it without moving focus. A mouse click also focuses a button, but that shows nothing, since the pointer is already there.

The pointer can move onto the tooltip. It stays open while the pointer crosses from the button to the text, so someone using screen magnification can read it. This is what WCAG asks of content that appears on hover.

A disabled control shows no tooltip. It cannot take keyboard focus, so a tooltip on it would only ever reach mouse users. If a control is disabled for a reason the reader needs, say the reason in visible text near it.