question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tooltip Component

See original GitHub issue

About

We would like to update our Tooltip components to better match design and development expectations. Currently, we see some usage of Tooltip that is completely appropriate for the component. In other areas, we might see Tooltips mistakenly be used. Often times this is when there is interactive content in a Tooltip.

As a result, we would like to limit the situations in which a Tooltip component can be used and augment the gaps with interactivity with the upcoming Popover and Disclosure components. For Tooltip, it should be used for annotating interactive elements with descriptive text.

In addition, it would be nice if this implementation supported a minimal version of “clip detection”. This means that it should be aware of its boundary and will auto-update its position accordingly. This heuristic will be naive initially and will grow support over time.

Accessibility

In terms of accessibility, we will be referencing the following resources:

API Design

The Tooltip component will accept a single child. In addition, it will mutually accept a label prop and description prop. If label is used, then aria-labelledby will be applied to the child. If description is used, aria-describedby will be applied to the child.

Example

<Tooltip label="Modify account settings">
  <button type="button">Edit</button>
</Tooltip>

Output

<div class="tooltip-container">
  <button type="button" aria-labelledby="tooltip1">Edit</button>
  <span class="tooltip">
    <span id="tooltip1" role="tooltip" class="tooltip-content">
      Modify account settings
    </span>
  </span>
</div>

By default, this component will render in-context and will not be rendered using a Portal. This will be an enhancement later, as needed.

Requirements

  • A tooltip can be applied to buttons, links, inputs, and more to create a tooltip
    • Question 1: What happens if our components don’t offer a way to access the interactive element?
  • A tooltip should be invoked upon hover or focus of the element which the tooltip describes (after a pause)
  • The tooltip should not be focusable, or contain elements which are focusable
  • The tooltip is dismissed after the element which invoked the tooltip has been blurred (unless the tooltip itself is hovered)
  • A tooltip is dismissible by use of the Escape key

Remaining items

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joshblackcommented, Dec 8, 2021

Hey @kubijo! 👋

This is definitely an enhancement we’d like to make for tooltips so that they can render outside of the current tree. Hopefully, it will make the cut for v11, but if not we will prioritize landing it because of how often this comes up 👍

0reactions
kubijocommented, Dec 9, 2021

Just FYI: For the time being, I’ve been able to make my own component thanks to react-popper-tooltip.

It is admittedly much more naive and unconcerned with A11Y than what you surely need, but it might give you some entropy to work with & I will gladly go back to carbons native and remove an extra library dependency in my project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Tooltip component - Material UI - MUI
Tooltips display informative text when users hover over, focus on, or tap an element. When activated, Tooltips display a text label identifying an...
Read more >
Building a tooltip component - web.dev
A tooltip is a non-modal, non-blocking, non-interactive overlay containing supplemental information to user interfaces. It is hidden by default ...
Read more >
Tooltip – Carbon Design System
A tooltip is a message box that is displayed when a user hovers over or gives focus to a UI element. The tool...
Read more >
Tooltips - Material Design
A tooltip is displayed upon tapping and holding a screen element or component (on mobile) or hovering over it (desktop). Continuously display the...
Read more >
Tooltip - Examples - Components - Atlassian Design System
A tooltip is a floating, non-actionable label used to explain a user interface element or feature.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found