{"id":25146411,"url":"https://github.com/larsnystrom/module-style","last_synced_at":"2026-04-09T16:18:02.853Z","repository":{"id":57154433,"uuid":"68093775","full_name":"larsnystrom/module-style","owner":"larsnystrom","description":"Declarative way to specify module-css with React.","archived":false,"fork":false,"pushed_at":"2016-09-13T10:28:12.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-23T15:39:36.524Z","etag":null,"topics":["css","css-modules","react"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/larsnystrom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-13T09:21:14.000Z","updated_at":"2017-02-15T13:01:51.000Z","dependencies_parsed_at":"2022-09-06T16:11:54.396Z","dependency_job_id":null,"html_url":"https://github.com/larsnystrom/module-style","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsnystrom%2Fmodule-style","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsnystrom%2Fmodule-style/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsnystrom%2Fmodule-style/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsnystrom%2Fmodule-style/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larsnystrom","download_url":"https://codeload.github.com/larsnystrom/module-style/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246946350,"owners_count":20859109,"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":["css","css-modules","react"],"created_at":"2025-02-08T20:18:18.848Z","updated_at":"2026-04-09T16:18:02.821Z","avatar_url":"https://github.com/larsnystrom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ModuleStyle\n\nDeclarative way to specify module-css with React, using [css-loader](https://github.com/webpack/css-loader) and [react-side-effect](https://github.com/gaearon/react-side-effect).\n\nCan be used both on the client and the server.\n\n## Install\n\n    npm install --save module-style\n\n## Usage\n\nThe `ModuleStyle` component is supposed to be used in tandem with [`css-loader`](https://github.com/webpack/css-loader), preferrably with [`css-modules`](https://github.com/webpack/css-loader#css-modules).\n\n### Example\n\nInstall dependencies\n\n    npm install --save module-style\n    npm install --save-dev css-loader\n\n`MyModule.js`: React component\n\n    import React from 'react';\n    import ModuleStyle from 'module-style;\n    import style, { locals as s } from './MyModule.css';\n\n    const MyModule = () =\u003e\n      \u003cModuleStyle style={style}\u003e\n        \u003cdiv className={s.root}\u003e\n          \u003cdiv className={s.container}\u003e\n            \u003ch1\u003eMy module page\u003c/h1\u003e\n            \u003cp\u003e...\u003c/p\u003e\n          \u003c/div\u003e\n        \u003c/div\u003e\n      \u003c/ModuleStyle\u003e\n\n    export default MyModule;\n\n`MyModule.css`: Stylesheet\n\n    .root {\n        background-color: blue;\n    }\n\n    .container {\n        background-color: red;\n    }\n\n`webpack.config.js`: Webpack configuration\n\n    {\n      module: {\n        loaders: [\n          {\n            test: /\\.css/,\n            loaders: [\n              'css-loader?modules',\n            ],\n          },\n        ],\n      },\n    }\n\n### Server-side\n\nOn the server you can get the style with the `ModuleStyle.rewind()` function.\n\n    import ReactDOM from 'react-dom';\n    import ModuleStyle from 'module-style';\n    import MyModule from './MyModule';\n    // ...\n\n    app.get('*', (req, res) =\u003e {\n        const content = ReactDOM.renderToString(\u003cMyModule /\u003e);\n        const style = ModuleStyle.rewind();\n\n        res.send(`\u003c!DOCTYPE html\u003e\n            \u003chtml\u003e\n                \u003chead\u003e\n                    \u003cmeta charset=\"utf-8\"\u003e\n                    \u003cstyle type=\"text/css\"\u003e${style}\u003c/style\u003e\n                \u003c/head\u003e\n                \u003cbody\u003e\n                    \u003cdiv id=\"app\"\u003e${content}\u003c/div\u003e\n                \u003c/body\u003e\n            \u003c/html\u003e`);\n    });\n\n## License\n\n[ISC License](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsnystrom%2Fmodule-style","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarsnystrom%2Fmodule-style","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsnystrom%2Fmodule-style/lists"}