{"id":19777041,"url":"https://github.com/iqbal-rashed/outsideclick-react","last_synced_at":"2025-07-03T23:34:11.084Z","repository":{"id":62668682,"uuid":"560357200","full_name":"iqbal-rashed/outsideclick-react","owner":"iqbal-rashed","description":"This is a lightweight React package that provides a hook and component for detecting clicks outside of a specified element.","archived":false,"fork":false,"pushed_at":"2025-03-29T09:32:51.000Z","size":164,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-30T19:41:45.837Z","etag":null,"topics":["hook","outsideclick","react","react-component","react-hooks","reactjs"],"latest_commit_sha":null,"homepage":"https://github.com/iqbal-rashed/outsideclick-react","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/iqbal-rashed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2022-11-01T10:10:54.000Z","updated_at":"2025-03-29T09:32:55.000Z","dependencies_parsed_at":"2024-11-12T05:35:03.067Z","dependency_job_id":null,"html_url":"https://github.com/iqbal-rashed/outsideclick-react","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"6df0684d8d3bc7b31c09ce090069493b803ae125"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/iqbal-rashed/outsideclick-react","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqbal-rashed%2Foutsideclick-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqbal-rashed%2Foutsideclick-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqbal-rashed%2Foutsideclick-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqbal-rashed%2Foutsideclick-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iqbal-rashed","download_url":"https://codeload.github.com/iqbal-rashed/outsideclick-react/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iqbal-rashed%2Foutsideclick-react/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421504,"owners_count":23464013,"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":["hook","outsideclick","react","react-component","react-hooks","reactjs"],"created_at":"2024-11-12T05:22:55.290Z","updated_at":"2025-07-03T23:34:10.722Z","avatar_url":"https://github.com/iqbal-rashed.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/rashed.iqbal"],"categories":[],"sub_categories":[],"readme":"# OutSideClick React\n\n`outsideclick-react` is a lightweight React package that detects clicks outside a specified element, useful for dropdowns, modals, etc.\n\n## Installation\n\n```bash\nnpm install outsideclick-react\n```\n\nor\n\n```bash\nyarn add outsideclick-react\n```\n\n## Usage\n\n### Hook\n\n```javascript\nimport { useOutsideClick } from \"outsideclick-react\";\n\nfunction MyComponent() {\n  const handleOutsideClick = (e) =\u003e {\n    // Handle outside click\n  };\n  const ref = useOutsideClick(handleOutsideClick);\n  /* const ref = useOutsideClick(handleOutsideClick, \".ignore-element\") */\n  return \u003cdiv ref={ref}\u003e{/* Your component */}\u003c/div\u003e;\n}\n```\n\n### Component\n\n```javascript\nimport { OutsideClick } from \"outsideclick-react\";\n\nfunction MyComponent() {\n  return (\n    \u003cOutsideClick\n      onOutsideClick={() =\u003e {\n        // Handle outside click\n      }}\n      ignoreElement=\".ignore\"\n    \u003e\n      \u003cdiv\u003e{/* Your component */}\u003c/div\u003e\n    \u003c/OutsideClick\u003e\n  );\n}\n```\n\n## API\n\n### `useOutsideClick`\n\nA hook that detects clicks outside of a specified element.\n\n#### Parameters:\n\n- **outsideClick**: `(v: HTMLElement) =\u003e void` - A function that gets called when an outside click is detected.\n- **ignoreElement** (optional): `IgnoreElementType` - An element or selector that should be ignored when detecting outside clicks.\n\n#### Returns:\n\n- A `ref` object that should be attached to the target element.\n\n### `OutsideClick`\n\nA component that detects clicks outside of its children.\n\n#### Props:\n\n- `onOutsideClick`: Function that is called when an outside click is detected.\n- `ignoreElement`: An element or selector to ignore when detecting outside clicks.\n\n## Contribution\n\nIf you'd like to contribute, please submit a pull request.\n\n## Support\n\nIf you want to support my work, you can buy me a coffee!\n\n[![](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoffee.com/rashed.iqbal)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiqbal-rashed%2Foutsideclick-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiqbal-rashed%2Foutsideclick-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiqbal-rashed%2Foutsideclick-react/lists"}