{"id":27017454,"url":"https://github.com/ankitmishradev/css-class-builder","last_synced_at":"2026-04-28T12:06:20.688Z","repository":{"id":142667040,"uuid":"438980339","full_name":"ankitmishradev/css-class-builder","owner":"ankitmishradev","description":"A small typescript package built to work with ReactJS to shorten manipulation and handling of CSS classes by combining useful methods and functions into one single package.","archived":false,"fork":false,"pushed_at":"2022-07-03T14:05:58.000Z","size":96,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T07:54:26.301Z","etag":null,"topics":["css-utilities","javascript","npm","npm-package","reactjs","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/css-class-builder","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/ankitmishradev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-16T12:24:34.000Z","updated_at":"2022-01-07T06:28:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"5eb26d08-29d8-4453-b3a6-7cc3a3850c8a","html_url":"https://github.com/ankitmishradev/css-class-builder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ankitmishradev/css-class-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitmishradev%2Fcss-class-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitmishradev%2Fcss-class-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitmishradev%2Fcss-class-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitmishradev%2Fcss-class-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankitmishradev","download_url":"https://codeload.github.com/ankitmishradev/css-class-builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankitmishradev%2Fcss-class-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32379679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T11:25:28.583Z","status":"ssl_error","status_checked_at":"2026-04-28T11:25:05.435Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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-utilities","javascript","npm","npm-package","reactjs","typescript","typescript-library"],"created_at":"2025-04-04T16:23:37.909Z","updated_at":"2026-04-28T12:06:20.671Z","avatar_url":"https://github.com/ankitmishradev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![npm](https://img.shields.io/npm/v/css-class-builder)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ankitmishradev/css-class-builder/build)\n![Typescript](https://img.shields.io/github/languages/top/ankitmishradev/css-class-builder)\n![MIT license](https://img.shields.io/github/license/ankitmishradev/css-class-builder)\n[![CodeFactor A+](https://www.codefactor.io/repository/github/ankitmishradev/css-class-builder/badge)](https://www.codefactor.io/repository/github/ankitmishradev/css-class-builder)\n\n# CSS Class Builder\n\nA small typescript package built to work with `ReactJS` to shorten manipulation and handling of css classnames by combining useful methods and functions into one single package.\n\n## How to use\n\n### Installation\n\nYou can install the package to your javascript/typescript project, using below command\n\n```cmd\nnpm i css-class-builder\n```\n\n### Setup\n\nAfter installation import the package in your project file,\n\n```js\nimport cssClassBuilder from 'css-class-builder';\n```\n\nThen initialize the builder function,\n\n```js\nconst classname = cssClassBuilder();\n```\n\nThis initialization creates a store where we can add, remove or toggle classnames. We can use `classname` to interact with the store.\n\n## Features\n\n### Initializing with value\n\nThe builder function can be initialized with a single or multiple classnames.\n\n```js\nconst classname = cssClassBuilder('initial'); // -\u003e initial\nconst headingClass = cssClassBuilder('heading h-6'); // -\u003e heading h-6\n```\n\n### Extending css class\n\nOnce you have initialized the builder function you can use `extend` method to add classname(s) to the store.\n\n```js\nconst classname = cssClassBuilder();\nclassname.extend('another-css-class'); // -\u003e another-css-class\nclassname.extend('red green'); // -\u003e another-css-class red green\n```\n\n### Removing css class\n\n`remove` method can be used to remove classname(s) from the store.\n\n```js\nconst classname = cssClassBuilder('bold italic');\nclassname.remove('italic'); // -\u003e bold\n```\n\n### Toggling class dynamically\n\nClassname(s) can be extended or removed from the store. We can use `toggle` method to toggle classname(s) over a boolean value.\n\n- For `true`, the classname will be added to the current classname.\n- For `false`, the class will be removed from the current classname.\n\n```js\nconst classname = cssClassBuilder('initial');\nlet anotherBooleanValue: boolean = true;\nclassname.toggle('blue', anotherBooleanValue); // -\u003e initial blue\notherValue = false;\nclassname.toggle('blue', anotherBooleanValue); // -\u003e initial\n```\n\n## Using stored classnames\n\nWhen ready to use the classname(s) stored in the builder for the `className` or `class` attribute of the HTML/JSX tags, `unzip` method can be used to get all classname(s) as a single string.\n\n```jsx\nconst classname = cssClassBuilder('initial');\nclassname.extend('bold italic');\n\nreturn \u003cdiv class={classname.unzip}\u003e\u003c/div\u003e;\n```\n\nAbove `div` will have the following classnames: `initial`, `bold`, `italic`.\n\n## Changelog\n\nPlease see the [changelog](https://github.com/ankitmishradev/css-class-builder/blob/main/CHANGELOG.md) to know about the latest updates.\n\n## Contributions\n\nContribution to this project are most welcomed.\n\nIf you find bugs or want more features, but don't know how to fix/implement them, please fill an [issue](https://github.com/ankitmishradev/css-class-builder/issues).\n\nIf you fixed bugs or implemented new features, please send a [pull request](https://github.com/ankitmishradev/css-class-builder/pulls).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankitmishradev%2Fcss-class-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankitmishradev%2Fcss-class-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankitmishradev%2Fcss-class-builder/lists"}