Skip to main content

Tooltip

BasicOverlays<co-tooltip>

Tooltip shows a short label for an icon or truncated text on hover and keyboard focus.

import { Tooltip } from 'health-components';

Examples​

Showcase​

Storybook

Placements​

Storybook

On Hover And Focus​

Storybook

Usage​

<Tooltip label="Print chart"><IconButton icon="file" label="Print chart" /></Tooltip>

When to use​

  • Naming icon-only controls, explaining an abbreviation (POS, DOS).

When not to use​

  • Anything the user must read to finish the task.

Variants and states​

VariantWhat it is
top / bottom / rightPlacement.
openForced open for docs.

Accessibility​

  • Shown on focus as well as hover; linked with aria-describedby.
  • Text is toast-ink on toast-bg.

Do and don't​

  • Do: "DOS: date of service".
  • Don't: Tooltips on disabled buttons (they get no focus).

Props​

PropTypeDefaultDescription
label *string—Tooltip text; required
children *ReactElement<{ 'aria-describedby'?: string }>—One focusable element (Button, IconButton, link); required
placementTooltipPlacement'top''top' | 'bottom' | 'right'
openbooleanfalseKeeps the tooltip shown (docs, onboarding)
idstringgeneratedid of the tooltip element
classNamestring—Class on the wrapper

Every component also accepts className.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-tooltip>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-tooltip label="…" placement="…">…</co-tooltip>
KindNameDescription
attributelabelTooltip text; required
attributeplacement'top' | 'bottom' | 'right'; default 'top'
attributeopenKeeps the tooltip shown (docs, onboarding); default false
attributeidid of the tooltip element; default generated
attributeclass-name / classNameClass on the wrapper
slot(default)One focusable element (Button, IconButton, link); required