You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a proposal to define a more flexible API and clean up some issues that have arisen after the first implementations have been used in the real world.
Distinction
Tooltip
A means of displaying a description or extra information about an element, usually on hover, but can also be on click or tap.1
Semantically, tooltips are linked to the trigger element through aria-describedby so the tooltip text is automatically being read by screenreaders when focus is on the trigger.
Popover
An element that pops up from another element over other content; it differs from a tooltip in that it is usually triggered via click instead of hover and can contain interactive elements.2
Semantically, popovers act as disclosure content which is not linked to the trigger. The trigger has an aria-expanded attribute to communicate the current state of the popover.
Issues with the current implementations
Hoverable tooltips get in the way of the cursor when there are a lot of buttons in a table. To resolve this issue, a delay option was added with Tooltip: add delay option #3213. The delay resolves the issue in most cases and is compatible with recommendations from Accessibility experts like Sarah Higley (https://sarahmhigley.com/writing/tooltips-in-wcag-21/#best-practices-summary). Still, it feels like a workaround and not a real solution to the issue at hand
Devs reported difficulties with setting id attributes for all the things. An alternative attribute has been proposed to get around the side effects of id, but was dismissed as the uniqueness is wanted here ([components]: Tooltip refactoring #4170)
arrow, boolean prop that will display an arrow, false by default (because that's what boolean props should be)
delay, [open-delay]|[open-delay close-delay] if it's a number, open delay in milliseconds, if it's a string of two numbers, e.g. delay="200 400", the first number is the open delay and the second the close delay, defaults to undefined
placement, string, one of the floating ui placement possibilities, defaults to 'top'
no-hover, boolean that defaults to false. Can be used to hide the tooltip when the cursor leaves the trigger, making the tooltip not hoverable. This is not accessible, but a requested feature that would be worked around if not there
id, string used to connect <post-tooltip-trigger> with the target <post-tooltip>, optional if the tooltip is nested inside the trigger
Background colour can be set by palette utilities.
Tooltip trigger props
for, string connects the trigger to it's tooltip, optional if the tooltip is nested inside the trigger
Setup
<!-- Tooltip is connected via for/id attributes --><post-tooltip-triggerfor="bold-description"><button>B</button></post-tooltip-trigger><post-tooltipid="bold-description">Bold</post-tooltip><!-- Tooltip is nested inside the trigger, no for/id attributes necessary --><post-tooltip-trigger><button>B</button><post-tooltip>Bold</post-tooltip></post-tooltip-trigger>
Popover proposal
Popover props
Popover trigger props
for, string connects the trigger to it's popover, optional if the tooltip is nested inside the trigger
`
Setup
<!-- Popover is connected via for/id attributes --><post-popover-triggerfor="more-info"><button>show info</button></post-popover-trigger><post-popoverid="more-info"><h3>Additional info</h3><p>Lorem...</p><ahref="/goto">Read more about it</a></post-popover><!-- Popover is nested inside the trigger, no for/id attributes necessary --><post-popover-trigger><button>show info</button><post-popover><h3>Additional info</h3><p>Lorem...</p><ahref="/goto">Read more about it</a></post-popover></post-tooltip-trigger>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Tooltips and popovers are a much discussed topic.
post-popovercontainer
promotes to Top Layer, causing UI overlap issues #4398<post-popovercontainer>
#4169This is a proposal to define a more flexible API and clean up some issues that have arisen after the first implementations have been used in the real world.
Distinction
Tooltip
A means of displaying a description or extra information about an element, usually on hover, but can also be on click or tap.1
Semantically, tooltips are linked to the trigger element through
aria-describedby
so the tooltip text is automatically being read by screenreaders when focus is on the trigger.Popover
An element that pops up from another element over other content; it differs from a tooltip in that it is usually triggered via click instead of hover and can contain interactive elements.2
Semantically, popovers act as disclosure content which is not linked to the trigger. The trigger has an
aria-expanded
attribute to communicate the current state of the popover.Issues with the current implementations
id
attributes for all the things. An alternative attribute has been proposed to get around the side effects ofid
, but was dismissed as the uniqueness is wanted here ([components]: Tooltip refactoring #4170)Tooltip proposal
Tooltip props
arrow
, boolean prop that will display an arrow, false by default (because that's what boolean props should be)delay
,[open-delay]|[open-delay close-delay]
if it's a number, open delay in milliseconds, if it's a string of two numbers, e.g.delay="200 400"
, the first number is the open delay and the second the close delay, defaults toundefined
placement
,string
, one of the floating ui placement possibilities, defaults to 'top'no-hover
,boolean
that defaults to false. Can be used to hide the tooltip when the cursor leaves the trigger, making the tooltip not hoverable. This is not accessible, but a requested feature that would be worked around if not thereid
,string
used to connect<post-tooltip-trigger>
with the target<post-tooltip>
, optional if the tooltip is nested inside the triggerBackground colour can be set by palette utilities.
Tooltip trigger props
for
,string
connects the trigger to it's tooltip, optional if the tooltip is nested inside the triggerSetup
Popover proposal
Popover props
Popover trigger props
for
,string
connects the trigger to it's popover, optional if the tooltip is nested inside the triggerSetup
Footnotes
https://component.gallery/components/tooltip/ ↩
https://component.gallery/components/popover/ ↩
Beta Was this translation helpful? Give feedback.
All reactions