{"id":49402580,"url":"https://github.com/yume-chan/yangshi","last_synced_at":"2026-04-28T19:05:20.473Z","repository":{"id":350904372,"uuid":"1208639216","full_name":"yume-chan/yangshi","owner":"yume-chan","description":"Object-style zero-runtime atomic CSS-in-JS library","archived":false,"fork":false,"pushed_at":"2026-04-12T17:14:34.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-12T19:06:35.429Z","etag":null,"topics":["css","css-in-js","zero-runtime"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/yume-chan.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-12T14:59:14.000Z","updated_at":"2026-04-12T17:14:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yume-chan/yangshi","commit_stats":null,"previous_names":["yume-chan/yangshi"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/yume-chan/yangshi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fyangshi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fyangshi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fyangshi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fyangshi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yume-chan","download_url":"https://codeload.github.com/yume-chan/yangshi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yume-chan%2Fyangshi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32394533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["css","css-in-js","zero-runtime"],"created_at":"2026-04-28T19:05:18.693Z","updated_at":"2026-04-28T19:05:20.467Z","avatar_url":"https://github.com/yume-chan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yangshi\n\nAnother object-style zero-runtime atomic CSS-in-JS library based on wyw-in-js.\n\n## Features\n\n- CSS-in-JS: Write CSS code inside JS files.\n- Object Style: Write CSS properties as objects, if this is what you prefer.\n- Atomic CSS: Only longhand properties are supported. Merging styles is straightforward and intuitive.\n- Zero runtime (except for `cx`): Styles are extracted to CSS files at bundling time. No runtime overhead added.\n  - Wide bundler support: Including Bun, esbuild, Next.js, Parcel, Rollup, Rspack, Svelte, Vite, Webpack...\n  - Code evaluation: Constants, function calls, and even imports (but not local function arguments!) are allowed inside CSS objects. They get evaluated at bundling time.\n\n## Install\n\n```sh\nnpm i @yume-chan/yangshi\n```\n\n## Config\n\nSee https://wyw-in-js.dev/bundlers to config your bundler.\n\nNote: because we are using Atomic CSS, you might want to generate a single CSS file (otherwise there will be many duplicate rules). For example for Vite, this can be done by setting `build.cssCodeSplit` to `false`.\n\n## Usage\n\n### Basics\n\n```ts\nimport { css } from \"@yume-chan/yangshi\";\n\nconst className = css({\n  color: \"red\",\n});\n```\n\nOutput:\n\n```js\nconst className = `a-a`;\n```\n\n```css\n.a-a {\n  color: red;\n}\n```\n\n### Pseudo classes/elements and parent selector\n\nUse `\u0026` (self selector) with nested objects:\n\n```ts\nimport { css } from \"@yume-chan/yangshi\";\n\nconst className = css({\n  color: \"red\",\n\n  \"\u0026:hover\": {\n    color: \"blue\",\n  },\n\n  \".dark \u0026\": {\n    color: \"cyan\",\n  },\n});\n```\n\nOutput:\n\n```js\nconst className = `a-a b-b c-c`;\n```\n\n```css\n.a-a {\n  color: red;\n}\n.b-b:hover {\n  color: blue;\n}\n.dark .c-c {\n  color: cyan;\n}\n```\n\n### Media queries and other at-rules\n\nJust what you think:\n\n```ts\nimport { css } from \"@yume-chan/yangshi\";\n\ncss({\n  color: \"red\",\n\n  \"@media (prefers-color-scheme: dark)\": {\n    color: \"blue\",\n  },\n});\n```\n\nOutput:\n\n```js\nconst className = `a-a b-b`;\n```\n\n```css\n.a-a {\n  color: red;\n}\n@media (prefers-color-scheme: dark) {\n  .b-b.b-b {\n    color: #00f;\n  }\n}\n```\n\nNote: at-rules use double class selector (`.b-b.b-b`) to increase its priority, so they always override normal rules no matter the ordering.\n\n### Animation\n\nPut the animation keyframes in `animationName` property:\n\n```ts\nimport { css } from \"@yume-chan/yangshi\";\n\nconst className = css({\n  animationName: {\n    from: {\n      color: \"blue\",\n    },\n    to: {\n      color: \"red\",\n    },\n  },\n  animationIterationCount: \"infinite\",\n  animationDuration: \"500ms\",\n});\n```\n\nOutput:\n\n```js\nconst className = `a-a b-b c-c`;\n```\n\n```css\n.a-a {\n  animation-name: a;\n}\n.b-b {\n  animation-iteration-count: infinite;\n}\n.c-c {\n  animation-duration: 0.5s;\n}\n@keyframes a {\n  0% {\n    color: blue;\n  }\n  to {\n    color: red;\n  }\n}\n```\n\n### Shorthand properties\n\nOnly atomic properties are allowed in `css`.\n\nSome shorthand helpers are provided in `atomic` object:\n\n```ts\nimport { atomic, css } from \"@yume-chan/yangshi\";\n\nconst className = css({\n  ...atomic.border(\"1px\", \"solid\", \"red\"),\n});\n```\n\nOutput:\n\n```js\nconst className = `a-a b-b c-c d-a e-b f-c g-a h-b i-c j-a k-b l-c`;\n```\n\n```css\n.a-a {\n  border-block-start-width: 1px;\n}\n.b-b {\n  border-block-start-style: solid;\n}\n.c-c {\n  border-block-start-color: red;\n}\n.d-a {\n  border-inline-end-width: 1px;\n}\n.e-b {\n  border-inline-end-style: solid;\n}\n.f-c {\n  border-inline-end-color: red;\n}\n.g-a {\n  border-block-end-width: 1px;\n}\n.h-b {\n  border-block-end-style: solid;\n}\n.i-c {\n  border-block-end-color: red;\n}\n.j-a {\n  border-inline-start-width: 1px;\n}\n.k-b {\n  border-inline-start-style: solid;\n}\n.l-c {\n  border-inline-start-color: red;\n}\n```\n\n### Code evaluation\n\nLike `atomic` functions, you can include constants, function calls, and even imports inside CSS objects:\n\n```ts\nimport { css } from \"@yume-chan/yangshi\";\n\nconst PrimaryColor = \"blue\";\n\nconst className = css({ color: PrimaryColor });\n```\n\nOutput:\n\n```js\nconst className = `a-a`;\n```\n\n```css\n.a-a {\n  color: blue;\n}\n```\n\nHowever, all values must be constant at bundling time. For example, local function arguments are not allowed:\n\n```tsx\nfunction MyComponent(props: { color: string }) {\n  // NO!\n  return \u003cdiv className={css({ color: props.color })} /\u003e;\n}\n```\n\nYou can only use `style` property, or CSS custom properties (variables) for that.\n\n## Merge class names\n\nThe `cx` function is a `classNames`-style function that merges class names at runtime.\n\n`cx` ensures property values specified later will always override values before, no matter what order they appeared in the final CSS output. In another word, you must always use `cx` to merge class names generated by this library!\n\n```ts\nimport { css, cx } from \"@yume-chan/yangshi\";\n\nconst isBlue = true;\n\nconst className = cx(\n  css({\n    color: \"red\",\n  }),\n  isBlue \u0026\u0026 css({ color: \"blue\" }),\n);\n```\n\nOutput:\n\n```js\nconst className = cx(`a-a`, Math.random() \u003e 0.5 \u0026\u0026 `a-b`);\n```\n\n```css\n.a-a {\n  color: red;\n}\n.a-b {\n  color: blue;\n}\n```\n\n## Stable class names\n\nNo. It currently doesn't generate stable class names.\n\nIt chooses class names from alphabets as new properties/values appears in processing.\n\nThis might change in future.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyume-chan%2Fyangshi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyume-chan%2Fyangshi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyume-chan%2Fyangshi/lists"}