{"id":28456834,"url":"https://github.com/cssinjs/aphrodite-jss","last_synced_at":"2025-06-30T00:32:19.561Z","repository":{"id":57181357,"uuid":"65689520","full_name":"cssinjs/aphrodite-jss","owner":"cssinjs","description":"Aphrodite-like API on top of JSS.","archived":false,"fork":false,"pushed_at":"2018-08-07T13:53:53.000Z","size":317,"stargazers_count":92,"open_issues_count":5,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-28T01:49:31.389Z","etag":null,"topics":["aphrodite","jss"],"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/cssinjs.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","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":"2016-08-14T22:38:01.000Z","updated_at":"2025-04-24T11:04:07.000Z","dependencies_parsed_at":"2022-09-14T04:40:26.057Z","dependency_job_id":null,"html_url":"https://github.com/cssinjs/aphrodite-jss","commit_stats":null,"previous_names":["cssinjs/aphrodisiac"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/cssinjs/aphrodite-jss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssinjs%2Faphrodite-jss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssinjs%2Faphrodite-jss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssinjs%2Faphrodite-jss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssinjs%2Faphrodite-jss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cssinjs","download_url":"https://codeload.github.com/cssinjs/aphrodite-jss/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssinjs%2Faphrodite-jss/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262368853,"owners_count":23300234,"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":["aphrodite","jss"],"created_at":"2025-06-06T23:09:08.104Z","updated_at":"2025-06-30T00:32:19.550Z","avatar_url":"https://github.com/cssinjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aphrodite-like API on top of JSS.\n\nThis project is a merge of good ideas from [aphrodite](https://github.com/Khan/aphrodite) and [JSS](https://github.com/cssinjs/jss). It provides an API of aphrodite but fixes lots of limitations and caveats by using JSS as a rendering engine under the hood.\n\n## Good parts from aphrodite.\n\n- Pretty much like inline styles known from React, except it allows to use the entire CSS.\n- No CSS is generated until `css()` function invocation. Only the passed rules are converted to a CSS string and injected.\n- Theming is possible without any headache or framework integrations.\n\n## Benefits compared to aphrodite.\n\n- More powerfull rendering abstraction through [JSS](https://github.com/cssinjs/jss) under the hood. You are using all it's plugins and [JSON DSL](https://github.com/cssinjs/jss/blob/master/docs/json-api.md). To name a few:\n  - Children, siblings and any other kinds of selectors. ([jss-nested](https://github.com/cssinjs/jss-nested))\n  - Global styles, without auto namespacing ([jss-global](https://github.com/cssinjs/jss-global)).\n- Immediate render upon `css()` call invocation. It gives you an access to computed styles right after render, no need to use `setTimeout()`. It also avoids additional recalcs and repaints, which can cause flickers and general performance overhead.\n- No auto \"!important\" insertion. You can write a plugin for this though.\n\n\n## Example\n\n```javascript\nimport {StyleSheet, css} from 'aphrodite-jss'\n\nconst sheet = StyleSheet.create({\n  button: {\n    border: '1px solid',\n    borderRadius: 5,\n    fontSize: 'inherit',\n    lineHeight: '2.3em',\n    padding: '0 1em',\n    boxShadow: 'inset 0 1px 0 rgba(255, 255, 255, 0.1)',\n    textShadow: '0 -1px 0 rgba(0, 0, 0, 0.25)',\n    backgroundRepeat: 'repeat-x',\n    color: '#fff',\n    fontWeight: 400,\n    '\u0026 span': {\n      marginRight: 5,\n      color: '#fff'\n    }\n  },\n  primary: {\n    borderColor: '#1177cd #0f6ab6 #0d5c9e',\n    backgroundImage: 'linear-gradient(to bottom, #2591ed 0%, #1177cd 100%)',\n    backgroundColor: '#1385e5',\n    '\u0026:hover': {\n      backgroundImage: 'linear-gradient(to bottom, #3c9def 0%, #1385e5 100%)'\n    }\n  }\n})\n\ndocument.body.innerHTML = `\n  \u003cbutton class=\"${css(sheet.button, sheet.primary)}\"\u003e\n    \u003cspan\u003e\u0026#10004;\u003c/span\u003ePrimary\n  \u003c/button\u003e\n`\n```\n\n## API\n\n### Create style sheet.\n\n`StyleSheet.create(styles)`\n\nCreate function doesn't render anything, it just registers your styles.\n\nReturns an object, where key names correspond the original styles obejct.\n\n### Inject rules.\n\n`css(rule1, [rule2], [rule3], ...)`\n\nInjects a previously defined rule to the dom. This is done in sync, so the CSS rule is immediately available.\n\nReturns a class name.\n\n### Styles format.\n\nThe format for styles is defined in [jss](https://github.com/cssinjs/jss/blob/master/docs/json-api.md). Aprodisiac uses [jss-preset-default](https://github.com/cssinjs/jss-preset-default), so all default presets are already in place.\n\n### Customizing JSS.\n\n`aphroditeJss(jss, [options])`\n\nYou can pass your own JSS instance with your custom setup.\n\nReturns aphrodite's interface.\n\n```javascript\nimport aphroditeJss from 'aphrodite-jss'\nimport {create} from 'jss'\n\nconst {css, StyleSheet} = aphroditeJss(create())\n```\n\n### Serverside Rendering.\n\nThere are 2 functions you need to know - `toString()` and `reset()`.\nAs aphrodite-jss can not know that you are rendering a new response, you need to get the CSS (`toString()`) when you are processing the first request and call `reset()` to clean up the styles your current page has produced.\n\n\n```javascript\nimport {toString, reset} from 'aphrodite-jss'\n\nfunction render() {\n  const app = renderApp()\n  const css = toString()\n  reset()\n\n  return `\n    \u003chead\u003e\n      \u003cstyle\u003e\n        ${css}\n      \u003c/style\u003e\n    \u003chead\u003e\n    \u003cbody\u003e\n      ${app}\n    \u003c/body\u003e\n  `\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcssinjs%2Faphrodite-jss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcssinjs%2Faphrodite-jss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcssinjs%2Faphrodite-jss/lists"}