@react-md/tooltip
TypeScript icon, indicating that this package has built-in type declarations

5.1.6 • Public • Published

@react-md/tooltip

Create accessible tooltips to add additional descriptions to buttons, links, or any other element. The tooltips will automatically attempt to position themselves within the viewport and adjust as needed.

Installation

npm install --save @react-md/tooltip

It is also recommended to install the following packages as they work hand-in-hand with this package:

npm install --save @react-md/theme \
  @react-md/button

Documentation

You should check out the full documentation for live examples and more customization information, but an example usage is shown below.

Usage

import { render } from "react-dom";
import { Button } from "@react-md/button";
import { Tooltip, useTooltip } from "@react-md/tooltip";

function App() {
  const { elementProps, tooltipProps } = useTooltip({
    baseId: "button-id",
    onClick(event) {
      // an optional click handler for the button
    },
  });

  return (
    <>
      <Button {...elementProps}>Button Text</Button>
      <Tooltip {...tooltipProps}>I am a tooltip</Tooltip>
    </>
  );
}

render(<App />, document.getElementById("root"));

Dependents (15)

Package Sidebar

Install

npm i @react-md/tooltip

Weekly Downloads

1,315

Version

5.1.6

License

MIT

Unpacked Size

207 kB

Total Files

58

Last publish

Collaborators

  • mlaursen