{"id":13394404,"url":"https://github.com/jorgebucaran/classcat","last_synced_at":"2025-05-14T15:03:52.996Z","repository":{"id":39821994,"uuid":"103287387","full_name":"jorgebucaran/classcat","owner":"jorgebucaran","description":"Build a class attribute string quickly","archived":false,"fork":false,"pushed_at":"2024-04-02T20:20:27.000Z","size":208,"stargazers_count":905,"open_issues_count":1,"forks_count":22,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-11T05:12:29.563Z","etag":null,"topics":["class","classlist","classnames","node"],"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/jorgebucaran.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-09-12T15:20:15.000Z","updated_at":"2025-02-26T17:56:45.000Z","dependencies_parsed_at":"2024-03-14T16:21:41.788Z","dependency_job_id":"c76c8087-e319-465c-94ef-41d2b0124b9e","html_url":"https://github.com/jorgebucaran/classcat","commit_stats":{"total_commits":167,"total_committers":9,"mean_commits":"18.555555555555557","dds":0.04790419161676651,"last_synced_commit":"b4aa45aae2f026071164981dd065efc42e805023"},"previous_names":["foldmap/classcat","srcfile/classcat","jorgebucaran/classcat"],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgebucaran%2Fclasscat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgebucaran%2Fclasscat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgebucaran%2Fclasscat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgebucaran%2Fclasscat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jorgebucaran","download_url":"https://codeload.github.com/jorgebucaran/classcat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345267,"owners_count":21088244,"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":["class","classlist","classnames","node"],"created_at":"2024-07-30T17:01:18.295Z","updated_at":"2025-04-11T05:12:36.645Z","avatar_url":"https://github.com/jorgebucaran.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Classcat\n\n\u003e Build a [`class`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class) attribute string quickly.\n\n- Framework agnostic, reusable, plain vanilla JavaScript.\n- Up to [2.5x faster](#benchmarks) than alternatives.\n- [217 B](http://bundlephobia.com/result?p=classcat) (minified+gzipped). 👌\n\nThis module makes it easy to build a space-delimited `class` attribute string from an object or array of CSS class names. Just pair each class with a boolean value to add or remove them conditionally.\n\n```js\nimport cc from \"classcat\"\n\nexport const ToggleButton = ({ isOn, toggle }) =\u003e (\n  \u003cdiv className=\"btn\" onClick={() =\u003e toggle(!isOn)}\u003e\n    \u003cdiv\n      className={cc({\n        circle: true,\n        off: !isOn,\n        on: isOn,\n      })}\n    /\u003e\n    \u003cspan className={cc({ textOff: !isOn })}\u003e{isOn ? \"ON\" : \"OFF\"}\u003c/span\u003e\n  \u003c/div\u003e\n)\n```\n\n[Try with React](https://codepen.io/jorgebucaran/pen/NYgLwG?editors=0010), [lit-html](https://codepen.io/jorgebucaran/pen/LjPJEp?editors=1000), [Mithril](https://codepen.io/jorgebucaran/pen/JjjOjwB?editors=1100), [Superfine](https://codepen.io/jorgebucaran/pen/wrMvjz?editors=1000)\n\n## Installation\n\n```console\nnpm install classcat\n```\n\nOr without a build step—import it right in your browser.\n\n```html\n\u003cscript type=\"module\"\u003e\n  import cc from \"https://unpkg.com/classcat\"\n\u003c/script\u003e\n```\n\n## API\n\n### `cc(names)`\n\n```ps\ncc(names: string | number | object | array): string\n```\n\n```js\nimport cc from \"classcat\"\n\ncc(\"elf\") //=\u003e \"elf\"\n\ncc([\"elf\", \"orc\", \"gnome\"]) //=\u003e \"elf orc gnome\"\n\ncc({\n  elf: false,\n  orc: null,\n  gnome: undefined,\n}) //=\u003e \"\"\n\ncc({\n  elf: true,\n  orc: false,\n  gnome: true,\n}) //=\u003e \"elf gnome\"\n\ncc([\n  {\n    elf: true,\n    orc: false,\n  },\n  \"gnome\",\n]) //=\u003e \"elf gnome\"\n```\n\n## Benchmarks\n\n```console\nnpm --prefix bench start\n```\n\n## License\n\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgebucaran%2Fclasscat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorgebucaran%2Fclasscat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgebucaran%2Fclasscat/lists"}