{"id":17533008,"url":"https://github.com/dab0mb/babel-plugin-scoped-styled-components","last_synced_at":"2025-09-12T20:32:13.663Z","repository":{"id":66209432,"uuid":"169914390","full_name":"DAB0mB/babel-plugin-scoped-styled-components","owner":"DAB0mB","description":null,"archived":false,"fork":false,"pushed_at":"2019-02-09T22:22:08.000Z","size":94,"stargazers_count":13,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T08:23:28.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/DAB0mB.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":"2019-02-09T21:13:48.000Z","updated_at":"2022-01-29T09:12:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"6893eb8b-7560-4fe0-9dc0-7ee9203709e0","html_url":"https://github.com/DAB0mB/babel-plugin-scoped-styled-components","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"d92c688b7c6bd94c6ae5a3363e6e92bc1358a5e8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DAB0mB/babel-plugin-scoped-styled-components","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fbabel-plugin-scoped-styled-components","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fbabel-plugin-scoped-styled-components/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fbabel-plugin-scoped-styled-components/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fbabel-plugin-scoped-styled-components/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DAB0mB","download_url":"https://codeload.github.com/DAB0mB/babel-plugin-scoped-styled-components/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fbabel-plugin-scoped-styled-components/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274873284,"owners_count":25365823,"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-12T02:00:09.324Z","response_time":60,"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":[],"created_at":"2024-10-20T18:12:19.090Z","updated_at":"2025-09-12T20:32:13.398Z","avatar_url":"https://github.com/DAB0mB.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/DAB0mB/babel-plugin-scoped-styled-components/tree/master.svg?style=svg)](https://circleci.com/gh/DAB0mB/babel-plugin-scoped-styled-components/tree/master)\n\n# babel-plugin-scoped-styled-components\n\nRemoves the necessity for a dedicated styled component for every React element; instead, we can just use the `className` prop. See [example](#example) below.\n\n### Example\n\n#### old\n\n```jsx\nconst Button = styled.button `\n  border-radius: 999px;\n`\n\nconst RedButton = styled(Button) `\n  color: red;\n`\n\nconst GreenButton = styled(Button) `\n  color: green;\n`\n\nconst BlueButton = styled(Button) `\n  color: blue;\n`\n\nconst Dashboard = (\n  \u003cdiv\u003e\n    \u003cRedButton /\u003e\n    \u003cGreenButton /\u003e\n    \u003cBlueButton /\u003e\n  \u003c/div\u003e\n)\n```\n\n#### new\n\n```jsx\nconst DashboardStyle = styled.div `\n  ._btn {\n    border-radius: 999px;\n  }\n\n  ._red-btn {\n    color: red;\n  }\n\n  ._green-btn {\n    color: green;\n  }\n\n  ._blue-btn {\n    color: blue;\n  }\n`\n\nconst Dashboard = (\n  \u003cDashboardStyle\u003e\n    \u003cbutton className=\"_btn _red-btn\" /\u003e\n    \u003cbutton className=\"_btn _green-btn\" /\u003e\n    \u003cbutton className=\"_btn _blue-btn\" /\u003e\n  \u003c/DashboardStyle\u003e\n)\n```\n\n#### out\n\n```jsx\nconst DashboardStyle = styled.div `\n  .${props =\u003e props.__scopename}-btn {\n    border-radius: 999px;\n  }\n\n  .${props =\u003e props.__scopename}-red-btn {\n    color: red;\n  }\n\n  .${props =\u003e props.__scopename}-green-btn {\n    color: green;\n  }\n\n  .${props =\u003e props.__scopename}-blue-btn {\n    color: blue;\n  }\n`\n\nconst Dashboard = (\n  \u003cDashboardStyle __scopename=\"__scope0\"\u003e\n    \u003cbutton className=\"__scope0-red-btn\" /\u003e\n    \u003cbutton className=\"__scope0-green-btn\" /\u003e\n    \u003cbutton className=\"__scope0-blue-btn\" /\u003e\n  \u003c/DashboardStyle\u003e\n)\n```\n\n### Usage\n\n- ALWAYS use the `styled` identifier to declare styled components.\n- ALWAYS use the `Style` postfix for components that you would like to scope.\n- Use the `_` prefix for class names that you would like to encapsulate.\n\n### Installation\n\n`babel-plugin-scoped-styled-components` is installable via NPM (or Yarn):\n\n    $ npm install babel-plugin-scoped-styled-components\n\nAdd the plug-in to your `.babelrc`:\n\n```json\n{\n  \"plugins\": [\"babel-plugin-scoped-styled-components\"]\n}\n```\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdab0mb%2Fbabel-plugin-scoped-styled-components","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdab0mb%2Fbabel-plugin-scoped-styled-components","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdab0mb%2Fbabel-plugin-scoped-styled-components/lists"}