{"id":30068615,"url":"https://github.com/graphieros/ez-tip","last_synced_at":"2025-08-24T04:17:48.584Z","repository":{"id":290210287,"uuid":"973721647","full_name":"graphieros/ez-tip","owner":"graphieros","description":"A lightweight, zero-dependency JavaScript tooltip library that uses CSS custom properties for full styling flexibility. Tooltips can be triggered on hover or displayed permanently, with configurable delay, offset, and positioning.","archived":false,"fork":false,"pushed_at":"2025-05-03T13:51:12.000Z","size":115,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T16:37:06.661Z","etag":null,"topics":["javascript","tooltip"],"latest_commit_sha":null,"homepage":"https://ez-tip.graphieros.com/","language":"TypeScript","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/graphieros.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-27T15:47:28.000Z","updated_at":"2025-05-29T09:16:43.000Z","dependencies_parsed_at":"2025-04-27T15:52:28.164Z","dependency_job_id":"8fab1c95-2c93-4256-8c00-5008e28dd0e7","html_url":"https://github.com/graphieros/ez-tip","commit_stats":null,"previous_names":["graphieros/ez-tip"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/graphieros/ez-tip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphieros%2Fez-tip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphieros%2Fez-tip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphieros%2Fez-tip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphieros%2Fez-tip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphieros","download_url":"https://codeload.github.com/graphieros/ez-tip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphieros%2Fez-tip/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269410055,"owners_count":24412147,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript","tooltip"],"created_at":"2025-08-08T10:46:15.581Z","updated_at":"2025-08-08T10:46:17.856Z","avatar_url":"https://github.com/graphieros.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ez-tip\n\n[![npm](https://img.shields.io/npm/v/ez-tip)](https://github.com/graphieros/ez-tip)\n[![GitHub issues](https://img.shields.io/github/issues/graphieros/ez-tip)](https://github.com/graphieros/ez-tip/issues)\n[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/graphieros/ez-tip?tab=MIT-1-ov-file#readme)\n[![npm](https://img.shields.io/npm/dt/ez-tip)](https://github.com/graphieros/ez-tip)\n\nA lightweight, zero-dependency JavaScript tooltip library that uses CSS custom properties for full styling flexibility. Tooltips can be triggered on hover or displayed permanently, with configurable delay, offset, and positioning.\n\n[DEMO](https://ez-tip.graphieros.com)\n\n## Features\n\n- **Easy to integrate:** Just import the JS and call `render()`\n- **CSS variables for styling:** Customize colors, padding, radii, and offsets without touching the JS\n- **Configurable delay:** Set a show delay per-instance or globally\n- **Smart positioning:** Automatically chooses the best placement (`top`, `bottom`, `left`, `right`) or honors your preference\n- **Auto-update:** Repositions on scroll/resize/element resize\n- **Auto-cleanup:** Removes tooltips when their target elements are removed from the DOM\n\n## Installation\n\nInstall via npm/yarn:\n\n```bash\nnpm install ez-tip\n# or\nyarn add ez-tip\n```\n\n\u003e **Note:** This library ships only JS. You must provide minimal CSS in your project to style the tooltip using the CSS variables defined below.\n\n## Quick Start\n\n1. **Import and call `render()`**\n\n   ```js\n   import { render } from \"ez-tip\";\n\n   // Optional: pass a global debounce delay (ms) for repositioning\n   render({ delay: 100 });\n   ```\n\n2. **Add `data-ez-tip` to any element**\n\n   ```html\n   \u003cbutton data-ez-tip=\"Hello, world!\"\u003eHover me\u003c/button\u003e\n   ```\n\n3. **Provide CSS to style the tooltip**\n\n   ```css\n   /* e.g. in your global stylesheet */\n   :root {\n     --tooltip-arrow-size: 6px;\n   }\n\n   .ez-tip {\n     background-color: var(--ez-tooltip-background-color);\n     color: var(--ez-tooltip-color);\n     padding: var(--ez-tooltip-padding);\n     border-radius: var(--ez-tooltip-border-radius);\n     opacity: 0;\n     transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n   }\n\n   .ez-tip.ez-tip-visible {\n     opacity: 1;\n   }\n\n   .ez-tip::after {\n     content: \"\";\n     position: absolute;\n     width: 0;\n     height: 0;\n     border-style: solid;\n   }\n\n   /* ─── TOP placement ───\n    Tooltip sits above the element,\n    arrow on the bottom edge pointing DOWN toward the element */\n   .ez-tip[data-position=\"top\"]::after {\n     bottom: calc(-1 * var(--tooltip-arrow-size));\n     left: 50%;\n     transform: translateX(-50%);\n     border-width: var(--tooltip-arrow-size) var(--tooltip-arrow-size) 0 var(--tooltip-arrow-size);\n     border-color: var(--ez-tooltip-background-color) transparent transparent transparent;\n   }\n\n   /* ─── BOTTOM placement ───\n    Tooltip sits below the element,\n    arrow on the top edge pointing UP toward the element */\n   .ez-tip[data-position=\"bottom\"]::after {\n     top: calc(-1 * var(--tooltip-arrow-size));\n     left: 50%;\n     transform: translateX(-50%);\n     border-width: 0 var(--tooltip-arrow-size) var(--tooltip-arrow-size) var(--tooltip-arrow-size);\n     border-color: transparent transparent var(--ez-tooltip-background-color) transparent;\n   }\n\n   /* ─── LEFT placement ───\n    Tooltip sits to the left of the element,\n    arrow on the right edge pointing RIGHT toward the element */\n   .ez-tip[data-position=\"left\"]::after {\n     right: calc(-1 * var(--tooltip-arrow-size));\n     top: 50%;\n     transform: translateY(-50%);\n     border-width: var(--tooltip-arrow-size) 0 var(--tooltip-arrow-size) var(--tooltip-arrow-size);\n     border-color: transparent transparent transparent var(--ez-tooltip-background-color);\n   }\n\n   /* ─── RIGHT placement ───\n    Tooltip sits to the right of the element,\n    arrow on the left edge pointing LEFT toward the element */\n   .ez-tip[data-position=\"right\"]::after {\n     left: calc(-1 * var(--tooltip-arrow-size));\n     top: 50%;\n     transform: translateY(-50%);\n     border-width: var(--tooltip-arrow-size) var(--tooltip-arrow-size) var(\n         --tooltip-arrow-size\n       ) 0;\n     border-color: transparent var(--ez-tooltip-background-color) transparent transparent;\n   }\n   ```\n\n## API\n\n### `render(options?: EzTipOptions)`\n\nInitializes tooltips for all elements with `data-ez-tip`. The library listens to the ready state of the dom.\n\n- `options.delay?` — **number**\n  - Global debounce delay (in ms) for repositioning on scroll/resize.\n  - Default: `0`\n\n```ts\ninterface EzTipOptions {\n  delay?: number;\n}\n```\n\n## Configuration\n\nBefore or after calling `render()`, you can override default styles globally by setting CSS variables on the `\u003cbody\u003e` (or any ancestor):\n\n| Variable                        | Default    | Description                     |\n| ------------------------------- | ---------- | ------------------------------- |\n| `--ez-tooltip-background-color` | `#FFFFFF`  | Tooltip background color        |\n| `--ez-tooltip-color`            | `#1A1A1A`  | Tooltip text color              |\n| `--ez-tooltip-padding`          | `0 0.5rem` | Tooltip padding (CSS shorthand) |\n| `--ez-tooltip-border-radius`    | `3px`      | Tooltip border radius           |\n\n```js\n// in JS before `render()` or anytime later\ndocument.body.style.setProperty(\"--ez-tooltip-background-color\", \"#222\");\ndocument.body.style.setProperty(\"--ez-tooltip-offset\", \"12px\");\n```\n\n```js\n// or import the config object and change the values directly:\n\nimport { render, config } from \"ez-tip\";\n\nconfig.backgroundColor = \"#E1E5E8\";\nconfig.color = \"#4A4A4A\";\nconfig.padding = \"0 0.5rem\";\nconfig.borderRadius = \"5px\";\n```\n\n## Data Attributes\n\n| Attribute                   | Type                          | Default | Description                                                                        |\n| --------------------------- | ----------------------------- | ------- | ---------------------------------------------------------------------------------- |\n| `data-ez-tip`               | string                        | **—**   | **Required.** HTML content or text for the tooltip.                                |\n| `data-ez-tip-hover`         | `true` or `false`             | `true`  | If `false`, tooltip is always visible; if `true` (or absent), shows on hover only. |\n| `data-ez-tip-delay`         | number (ms)                   | `0`     | Milliseconds to wait after hover before showing the tooltip.                       |\n| `data-ez-tip-position`      | `top`,`bottom`,`left`,`right` |         | Preferred placement; library will auto-fallback to best-fit if it doesn’t fit.     |\n| `data-ez-tip-background`    | string                        |         | Force background color for a single tooltip                                        |\n| `data-ez-tip-color`         | string                        |         | Force text color for a single tooltip                                              |\n| `data-ez-tip-padding`       | string                        |         | Force padding for a single tooltip                                                 |\n| `data-ez-tip-border-radius` | string                        |         | Force border-radius for a single tooltip                                           |\n\n```html\n\u003cbutton\n  data-ez-tip=\"Detailed info\"\n  data-ez-tip-hover=\"true\"\n  data-ez-tip-delay=\"300\"\n  data-ez-tip-offset=\"10\"\n  data-ez-tip-position=\"bottom\"\n\u003e\n  Show at bottom on hover with a 300ms delay\n\u003c/button\u003e\n```\n\n## Examples\n\n### Basic tooltip\n\n```html\n\u003cbutton data-ez-tip=\"Simple tooltip\"\u003eHover me\u003c/button\u003e\n```\n\n### Tooltip with delay and custom offset\n\n```html\n\u003cbutton data-ez-tip=\"Delayed\" data-ez-tip-delay=\"500\" data-ez-tip-offset=\"16\"\u003e\n  Delayed tooltip\n\u003c/button\u003e\n```\n\n### Always-visible tooltip\n\n```html\n\u003cp data-ez-tip=\"Persistent\" data-ez-tip-hover=\"false\"\u003ePersistent tooltip\u003c/p\u003e\n```\n\n## Cleanup\n\nTooltips auto-remove themselves if their target element is removed from the DOM—no memory leaks or orphan nodes.\n\n## License\n\nMIT © Alec Lloyd Probert\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphieros%2Fez-tip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphieros%2Fez-tip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphieros%2Fez-tip/lists"}