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
Placements
On Hover And Focus
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
| Variant | What it is |
|---|---|
| top / bottom / right | Placement. |
| open | Forced open for docs. |
Accessibility
- Shown on focus as well as hover; linked with aria-describedby.
- Text is
toast-inkontoast-bg.
Do and don't
- Do: "DOS: date of service".
- Don't: Tooltips on disabled buttons (they get no focus).
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Tooltip text; required |
children * | ReactElement<{ 'aria-describedby'?: string }> | — | One focusable element (Button, IconButton, link); required |
placement | TooltipPlacement | 'top' | 'top' | 'bottom' | 'right' |
open | boolean | false | Keeps the tooltip shown (docs, onboarding) |
id | string | generated | id of the tooltip element |
className | string | — | 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>
| Kind | Name | Description |
|---|---|---|
| attribute | label | Tooltip text; required |
| attribute | placement | 'top' | 'bottom' | 'right'; default 'top' |
| attribute | open | Keeps the tooltip shown (docs, onboarding); default false |
| attribute | id | id of the tooltip element; default generated |
| attribute | class-name / className | Class on the wrapper |
| slot | (default) | One focusable element (Button, IconButton, link); required |