{"id":13437963,"url":"https://github.com/RickWong/react-inline-css","last_synced_at":"2025-03-19T18:31:15.706Z","repository":{"id":17129618,"uuid":"19895886","full_name":"RickWong/react-inline-css","owner":"RickWong","description":"🌳 Write CSS inside your React components!","archived":false,"fork":false,"pushed_at":"2020-05-01T04:19:43.000Z","size":5201,"stargazers_count":169,"open_issues_count":16,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-19T03:49:47.065Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RickWong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-17T20:45:35.000Z","updated_at":"2024-09-02T11:26:41.000Z","dependencies_parsed_at":"2022-08-24T13:00:27.351Z","dependency_job_id":null,"html_url":"https://github.com/RickWong/react-inline-css","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickWong%2Freact-inline-css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickWong%2Freact-inline-css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickWong%2Freact-inline-css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickWong%2Freact-inline-css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RickWong","download_url":"https://codeload.github.com/RickWong/react-inline-css/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221588977,"owners_count":16848430,"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-07-31T03:01:01.747Z","updated_at":"2024-10-27T20:30:54.025Z","avatar_url":"https://github.com/RickWong.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","Code Design"],"sub_categories":["Uncategorized","CSS / Style"],"readme":"![screenshot](https://i.imgur.com/7Pop4SZ.png?1)\n\n# React Inline CSS\n\nMake your React components visually predictable. React Inline CSS allows you to write traditional CSS stylesheets in your components, automatically namespacing them for you.\n\nInspired by the [SUIT CSS](https://suitcss.github.io/) methodology.\n\n## Demo\n\n[Mao-mao-mao!](https://edealer.nl/mao)\n\n## Example\n\nYou write:\n\n```javascript\nvar Profile = React.createClass({\n\trender: function () {\n\t\treturn (\n\t\t\t\u003cInlineCss stylesheet={`\n\t\t\t\t\u0026 .card {\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\tmargin: 15px;\n\t\t\t\t\tpadding: 15px;\n\t\t\t\t\ttext-align: center;\n\t\t\t\t\theight: 200px;\n\t\t\t\t}\n\t\t\t\t\u0026 img {\n\t\t\t\t\twidth: 130px;\n\t\t\t\t\theight: 130px;\n\t\t\t\t}\n\t\t\t\t\u0026 p {\n\t\t\t\t\tmargin: 10px;\n\t\t\t\t}\n\t\t\t\t`}\u003e\n\t\t\t\t\u003cdiv className=\"card\"\u003e\n\t\t\t\t\t\u003cimg src=\"mao.jpg\" /\u003e\n\t\t\t\t\t\u003cp\u003eMao\u003c/p\u003e\n\t\t\t\t\u003c/div\u003e\n\t\t\t\u003c/InlineCss\u003e\n\t\t);\n\t}\n});\n```\n\nYou get namespaced CSS that works on sub-components (comparable to HTML5 `\u003cstyle scoped\u003e`):\n\n```html\n\u003cdiv id=\"InlineCss-1\"\u003e\n\t\u003cdiv class=\"card\"\u003e\n\t\t\u003cimg src=\"mao.jpg\"\u003e\n\t\t\u003cp\u003eMao\u003c/p\u003e\n\t\u003c/div\u003e\n\t\u003cstyle\u003e\n\t\t#InlineCss-1 .card { \n\t\t  cursor: pointer; \n\t\t  margin: 15px; \n\t\t  padding: 15px; \n\t\t  text-align: center; \n\t\t  height: 200px; \n\t\t}\n\t\t#InlineCss-1 img { \n\t\t  width: 130px; \n\t\t  height: 130px; \n\t\t}\n\t\t#InlineCss-1 p { \n\t\t  margin: 10px; \n\t\t}\n\t\u003c/style\u003e\n\u003c/div\u003e\n```\n\nFor a cascaded effect, see the `index.html` demo.\n\n## Installation\n\n\tnpm install --save react-inline-css react\n\n## Usage\n\nRun `npm run watch` in your terminal and play with `example/` to get a feel of react-inline-css.\n\n### SASS / LESS\n\nYou can override the `\u0026` as the selector to the current component. This is useful if you want to require precompiled stylesheets from an external file. Here's an example with [SASS loader for Webpack](https://www.npmjs.com/package/sass-loader):\n\n**UserComponent.js**\n```javascript\nimport React from \"react\";\nimport InlineCss from \"react-inline-css\";\nconst stylesheet = require(\"!raw!sass!./UserComponent.scss\");\n\nclass UserComponent extends React.Component {\n\trender () {\n\t\treturn (\n\t\t\t\u003cInlineCss componentName=\"UserComponent\" stylesheet={stylesheet}\u003e\n\t\t\t\t\u003cdiv className=\"facebook\"\u003eMao is no longer red!\u003c/div\u003e\n\t\t\t\t\u003cdiv className=\"google\"\u003eMao is no longer red!\u003c/div\u003e\n\t\t\t\t\u003cdiv className=\"twitter\"\u003eMao is no longer red!\u003c/div\u003e\n\t\t\t\u003c/InlineCss\u003e\n\t\t);\n\t}\n};\n```\n\n**UserComponent.scss**\n```scss\nUserComponent {\n\tcolor: red;\n\t.facebook {\n\t\tcolor: blue;\n\t}\n\t.google {\n\t\tcolor: blue;\n\t}\n\t.twitter {\n\t\tcolor: green;\n\t}\n}\n```\n\n**result**\n\n![screenshot](https://i.imgur.com/e3ErqTz.png?1)\n\n## Community\n\nLet's start one together! After you ★Star this project, follow me [@Rygu](https://twitter.com/rygu)\non Twitter. \n\n### Contributors\n\n- [Danilo Moret](https://github.com/moret)\n- [Will Butler](https://github.com/willbutler)\n\n## License\n\nBSD 3-Clause license. Copyright © 2015, Rick Wong. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRickWong%2Freact-inline-css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRickWong%2Freact-inline-css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRickWong%2Freact-inline-css/lists"}