{"id":13393939,"url":"https://github.com/CraigCav/css-zero","last_synced_at":"2025-03-13T19:31:54.877Z","repository":{"id":36443987,"uuid":"222539361","full_name":"CraigCav/css-zero","owner":"CraigCav","description":"Zero-runtime CSS-in-JS","archived":false,"fork":false,"pushed_at":"2023-01-05T01:09:42.000Z","size":2290,"stargazers_count":283,"open_issues_count":47,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-04T04:08:08.113Z","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/CraigCav.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":"2019-11-18T20:34:15.000Z","updated_at":"2025-01-02T10:10:16.000Z","dependencies_parsed_at":"2023-01-17T01:31:39.296Z","dependency_job_id":null,"html_url":"https://github.com/CraigCav/css-zero","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CraigCav%2Fcss-zero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CraigCav%2Fcss-zero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CraigCav%2Fcss-zero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CraigCav%2Fcss-zero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CraigCav","download_url":"https://codeload.github.com/CraigCav/css-zero/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243469233,"owners_count":20295715,"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-30T17:01:03.110Z","updated_at":"2025-03-13T19:31:53.277Z","avatar_url":"https://github.com/CraigCav.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# CSS-Zero\n\n## Features\n\n- All of the benefits of writing CSS-in-JS, but with **zero runtime code**\n- Write your styles with familiar CSS Syntax\n- Generates optimized, atomic CSS with no duplicated style rules\n- Style resolution based on order of application, rather than the cascade\n- Zero config server-side rendering for applications that support CSS Modules\n- Easy composition of styles, with property name collisions eliminated via static analysis\n- Theme support via CSS variables, allowing the cost of theming to be proportional to the size of the color palette\n- Fast parsing of styles, with CSS downloaded and parsed separately from JS.\n- Works without JavaScript, as styles are extracted at build-time.\n\nThese benefits are in addition to the more general benefits of using CSS-in-JS:\n\n- Scoped selectors to avoid accidental collision of styles\n- Styles co-located with your component reduces context switching\n- Refactor with confidence when changing/removing styles\n- Detect unused styles with EsLint, just like normal JS variables\n- Declarative dynamic styling with React\n\n## Installation\n\nSince CSS-Zero has no runtime, it can be installed purely as a devDependency:\n\n```\nnpm install css-zero --save-dev\n```\n\n## Setup\n\nThe simplest way to run CSS-Zero in a React application is using our Babel Macro:\n\n```jsx\nimport {css, styled} from 'css-zero/macro';\n```\n\nFor applications created using Create React App (which supports both Babel Macros and CSS Modules out-of-the-box), no further setup or configuration is needed.\n\nFor usage with other front-end frameworks, CSS-Zero can be set up with our babel-plugin.\n\n## Syntax\n\nThe basic usage of CSS-Zero looks like this:\n\n```jsx\nimport {css, styles} from 'css-zero';\n\n// Write your styles using the `css` tag\nconst blue = css`\n  color: blue;\n`;\n\nconst base = css`\n  color: red;\n  font-size: 16px;\n`;\n\n// then use the `styles` helper to compose your styles and generate class names\nexport default props =\u003e \u003cdiv className={styles(base, props.isBlue \u0026\u0026 blue)} /\u003e;\n\n      ↓ ↓ ↓ ↓ ↓ ↓ Compiles to  ↓ ↓ ↓ ↓ ↓ ↓\n\nexport default props =\u003e \u003cdiv className={(props.isBlue ? \"x1vong5g\" : \"x1dqz7z3\") + \" \" + \"x1e4w2a9\"} /\u003e\n\n// along with a the following .zero.css file:\n.x1vong5g {color:blue}\n.x1dqz7z3 {color:red}\n.x1e4w2a9 {font-size:16px}\n```\n\n## Demo\n\n[![Edit CSS-Zero Create React App Example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/hello-world-ogzzo?fontsize=14\u0026hidenavigation=1\u0026theme=dark)\n\n## Inspiration\n\n- [emotion](https://emotion.sh/)\n- [linaria](https://github.com/callstack/linaria)\n- [style-sheet](https://github.com/giuseppeg/style-sheet)\n- [Facebook stylex](https://www.youtube.com/watch?v=9JZHodNR184\u0026list=PLPxbbTqCLbGHPxZpw4xj_Wwg8-fdNxJRh\u0026index=3)\n- [object-style](https://github.com/jxnblk/object-style)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCraigCav%2Fcss-zero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCraigCav%2Fcss-zero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCraigCav%2Fcss-zero/lists"}