{"id":13543216,"url":"https://github.com/romainberger/react-portal-tooltip","last_synced_at":"2025-10-06T12:56:40.940Z","repository":{"id":36066581,"uuid":"40365719","full_name":"romainberger/react-portal-tooltip","owner":"romainberger","description":"Awesome React tooltip","archived":false,"fork":false,"pushed_at":"2023-01-03T18:14:16.000Z","size":6401,"stargazers_count":407,"open_issues_count":53,"forks_count":73,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-09T05:45:04.980Z","etag":null,"topics":["react","reactjs","tooltip"],"latest_commit_sha":null,"homepage":"http://romainberger.github.io/react-portal-tooltip/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romainberger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-07T14:56:58.000Z","updated_at":"2025-04-17T00:57:11.000Z","dependencies_parsed_at":"2023-01-16T12:46:09.024Z","dependency_job_id":null,"html_url":"https://github.com/romainberger/react-portal-tooltip","commit_stats":null,"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainberger%2Freact-portal-tooltip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainberger%2Freact-portal-tooltip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainberger%2Freact-portal-tooltip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainberger%2Freact-portal-tooltip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romainberger","download_url":"https://codeload.github.com/romainberger/react-portal-tooltip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254453667,"owners_count":22073618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","reactjs","tooltip"],"created_at":"2024-08-01T11:00:26.385Z","updated_at":"2025-10-06T12:56:35.908Z","avatar_url":"https://github.com/romainberger.png","language":"JavaScript","funding_links":[],"categories":["UI Components","JavaScript","Demos","\u003csummary\u003eUI Components\u003c/summary\u003e"],"sub_categories":["Tooltip"],"readme":"# React Portal Tooltip \n\nAwesome tooltips.\n\n[![Build Status](https://img.shields.io/travis/romainberger/react-portal-tooltip/master.svg?style=flat-square)](https://travis-ci.org/romainberger/react-portal-tooltip) [![npm version](https://img.shields.io/npm/v/react-portal-tooltip.svg?style=flat-square)](https://www.npmjs.com/package/react-portal-tooltip)\n[![npm downloads](https://img.shields.io/npm/dm/react-portal-tooltip.svg?style=flat-square)](https://www.npmjs.com/package/react-portal-tooltip)\n\n![react tooltip](https://raw.githubusercontent.com/romainberger/react-portal-tooltip/master/react-portal-tooltip.gif)\n\n## Installation\n\n```shell\n$ npm install react-portal-tooltip\n```\n\n**Warning** The versions 2.x on npm are compatible with React 16. Corresponding versions for older versions of React:\n\n```shell\n# For react v15\n$ npm install react-portal-tooltip@1\n\n# For react 0.14\n$ npm install react-portal-tooltip@0.14\n\n# For react 0.13\n$ npm install react-portal-tooltip@0.13\n```\n\n## Documentation and demo\n\n[http://romainberger.github.io/react-portal-tooltip/](http://romainberger.github.io/react-portal-tooltip/)\n\n## Usage\n\n```javascript\nimport React from 'react'\nimport ToolTip from 'react-portal-tooltip'\n\nclass MyComponent extends React.Component {\n    state = {\n        isTooltipActive: false\n    }\n    showTooltip() {\n        this.setState({isTooltipActive: true})\n    }\n    hideTooltip() {\n        this.setState({isTooltipActive: false})\n    }\n    render() {\n        return (\n            \u003cdiv\u003e\n                \u003cp id=\"text\" onMouseEnter={this.showTooltip.bind(this)} onMouseLeave={this.hideTooltip.bind(this)}\u003eThis is a cool component\u003c/p\u003e\n                \u003cToolTip active={this.state.isTooltipActive} position=\"top\" arrow=\"center\" parent=\"#text\"\u003e\n                    \u003cdiv\u003e\n                        \u003cp\u003eThis is the content of the tooltip\u003c/p\u003e\n                        \u003cimg src=\"image.png\"/\u003e\n                    \u003c/div\u003e\n                \u003c/ToolTip\u003e\n            \u003c/div\u003e\n        )\n    }\n}\n```\n\n### Props\n\n* `active`: boolean, the tooltip will be visible if true\n* `position`: top, right, bottom or left. Default to right\n* `arrow`: center, right, left, top or bottom (depending on the position prop). No arrow when the prop is not sepecified\n* `align`: the alignment of the whole tooltip relative to the `parent` element. possible values : center, right, left. Default to center.\n* `tooltipTimeout`: timeout for the tooltip fade out in milliseconds. Default to 500\n* `parent`: the tooltip will be placed next to this element. Can be the id of the parent or the ref (see example below)\n* `group`: string, necessary if you want several independent tooltips\n* `style`: object, allows customizing the tooltip. Checkout the [example](https://github.com/romainberger/react-portal-tooltip/blob/master/example/src/style.js) for details.\n* `useHover` bool, default to true. If true, the tooltip will stay visible when hovered.\n\n### Parent prop\n\nYou can use an id or a ref to reference the parent:\n\n#### id\n\n```javascript\n\u003cdiv id=\"hoverMe\" onMouseEnter={this.showTooltip} onMouseLeave={this.hideTooltip}\u003e\n    Hover me!!!\n\u003c/div\u003e\n\u003cToolTip active={this.state.isTooltipActive} position=\"top\" arrow=\"center\" parent=\"#hoverMe\"\u003e\n    \u003cdiv\u003e\n        \u003cp\u003eThis is the content of the tooltip\u003c/p\u003e\n    \u003c/div\u003e\n\u003c/ToolTip\u003e\n```\n\n#### ref\n\n```javascript\n\u003cdiv ref={(element) =\u003e { this.element = element }} onMouseEnter={this.showTooltip} onMouseLeave={this.hideTooltip}\u003e\n    Hover me!!!\n\u003c/div\u003e\n\u003cToolTip active={this.state.isTooltipActive} position=\"top\" arrow=\"center\" parent={this.element}\u003e\n    \u003cdiv\u003e\n        \u003cp\u003eThis is the content of the tooltip\u003c/p\u003e\n    \u003c/div\u003e\n\u003c/ToolTip\u003e\n```\n\n### Stateful ToolTip\n\nIf you only use the Tooltip for mouse enter / mouse leave, you may not want to handle the state yourself for all elements. In this case, you can use the stateful version which will do it for you:\n\nImport the stateful version:\n\n```js\nimport { StatefulToolTip } from \"react-portal-tooltip\"\n```\n\nThen create your parent and give it as a prop to the Tooltip:\n\n```js\nconst button = \u003cspan\u003eHover me to display the tooltip\u003c/span\u003e\n\nreturn (\n  \u003cStatefulToolTip parent={ button }\u003e\n    Stateful Tooltip content here!\n  \u003c/StatefulToolTip\u003e\n)\n```\n\n`StatefulToolTip` takes the same props as `ToolTip`, plus a `className` prop that will be applied to the root element wrapping the parent ([see the example](https://github.com/romainberger/react-portal-tooltip/blob/master/example/src/stateful.js)).\n\n[See the example live](http://romainberger.github.io/react-portal-tooltip/#/stateful).\n\n## Development\n\n```shell\n# clone\n$ git clone git@github.com:romainberger/react-portal-tooltip.git\n\n# install the dependencies\n$ npm install\n\n# go to the example folder, then install more dependencies\n$ cd example \u0026\u0026 npm install\n\n# start the development server with hot reloading\n$ npm start\n\n# to build run this command from the root directory\n$ npm build\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromainberger%2Freact-portal-tooltip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromainberger%2Freact-portal-tooltip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromainberger%2Freact-portal-tooltip/lists"}