{"id":27316942,"url":"https://github.com/huwcarwyn/react-context-modals","last_synced_at":"2025-08-10T21:05:52.557Z","repository":{"id":35511982,"uuid":"217743444","full_name":"huwcarwyn/react-context-modals","owner":"huwcarwyn","description":"Add modals anywhere using a simple hook or context","archived":false,"fork":false,"pushed_at":"2024-10-01T14:06:54.000Z","size":1557,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-02T06:25:51.646Z","etag":null,"topics":["context-api","hooks","modals","react"],"latest_commit_sha":null,"homepage":"","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/huwcarwyn.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":"2019-10-26T17:16:52.000Z","updated_at":"2024-10-01T14:06:57.000Z","dependencies_parsed_at":"2024-10-13T09:30:25.422Z","dependency_job_id":"3b50d105-3392-4e02-9710-13ad2015f5c9","html_url":"https://github.com/huwcarwyn/react-context-modals","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.4444444444444444,"last_synced_commit":"9c1dc19a277ce82cb75754a8f50aff80e6474cdf"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huwcarwyn/react-context-modals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huwcarwyn%2Freact-context-modals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huwcarwyn%2Freact-context-modals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huwcarwyn%2Freact-context-modals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huwcarwyn%2Freact-context-modals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huwcarwyn","download_url":"https://codeload.github.com/huwcarwyn/react-context-modals/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huwcarwyn%2Freact-context-modals/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269787316,"owners_count":24475716,"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-10T02:00:08.965Z","response_time":71,"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":["context-api","hooks","modals","react"],"created_at":"2025-04-12T08:39:08.835Z","updated_at":"2025-08-10T21:05:52.532Z","avatar_url":"https://github.com/huwcarwyn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Context Modals\n\nReact Context Modals allows you to very easily add flexible modals to any project, any component can be turned into a modal. Can be used either via the context API or by using the hook.\n\n### Installation\n\n```\nnpm install --save react-context-modals\n```\n\nor\n\n```\nyarn add react-context-modals\n```\n\n### Setup\n\nTo set up the library - import the modal CSS (or optionally roll your own), then wrap your app in the ModalProvider like so:\n\n```\nimport { ModalProvider } from 'react-context-modals'\n\nimport 'react-context-modals/dist/main.css'\n\nexport const App = () =\u003e {\n    return (\n        \u003cModalProvider\u003e\n            // ...rest of your app\n        \u003c/ModalProvider\u003e\n    )\n}\n```\n\n### Usage\n\nWith hooks:\n\n```\nimport { useModal } from 'react-context-modals'\n\nconst BasicModal = ({ message }) =\u003e (\n    \u003cdiv\u003ethis is a very basic modal, with a message passed via props: {message}\u003c/div\u003e\n)\n\nconst Example = props =\u003e {\n    const { showModal, hideModal } = useModal()\n\n    const showBasicModal = () =\u003e showModal(BasicModal, {\n        message: 'This message will be passed to the modal component'\n    })\n\n    return (\n        \u003cbutton onClick={showBasicModal}\u003e\n            Open modal\n        \u003c/button\u003e\n    )\n}\n```\n\nWith class based components:\n\n```\nimport React, { Component } from 'react'\nimport { ModalConsumer } from 'react-context-modals'\n\nconst BasicModal = () =\u003e \u003cdiv\u003ethis is a very basic modal\u003c/div\u003e\n\nclass Example extends Component {\n    render() {\n        return (\n            \u003cModalConsumer\u003e\n                {({ showModal, hideModal }) =\u003e (\n                    \u003cbutton onClick={() =\u003e showModal(BasicModal)}\u003eOpen modal\u003c/button\u003e\n                )}\n            \u003c/ModalConsumer\u003e\n        )\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuwcarwyn%2Freact-context-modals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuwcarwyn%2Freact-context-modals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuwcarwyn%2Freact-context-modals/lists"}