Skip to content
Advertisement

Add Tooltip over a button

I’m trying to create a button which copies into clipboard content from variable using TypeScript and Material-UI. I tried this:

JavaScript

Button to call above code:

JavaScript

Do you know how I can add Tooltip https://mui.com/components/tooltips/ over the button to display message for successful copy when the text is copied?

Advertisement

Answer

You can use the controlled version of the MUI tooltip to manually open and close the tooltip on some event.

The updated code could be something like below to show and hide the tooltip.

JavaScript

sandbox

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement