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

wf

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

wf

Tooltip("Save your changes", shortcut: "mod+s") { Button("Save").primary }

Placed to the side

wf

Tooltip("Collapse the sidebar").right { IconButton(icon: "chevron-left", label: "Collapse") }

Props

Props of Tooltip
PropTypeUnsetMeaning

text

String (positional)

—

The tooltip's words, shown above everything at the control in its block and linked to it by aria-describedby

shortcut:

String

none

The keys that do the same, mod+s, shown as a chip as this system writes them and set as the control's aria-keyshortcuts

placement:

one of its cases

top

Where it goes against its control; it flips to the other side when there is no room. Written as a flag, .bottom, or by name, placement: .bottom.

  • .bottom: Below, centred
  • .bottomStart: Below, from its start
  • .bottomEnd: Below, to its end
  • .top (the default): Above, centred (the default)
  • .topStart: Above, from its start
  • .topEnd: Above, to its end
  • .left: Before it, centred
  • .leftStart: Before it, from its top
  • .leftEnd: Before it, to its bottom
  • .right: After it, centred
  • .rightStart: After it, from its top
  • .rightEnd: After it, to its bottom

delay:

Number

500

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.