{"id":25289012,"url":"https://github.com/chandrahaswtw/ellipsis-tooltip-react-chan","last_synced_at":"2025-06-23T08:36:26.608Z","repository":{"id":57222491,"uuid":"306696375","full_name":"chandrahaswtw/ellipsis-tooltip-react-chan","owner":"chandrahaswtw","description":"Hi there, this npm package helps in truncating the overflown text or inline element with ellipsis \u0026 shows tooltip on hover.","archived":false,"fork":false,"pushed_at":"2021-08-07T12:47:28.000Z","size":111,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-07T14:17:36.844Z","etag":null,"topics":["babel","react","react-tooltip","typescript","uuid","webpack"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ellipsis-tooltip-react-chan","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chandrahaswtw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-23T16:56:45.000Z","updated_at":"2024-04-15T22:00:50.000Z","dependencies_parsed_at":"2022-08-28T23:30:08.706Z","dependency_job_id":null,"html_url":"https://github.com/chandrahaswtw/ellipsis-tooltip-react-chan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandrahaswtw%2Fellipsis-tooltip-react-chan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandrahaswtw%2Fellipsis-tooltip-react-chan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandrahaswtw%2Fellipsis-tooltip-react-chan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chandrahaswtw%2Fellipsis-tooltip-react-chan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chandrahaswtw","download_url":"https://codeload.github.com/chandrahaswtw/ellipsis-tooltip-react-chan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238566066,"owners_count":19493408,"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":["babel","react","react-tooltip","typescript","uuid","webpack"],"created_at":"2025-02-12T23:27:47.471Z","updated_at":"2025-02-12T23:27:48.056Z","avatar_url":"https://github.com/chandrahaswtw.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ellipsis-tooltip-react-chan\n\n\u003e Hi there, this package helps in truncating the overflown text or inline element with ellipsis \u0026 shows tooltip on hover. It comes into effect only when the text is overflown, else it looks like a normal element. This is dynamic i.e., when screen is minimized, more elements get truncated \u0026 it dynamically show tooltips wherever necessary.\n This uses [react-tooltip](https://www.npmjs.com/package/react-tooltip) package to display truncated content \u0026 [uuid](https://www.npmjs.com/package/uuid) to generate unique id's for tooltips.  \n\n# DEMO\n**[CLICK HERE FOR THE DEMO](https://chandrahaswtw.github.io/ellipsis-tooltip-demo/)**\n\n\n## INSTALLATION\n\n```\nnpm install --save ellipsis-tooltip-react-chan\n```\n**NOTE**: Type definitions already included to work with typescript\n\n## USAGE\n\nAll we need is to wrap this with any element that has a fixed width. To configure the tooltip settings, it accepts ```options``` as prop. From the below example, ```place``` refers to place of tooltip. It can be ```left```,```right```,```top```,```bottom```. You can find more information about other options at \n[react-tooltip](https://www.npmjs.com/package/react-tooltip) documentation.\n\n**NOTE**: The effect works only if you pass direct text or any inline or inline-block elements as children. See the examples below:\n\n```\nimport React from 'react';\nimport './App.css';\nimport EllipsisToolTip from \"ellipsis-tooltip-react-chan\";\n\nfunction App() {\n\n  const options = {\n    effect: \"solid\",\n    place: \"top\"\n  }\n\n  return (\n    \u003cdiv style={{ width: \"50px\", margin: \"5rem\" }}\u003e\n      \u003cEllipsisToolTip options={options}\u003e\n         Lorem ipsum dolor sit amet consectetur adipisicing elit. Libero, fugiat.\n      \u003c/EllipsisToolTip\u003e\n    \u003c/div\u003e\n  );\n\n}\n\nexport default App;\n```\n### Span element\n\n```\n\u003cEllipsisToolTip options={options}\u003e\n   \u003cspan\u003e\n       Lorem ipsum dolor sit amet consectetur.\n   \u003c/span\u003e\n\u003c/EllipsisToolTip\u003e\n```\n### Anchor element\n\n```\n\u003cEllipsisToolTip options={options}\u003e\n  \u003ca href=\"\"\u003e\n    Lorem ipsum dolor sit amet consectetur\n  \u003c/a\u003e\n\u003c/EllipsisToolTip\u003e\n```\n\n### Table cell\nWhen you are explicitly adding the width to the columns, do not forget to apply ```table-layout: fixed``` as the table style.\n```\n\u003ctable style={{tableLayout : \"fixed\"}}\u003e\n  \u003ctr\u003e\n    \u003ctd style={{maxWidth : \"10vw\"}}\u003e\n      \u003cEllipsisToolTip options={options}\u003e\n        Lorem ipsum dolor sit amet consectetur\n      \u003c/EllipsisToolTip\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n```\nand etc.....\n\n## STYLES\n\nWhen it recieves children, it wraps around an       ```inline-block``` element to give the effect \u0026 ```inline-block``` elements have extra space around them. So, when placed in a table cell or CSS Grid, it gives a wired look. So we can pass style explicitly ```float:left``` as shown below to prevent this. Use this hack whenever necessary.\n\n```\n\u003ctr\u003e\n  \u003ctd style={{maxWidth : \"10vw\"}}\u003e\n    \u003cEllipsisToolTip style={{float: \"left\"}} options={options}\u003e\n      Lorem ipsum dolor sit amet consectetur\n    \u003c/EllipsisToolTip\u003e\n  \u003c/td\u003e\n\u003c/tr\u003e\n```\n\nBy default, the ```font``` is inherited. If we want to pass any extra styles, you can make use of ```style``` prop as shown above. This doesn't affect the tooltip styles but only the wrapper I mentioned. If you wish to change the tool tip styles, you need to send the ```className``` in ```options```. Go through the [react-tooltip](https://www.npmjs.com/package/react-tooltip) documentation for more information. I have briefly mentioned about styling the tooltip in my [DEMO](https://chandrahaswtw.github.io/ellipsis-tooltip-demo/) as well under TABLE/CSS GRID section. Have a look if necessary.\n\n\n## DYNAMIC TOOLTIP\n\nYou might run into an issue when there is state change and tool tips aren't diplaying properly, you might have to restart the react-toolip as below. \n\n```\nimport ReactTooltip from \"react-tooltip\";\n\nuseEffect(() =\u003e {\n        ReactTooltip.rebuild();\n},[pass dependency array]);\n```\n\n\n\n# FINAL NOTE\n\nI am extremely glad that you thought of using this package in you project. If you like my work, I would really appreciate if you provide a **star** on [github repo](https://github.com/chandrahaswtw/ellipsis-tooltip-react-chan). If you stumble across any issues, kindly raise an issue for the same.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandrahaswtw%2Fellipsis-tooltip-react-chan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchandrahaswtw%2Fellipsis-tooltip-react-chan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandrahaswtw%2Fellipsis-tooltip-react-chan/lists"}