0.0.7 • Published 7 months ago

react-sketch-tooltip v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-sketch-tooltip

A customizable sketch-style tooltip for React, inspired by comic-style speech bubbles. Easily add fun and engaging tooltips to your web application!

Features

  • Comic-Style Speech Bubbles: Rounded or pointed borders for a playful look.
  • Tail Positioning: Adjustable tail positions (top, bottom, left, right).
  • Themes and Colors: With roughjs, you can effortlessly create unique balloon-shaped tooltips by leveraging its wide range of customizable styles!
  • Hover Interaction: Tooltips appear on hover.
  • HTML Content Support: Supports not only text but also images, links, and other HTML content.
  • Resizable: Fixed size can be set for tooltips.

Installation

Install the package via npm:

npm install react-sketch-tooltip

Usage

Here’s a basic example to get you started:

import React from "react";
import SketchTooltip from "react-sketch-tooltip";
import "react-sketch-tooltip/react-sketch-tooltip.css"; // You must import the CSS file!

const App = () => {
  return (
    <div>
      <SketchTooltip
        content={<div>Here’s a cool tooltip!</div>}
        position="top"
        // Customize the size of the tooltip here!
        size={{
          width: 100,
          height: 20,
          tailWidth: 20,
          tailHeight: 30,
          cornerCurve: 50,
        }}
        // you can customize tooltips
        // using the various styles provided by roughjs!
        styleOptions={{
          roughness: 3,
          stroke: "skyBlue",
          fill: "skyBlue",
          fillStyle: "zigzag",
          strokeWidth: 4,
          hachureGap: 3,
        }}
      >
        <button>Hover me!</button>
      </SketchTooltip>
    </div>
  );
};

export default App;

Props

PropTypeDefaultRequiredDescription
contentstring ReactNode-YesThe content to display inside the tooltip.
childrenReactNode-YesThe markup element to display the tooltip.
positiontop bottom left righttopYesPosition of the tooltip tail.
sizeObject-YesTooltip size.
widthnumber100NoWidth of the tooltip.
heightnumber20NoHeight of the tooltip.
tailWidthnumber20NoWidth of the tooltip's tail.
tailHeightnumber30NoHeight of the tooltip's tail.
cornerCurvenumber50NoRadius of the tooltip's corner curve.
leftCanvasMarginnumber5NoLeft margin of the tooltip's canvas.
topCanvasMarginnumber5NoTop margin of the tooltip's canvas.
styleOptions{ [key: string]: unknown }{}NoCustom styles for the tooltip.

Contributing

We welcome contributions to enhance react-sketch-tooltip. If you have any ideas or find a bug, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

If you have questions or need help, feel free to reach out or open an issue on the GitHub repository.

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago

0.0.0

7 months ago