Tooltip
Tooltip shows a short phrase next to the element it wraps. Hover a button,
or Tab to it:
import { Button, Stack, Tooltip } from '@hozo/ui'
export function TooltipDemo() { return ( <Stack direction="row" gap="tight" align="center"> <Tooltip content="Saves without leaving the page"> <Button tone="neutral">Save</Button> </Tooltip> <Tooltip content="Copies a link anyone in the team can open"> <Button tone="quiet">Share</Button> </Tooltip> </Stack> )}- The child is the trigger. The tooltip adds a ref, the pointer and focus
handlers, and
aria-describedbyto it, so a screen reader reads the phrase after the button’s name. The child has to be one element that accepts those props, such as aButton. contentis the phrase. Keep it to one: the bubble stops atmax-w-xs, and anything a reader must know belongs on the page, where touch users can see it too.- It opens on focus as well as hover, and Escape closes it. The pointer can move from the trigger onto the bubble without it closing.
placementistopby default, and it flips when there is no room.openDelayandcloseDelaytune the timing.- The colours are inverted: dark on a light page and light on a dark one, so it reads as something above the page rather than part of it.