{"id":21580573,"url":"https://github.com/imp-dance/native-popover-react","last_synced_at":"2025-03-18T08:12:31.038Z","repository":{"id":236356554,"uuid":"792441454","full_name":"imp-dance/native-popover-react","owner":"imp-dance","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-23T14:34:49.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T14:42:03.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/imp-dance.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-26T17:14:04.000Z","updated_at":"2024-09-23T14:34:54.000Z","dependencies_parsed_at":"2024-04-26T18:31:00.455Z","dependency_job_id":"e50bd28e-efc5-440a-9082-c363b559ba65","html_url":"https://github.com/imp-dance/native-popover-react","commit_stats":null,"previous_names":["imp-dance/native-popover-react"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fnative-popover-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fnative-popover-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fnative-popover-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fnative-popover-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imp-dance","download_url":"https://codeload.github.com/imp-dance/native-popover-react/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244181387,"owners_count":20411604,"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":[],"created_at":"2024-11-24T14:09:00.441Z","updated_at":"2025-03-18T08:12:30.998Z","avatar_url":"https://github.com/imp-dance.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# native-popover-react\n\n\u003e Utilize the [native web Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) in React\n\n```tsx\nimport { NativePopover } from \"native-popover-react\";\n\nfunction App() {\n  return (\n    \u003cNativePopover\n      trigger={(props) =\u003e (\n        \u003cbutton {...props}\u003eOpen tooltip\u003c/button\u003e\n      )}\n      popover={(props) =\u003e (\n        \u003cdiv {...props} className=\"my-popover\"\u003e\n          Popover content\n        \u003c/div\u003e\n      )}\n    /\u003e\n  );\n}\n```\n\n## Controls\n\n```tsx\nimport {\n  NativePopover,\n  usePopoverControls,\n} from \"native-popover-react\";\n\nfunction App() {\n  const popover = usePopoverControls\u003cHTMLDivElement\u003e();\n\n  return (\n    \u003cdiv\u003e\n      \u003cbutton onClick={popover.toggle}\u003e\n        {popover.isOpen ? \"Close popover\" : \"Open popover\"}\n      \u003c/button\u003e\n      \u003cNativePopover\n        control={popover.control}\n        popover={(props) =\u003e (\n          \u003cdiv {...props} className=\"my-popover\"\u003e\n            Popover content\n          \u003c/div\u003e\n        )}\n      /\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n### Closing popover\n\nYou can close the popover using `usePopoverControls`, or by utilizing the second argument in the `popover` prop to create a close button:\n\n```tsx\n\u003cNativePopover\n  trigger={(props) =\u003e \u003cbutton {...props}\u003eToggle\u003c/button\u003e}\n  popover={(props, closeProps) =\u003e (\n    \u003cdiv {...props} className=\"my-popover\"\u003e\n      Popover content\n      \u003cbutton {...closeProps}\u003eX\u003c/button\u003e\n    \u003c/div\u003e\n  )}\n/\u003e\n```\n\n## Anchoring\n\n\u003e [!WARNING]  \n\u003e **Experimental**: This might not be supported in all modern browsers yet.\n\nEnable an [anchor](https://developer.chrome.com/blog/introducing-popover-api#anchor_positioning) between `trigger` and `popover`.\n\n```tsx\nimport { NativePopover } from \"native-popover-react\";\n\nfunction App() {\n  return (\n    \u003cdiv\u003e\n      \u003cNativePopover\n        anchor={{\n          top: \"bottom\", // top of popover aligned to bottom of trigger\n          left: \"right\", // left of popover aligned to right of trigger\n        }}\n        trigger={(props) =\u003e \u003cbutton {...props}\u003eToggle\u003c/button\u003e}\n        popover={(props) =\u003e (\n          \u003cdiv {...props}\u003ePopover content\u003c/div\u003e\n        )}\n      /\u003e\n    \u003c/div\u003e\n  );\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimp-dance%2Fnative-popover-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimp-dance%2Fnative-popover-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimp-dance%2Fnative-popover-react/lists"}