{"id":13755488,"url":"https://github.com/trendmicro-frontend/react-portal","last_synced_at":"2025-09-04T14:32:28.078Z","repository":{"id":57167643,"uuid":"103390562","full_name":"trendmicro-frontend/react-portal","owner":"trendmicro-frontend","description":"React Portal component","archived":false,"fork":false,"pushed_at":"2023-09-22T14:09:39.000Z","size":1690,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-08-10T02:51:26.431Z","etag":null,"topics":["modals","popovers","portal","react"],"latest_commit_sha":null,"homepage":"https://trendmicro-frontend.github.io/react-portal","language":"JavaScript","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/trendmicro-frontend.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}},"created_at":"2017-09-13T11:17:54.000Z","updated_at":"2023-09-22T14:09:38.000Z","dependencies_parsed_at":"2024-01-17T15:04:23.021Z","dependency_job_id":"57b3c882-1185-46a2-9887-a2a94082daa6","html_url":"https://github.com/trendmicro-frontend/react-portal","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/trendmicro-frontend/react-portal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-portal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-portal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-portal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-portal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trendmicro-frontend","download_url":"https://codeload.github.com/trendmicro-frontend/react-portal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-portal/sbom","scorecard":{"id":897979,"data":{"date":"2025-08-11","repo":{"name":"github.com/trendmicro-frontend/react-portal","commit":"8e6f46e109e729bce710639d2c90a19343a94b80"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T14:27:41.226Z","repository_id":57167643,"created_at":"2025-08-24T14:27:41.226Z","updated_at":"2025-08-24T14:27:41.226Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273612667,"owners_count":25137010,"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-09-04T02:00:08.968Z","response_time":61,"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":["modals","popovers","portal","react"],"created_at":"2024-08-03T10:00:55.133Z","updated_at":"2025-09-04T14:32:27.579Z","avatar_url":"https://github.com/trendmicro-frontend.png","language":"JavaScript","funding_links":[],"categories":["Trend Micro"],"sub_categories":["React Components"],"readme":"# react-portal [![build status](https://travis-ci.org/trendmicro-frontend/react-portal.svg?branch=master)](https://travis-ci.org/trendmicro-frontend/react-portal) [![Coverage Status](https://coveralls.io/repos/github/trendmicro-frontend/react-portal/badge.svg?branch=master)](https://coveralls.io/github/trendmicro-frontend/react-portal?branch=master)\n\n[![NPM](https://nodei.co/npm/@trendmicro/react-portal.png?downloads=true\u0026stars=true)](https://nodei.co/npm/@trendmicro/react-portal/)\n\nReact Portal\n\nThe `portal` approach that transports its child into a new React component and attaches it to \u003cb\u003edocument.body\u003c/b\u003e. This is useful for modals or popovers.\n\nDemo: https://trendmicro-frontend.github.io/react-portal\n\n## Installation\n\n1. Install the latest version of [react](https://github.com/facebook/react) and [react-portal](https://github.com/trendmicro-frontend/react-portal):\n\n  ```\n  npm install --save react @trendmicro/react-portal\n  ```\n\n2. Install [react-portal](https://github.com/trendmicro-frontend/react-portal)` with \u003cb\u003e@trendmicro\u003c/b\u003e scope:\n\n  ```js\n  import Portal from '@trendmicro/react-portal';\n\n  // Use LegacyPortal if you need cross-frame rendering support.\n  import LegacyPortal from '@trendmicro/react-portal/LegacyPortal';\n  ```\n\n## Usage\n\n### Portal\n\n```jsx\n\u003cPortal\u003e\n    This text is transported to the end of document.body.\n\u003c/Portal\u003e\n\n\u003cPortal node={document.body \u0026\u0026 document.body.querySelector('#modal-container')}\u003e\n    This text is transported to a DOM element.\n\u003c/Portal\u003e\n```\n\n### LegacyPortal\n\n```jsx\n\u003cLegacyPortal\n    node={window.top.document \u0026\u0026 window.top.document.querySelector('#modal-container')}\n\u003e\n    This text is transported to a DOM element within the top window document.\n\u003c/LegacyPortal\u003e\n```\n\n## Examples\n\nWe recommend using [styled-components](https://github.com/styled-components/styled-components) to make style changes, like so:\n\n```js\nimport PropTypes from 'prop-types';\nimport styled, { keyframes } from 'styled-components';\n\nconst Overlay = styled.div`\n    position: fixed;\n    top: 0;\n    left: 0;\n    right: 0;\n    bottom: 0;\n    color: #fff;\n    background-color: rgba(0, 0, 0, .7);\n`;\n\nconst VerticallyCenter = styled.div`\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n`;\n\nconst fadeIn = keyframes`\n    from {\n        transform: scale(.25);\n        opacity: 0;\n    }\n    to {\n        transform: scale(1);\n        opacity: 1;\n    }\n`;\n\nconst fadeOut = keyframes`\n    from {\n        transform: scale(1);\n        opacity: 1;\n    }\n    to {\n        transform: scale(.25);\n        opacity: 0;\n    }\n`;\n\nconst Fade = styled.div`\n    display: inline-block;\n    visibility: ${props =\u003e (props.out ? 'hidden' : 'visible')};\n    animation: ${props =\u003e (props.out ? fadeOut : fadeIn)} ${props =\u003e (props.timeout / 1000).toFixed(2)}s linear;\n    transition: visibility ${props =\u003e (props.timeout / 1000).toFixed(2)}s linear;\n`;\nFade.propTypes = {\n    out: PropTypes.bool,\n    timeout: PropTypes.number\n};\nFade.defaultProps = {\n    out: false,\n    timeout: 150\n};\n```\n\nThen you can nest components in the following way:\n\n### Center Modal Vertically\n\n```jsx\n\u003cPortal\u003e\n    \u003cOverlay\u003e\n        \u003cVerticallyCenter\u003e\n            \u003cModal\u003e\n                Your modal content goes here\n            \u003c/Modal\u003e\n        \u003c/VeticallyCenter\u003e\n    \u003c/Overlay\u003e\n\u003c/Portal\u003e\n```\n\n### Fade-in Animation\n\n```jsx\n\u003cPortal\u003e\n    \u003cOverlay\u003e\n        \u003cVerticallyCenter\u003e\n            \u003cFade timeout={150}\u003e\n                \u003cModal\u003e\n                    Your modal content goes here\n                \u003c/Modal\u003e\n            \u003c/Fade\u003e\n        \u003c/VeticallyCenter\u003e\n    \u003c/Overlay\u003e\n\u003c/Portal\u003e\n```\n\n## Fullscreen Modal From Within an Iframe\n\n#### Transport children to a DOM element within the top window document\n\n```jsx\n\u003cLegacyPortal\n    node={window.top.document \u0026\u0026 window.top.document.querySelector('#modal-container')}\n\u003e\n    \u003cOverlay\u003e\n        \u003cFade timeout={150}\u003e\n            \u003cModal\u003e\n                Your modal content goes here\n            \u003c/Modal\u003e\n        \u003c/Fade\u003e\n    \u003c/Overlay\u003e\n\u003c/LegacyPortal\u003e\n```\n\n#### Implement a `persistStyles()` function to synchronize style changes\n\n```js\npersistStyles = () =\u003e {\n    const parent = window.top;\n    if (parent === window) {\n        return;\n    }\n\n    const parentDocument = parent.document;\n    const parentHead = parentDocument.getElementsByTagName('head')[0];\n\n    const parentStyles = Array.prototype.slice.call(parentDocument.getElementsByTagName('style') || []);\n    parentStyles.forEach(style =\u003e {\n        if (style.getAttribute('data-cloned')) {\n            style.parentNode.removeChild(style);\n        }\n    });\n\n    const now = Date.now();\n    const styles = document.getElementsByTagName('style');\n    for (let i = 0; i \u003c styles.length; ++i) {\n        const style = styles[i].cloneNode(true);\n        style.setAttribute('data-cloned', true);\n        style.setAttribute('data-ctime', now);\n        parentHead.appendChild(style);\n    }\n};\n```\n\n#### Use a mutation observer to observe style changes\n\n```js\nconst target = document.head;\nconst config = {\n    attributes: true,\n    attributeOldValue: false,\n    characterData: true,\n    characterDataOldValue: false,\n    childList: true,\n    subtree: true\n};\nthis.observer = new MutationObserver(mutations =\u003e {\n    this.persistStyles();\n});\nthis.observer.observe(target, config);\n```\n\nSee a complete example at https://github.com/trendmicro-frontend/react-portal/blob/master/examples/iframe.jsx\n\n\n## API\n\n### Properties\n\n#### Portal\n\nName | Type | Default | Description\n:--- | :--- | :------ | :----------\nnode | DOM node | document.body | A root DOM node to render a React element.\n\n#### LegacyPortal\n\nName | Type | Default | Description\n:--- | :--- | :------ | :----------\nnode | DOM node | document.body | A root DOM node to render a React element.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrendmicro-frontend%2Freact-portal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrendmicro-frontend%2Freact-portal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrendmicro-frontend%2Freact-portal/lists"}