
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-path-tooltip
Advanced tools
A simple yet beautiful react tooltip component for SVG-Paths. The component detects the SVG and Path locations/sizes. The component also detects the display text width of the tooltip. Based on that information a calculation is done so that the rendering of the tooltip will be optimized and correctly oriented.
Note: When generating SVG with multiple paths, make sure to add the tooltips at the bottom of the SVG element, after all the paths are already displays.
In order to install, run the following command:
$ npm install react-path-tooltip --save
A very simple `App.tsx' example:
import React from "react"
import "./App.css"
import { PathTooltip } from "ReactPathTooltip" // import the package
function App() {
const svgRef = React.createRef<SVGSVGElement>()
const pathRef = React.createRef<SVGCircleElement>()
return (
< div className="App" >
< div className="Main">
<svg width="400" height="400" ref={svgRef}>
<circle cx={50} cy={50} r={50} fill="red" ref={pathRef} />
<PathTooltip svgRef={svgRef} pathRef={pathRef} tip="Hello World!" />
</svg>
</div>
</div>
)
}
export default App
The following parameters are passed to the tooltip component:
Prop | Type | Description |
---|---|---|
tip | string | Mandatory. The text to be displayed inside the tooltip |
svgRef | React.RefObject | Mandatory. A React reference object to the SVG element |
pathRef | React.RefObject | Mandatory. A React reference object to the path element bounded to the tooltip |
bgColor | string | Optional. Background color. Default: "black" |
textColor | string | Optional. Text color. Default: "white" |
fontFamily | string | Optional. The font family. Default: san-serif |
fontSize | number | Optional. The font size. Default 12 |
Notes:
tip
must include simple text. No new lines, or html decoration.pathRef
must be a valid reference to a path element. There are a number of such types such as SVGRectElement, SVGCircleElement, etc.MIT
1.0.15
FAQs
A tooltip for SVG paths in React
The npm package react-path-tooltip receives a total of 5,643 weekly downloads. As such, react-path-tooltip popularity was classified as popular.
We found that react-path-tooltip demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.