Reference
Tooltip
Shows text above everything when its child is hovered (after delay:) or focused from the keyboard.
Tooltip(_ text: String, shortcut: String, placement: Enum, delay: Number) { … }
Before 5.0
text
placement
bottom
bottomStart
bottomEnd
top
topStart
Example
Row(gap: .sm) {
Tooltip("Copy the link") { IconButton(icon: "copy", label: "Copy link") }
Tooltip("Edit the page", shortcut: "mod+e") { IconButton(icon: "edit", label: "Edit") }
Tooltip("Delete it for good", placement: .bottom, delay: 200) {
IconButton(icon: "trash", label: "Delete").danger
}
}
Around a button, with its shortcut
Tooltip("Save your changes", shortcut: "mod+s") { Button("Save").primary }
Placed to the side
Tooltip("Collapse the sidebar").right { IconButton(icon: "chevron-left", label: "Collapse") }
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
text | String (positional) | — | The tooltip's words, shown above everything at the control in its block and linked to it by |
shortcut: | String | none | The keys that do the same, |
placement: | one of its cases |
| Where it goes against its control; it flips to the other side when there is no room. Written as a flag,
|
delay: | Number |
| How long a hover waits before it shows, in ms; keyboard focus shows it at once |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.bottom
.bottomStart
.bottomEnd
.top
.topStart
.topEnd
.left
.leftStart
.leftEnd
.right
.rightStart
.rightEnd
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Renders with the class wf-tooltip, stable across releases, so a stylesheet may target it.