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.

Create button tooltip component

See original GitHub issue

Summary

Currently there is no simple way to add a tooltip to a button. However it is a demand of many services (at least our one: SQL Query) to give users a hint of what a button is going to achieve.

The only current solution is to wrap a tooltip (more specifically <TooltipDefinition>) around a button:

    <div className="button">
      <TooltipDefinition
        tooltipText="this is going to happen when you click"
        direction="bottom"
        alignment="right"
      >
        <Button>A button</Button>
      </TooltipDefinition>
    </div>

While this works in principle it produces a number of errors in the browser:

  1. Warning: Failed prop type: Invalid prop 'children' of type 'object' supplied to 'TooltipDefinition', expected 'string', due to
...
TooltipDefinition.propTypes = {
  /**
   * Specify the tooltip trigger text that is rendered to the UI for the user to
   * interact with in order to display the tooltip.
   */
  children: _propTypes.default.string.isRequired,
...
  1. Warning: validateDOMNesting(...): <button> cannot appear as a descendant of <button> This is due to the fact that the tooltip itself is creating a <button> into which we are wrapping another button.

A native button tooltip would avoid these issues. I assume design (in case the button tooltip should be different from other tooltips) and development (css, implementation for react…) would be required to solve this issue.

Justification

There is currently no suitable alternatives.

Desired UX and success metrics

“Must have” functionality

Hovering over a button should show a tooltip similar to the Definition Tooltip (i.e. multiline possible).

Specific timeline issues / requests

SQL Query is currently moving to carbon components (this sprint). Current solution using Definition Tooltip is not satisfying because of browser errors

Available extra resources

What resources do you have to assist this effort?

Here is a codesandbox which highlights what i mean: https://codesandbox.io/s/rw4w26kkzp. (I also briefly tried to create a Vanilla-JS version of a multi-line botton tooltip which does not seem to work solely based on the predefined styles: see last button)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
shixiedesigncommented, May 16, 2019

@asudoh Nooo why would i be against it?! 😂Please add it 🎉 this is clearly useful knowledge!

1reaction
gmoehlercommented, May 21, 2019

For reference: this is what i am currently using (until 10.3 is out): https://codesandbox.io/s/buttonwithtooltipref-b2wqn (added own trigger styles and right aligned styles from master branch)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Create Tooltips - W3Schools
Tip: Go to our CSS Tooltip Tutorial to learn more about tooltips. Tip: To create "clickable" tooltips, go to our How To Create...
Read more >
Tooltips for Button elements - html - Stack Overflow
Is it possible to create a tooltip for an html button. Its the normal HTML button and there is no Title attribute as...
Read more >
How to Tooltip for Button in React Button component
Tooltip can be shown on Button hover and it can be achieved by setting title attribute. The following snippets illustrates how to show...
Read more >
React Tooltip component - Material UI - MUI
Tooltips display informative text when users hover over, focus on, or tap an element.
Read more >
Tooltips - Bootstrap
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-attributes for local title storage.
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