{"id":25647112,"url":"https://github.com/marouanekadiri/react-relative-container","last_synced_at":"2026-05-08T07:32:16.523Z","repository":{"id":57343447,"uuid":"312317847","full_name":"marouanekadiri/react-relative-container","owner":"marouanekadiri","description":"This repository allows you to build responsive components that adapt its style and content based on the size of its container.","archived":false,"fork":false,"pushed_at":"2020-11-16T13:04:37.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-22T10:39:22.520Z","etag":null,"topics":["container-query","css","reactjs","responsive","styled-components"],"latest_commit_sha":null,"homepage":"","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/marouanekadiri.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}},"created_at":"2020-11-12T15:29:22.000Z","updated_at":"2020-11-16T13:04:40.000Z","dependencies_parsed_at":"2022-09-12T07:00:27.387Z","dependency_job_id":null,"html_url":"https://github.com/marouanekadiri/react-relative-container","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/marouanekadiri/react-relative-container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marouanekadiri%2Freact-relative-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marouanekadiri%2Freact-relative-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marouanekadiri%2Freact-relative-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marouanekadiri%2Freact-relative-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marouanekadiri","download_url":"https://codeload.github.com/marouanekadiri/react-relative-container/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marouanekadiri%2Freact-relative-container/sbom","scorecard":{"id":620992,"data":{"date":"2025-08-11","repo":{"name":"github.com/marouanekadiri/react-relative-container","commit":"e8cecbcb545c397fb3922fbc83dd3bbe870f7574"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/marouanekadiri/react-relative-container/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/marouanekadiri/react-relative-container/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/marouanekadiri/react-relative-container/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/marouanekadiri/react-relative-container/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/marouanekadiri/react-relative-container/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/marouanekadiri/react-relative-container/test.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   3 out of   3 npmCommand dependencies pinned"],"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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/20 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":"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":"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":"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":"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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"Vulnerabilities","score":0,"reason":"18 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T05:13:08.607Z","repository_id":57343447,"created_at":"2025-08-21T05:13:08.607Z","updated_at":"2025-08-21T05:13:08.607Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32770999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T02:36:36.067Z","status":"ssl_error","status_checked_at":"2026-05-08T02:36:07.210Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["container-query","css","reactjs","responsive","styled-components"],"created_at":"2025-02-23T11:18:42.134Z","updated_at":"2026-05-08T07:32:15.924Z","avatar_url":"https://github.com/marouanekadiri.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **React Relative Container**\n\nMake your component responsive everywhere.\n\nThis repository allows you to build responsive components that adapt its style and content based on the size of its container.\n\n## Installation\n```sh\n  npm i -s react-relative-container\n```\n\n## Demo\n[See examples](https://codesandbox.io/s/react-relative-container-ymihr)\n\n## Usage\n\nMake sure you have forwarded ref to a specific dom element that you want to observe its size change\n```jsx\nconst Parent = React.forwardRef((props, ref) =\u003e (\u003cdiv ref={ref} {...props} /\u003e)\n```\n\nWrap the container that you want to observe\n```jsx\nimport { RelativeContainer } from 'react-relative-container'\n\nconst Container = RelativeContainer(Parent)\n```\n\nDefine your custom breakpoints that you want your component to change when we have\n```jsx\nconst S = ({ width }) =\u003e width \u003c 400\nconst M = ({ width }) =\u003e width \u003c 700 \u0026\u0026 width \u003e= 400\nconst L = ({ width }) =\u003e width \u003c 1000 \u0026\u0026 width \u003e= 700\n```\n\nLet say this is your child component\n```jsx\nconst Child = props =\u003e {\n  return S(props.rcsize) ? \n          \u003cdiv\u003ei'm small\u003c/div\u003e \n            : \n          \u003cdiv\u003ei'm medium or large\u003c/div\u003e\n}\n```\n\nApply breakpoints to your child components\n```jsx\nimport { ObserveRCSizeOn } from 'react-relative-container'\n\nconst ResponsiveChild = ObserveRCSizeOn(S)(Child) // You can listen to S only\n// or\nconst ResponsiveChild = ObserveRCSizeOn(S, M)(Child) // You can listen to S and M only\n// or\nconst ResponsiveChild = ObserveRCSizeOn(S, M, L)(Child) // You can listen to S, M and L\n```\n\nNow all together\n\n```jsx\nconst Example = () =\u003e {\n  return (\n    \u003cContainer\u003e\n      \u003cResponsiveChild /\u003e\n    \u003c/Container\u003e\n  )\n}\n\n// Or\nconst Example = () =\u003e {\n  return (\n    \u003cContainer\u003e\n      \u003cdiv\u003e\n        \u003cResponsiveChild /\u003e\n      \u003c/div\u003e\n      \u003cResponsiveChild /\u003e\n    \u003c/Container\u003e\n  )\n}\n// They both observe size changes of the container\n```\n\n## Usage with `styled-components`\nThis library provides some api to easily work with styled component\n```jsx\nimport { styledRCMatches } from 'react-relative-container'\n\n// Wrap your container with your styled container\nconst Container = RelativeContainer(\n  styled.div``\n)\n\n// breakpoint conditions\nconst S = ({ width }) =\u003e width \u003c 200\nconst M = ({ width }) =\u003e width \u003c 300\nconst L = ({ width }) =\u003e width \u003c 400\n\n// Your responsive child\nconst ResponsiveChild = ObserveRCSizeOn(S, M, L)(\n  styled.div`\n    background-color: grey;\n    ${styledRCMatches(L)(\n      css`\n        background-color: yellow;\n        font-size: 16px;\n      `\n    )}\n    ${styledRCMatches(M)(\n      css`\n        background-color: yellow;\n        font-size: 16px;\n      `\n    )}\n    ${styledRCMatches(S)(\n      css`\n        background-color: blue;\n        font-size: 10px;\n      `\n    )}\n  `\n  )\n\n// This could be your component\nconst Example = () =\u003e {\n  return (\n    \u003cContainer\u003e\n      \u003cResponsiveChild\u003eHello world\u003c/ResponsiveChild\u003e\n    \u003c/Container\u003e\n  )\n}\n```\n\nLets assume we have a Page that is like this\n```jsx\n\nconst grow = keyframes`\n  from {\n    width: 100px\n  }\n  to {\n    width: 500px;\n  }\n`\n\nconst PageContainer = styled.div`\n  width: 500px;\n  animation: ${grow} linear 1s;\n`\n\nconst Page = () =\u003e {\n return (\n   \u003cPageContainer\u003e\n      \u003cExample /\u003e\n   \u003c/PageContainer\u003e\n )\n}\n```\n\n**Results**\n\n![Styled component example](https://user-images.githubusercontent.com/15144618/99157663-40a98480-26cb-11eb-92ec-c5e7736e7a96.gif)\n\n## API Documentation\nWIP\n\n## Contributing\n\nContributions are welcomed!\n\n## Licensing\n\nThis project is licensed under the MIT License. See [LICENSE](LICENSE) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarouanekadiri%2Freact-relative-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarouanekadiri%2Freact-relative-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarouanekadiri%2Freact-relative-container/lists"}