{"id":15982751,"url":"https://github.com/seanmcp/class-list-builder","last_synced_at":"2025-04-04T19:19:08.483Z","repository":{"id":57139592,"uuid":"196979886","full_name":"SeanMcP/class-list-builder","owner":"SeanMcP","description":"🏗 A simpler class list builder","archived":false,"fork":false,"pushed_at":"2019-11-25T21:52:25.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-27T10:21:47.820Z","etag":null,"topics":["builder","class-list","class-list-builder","class-name","class-names","classes"],"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/SeanMcP.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-07-15T10:47:35.000Z","updated_at":"2019-11-25T21:52:52.000Z","dependencies_parsed_at":"2022-09-16T14:51:05.730Z","dependency_job_id":null,"html_url":"https://github.com/SeanMcP/class-list-builder","commit_stats":null,"previous_names":["seanmcp/class-list"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fclass-list-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fclass-list-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fclass-list-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeanMcP%2Fclass-list-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeanMcP","download_url":"https://codeload.github.com/SeanMcP/class-list-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234943,"owners_count":20905855,"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":["builder","class-list","class-list-builder","class-name","class-names","classes"],"created_at":"2024-10-08T01:21:45.761Z","updated_at":"2025-04-04T19:19:08.462Z","avatar_url":"https://github.com/SeanMcP.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Class List Builder\n\n[![npm](https://img.shields.io/npm/v/class-list-builder.svg)](https://npmjs.com/package/class-list-builder) [![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/class-list-builder.svg)](https://npmjs.com/package/class-list-builder) [![npm](https://img.shields.io/npm/dt/class-list-builder.svg)](https://npmjs.com/package/class-list-builder)\n\n🏗 A simpler class list builder\n\n## Use\n\n```js\nclassListBuilder('Build', 'class lists', true \u0026\u0026 'without', 'fear')\n// -\u003e 'Build class lists without fear'\n```\n\n## Why\n\n[Jed Watson's `classnames` library](https://github.com/JedWatson/classnames) is pretty much the industry standard for building a list of class names. Definitely check that out if you haven't already.\n\nThis library serves as an alternative with a simpler API for conditional classes. Instead of building dynamic keys on passed objects, you can use a simple `\u0026\u0026` binary to pass the class if the condition is `true`.\n\n## Install\n\n```sh\nnpm install class-list-builder\n# or\nyarn add class-list-builder\n```\n\n## API\n\nImport or require the default function exported from `class-list-builder`, then call and pass the desired class names as arguments:\n\n```js\nclassListBuilder('one', 2, 'three', 4)\n// -\u003e 'one 2 three 4'\n```\n\nArguments at evaluate to `false` are removed from the output:\n\n```js\nclassListBuilder(0, 'one', undefined, 'three')\n// -\u003e 'one three'\n```\n\nThis means you can use conditions in the passed arguments to selectively add classes:\n\n```js\nlet time = 1\n\nclassListBuilder('book', time \u003c 1 \u0026\u0026 '--due')\n// -\u003e 'book'\n\ntime = 0\n\nclassListBuilder('book', time \u003c 1 \u0026\u0026 '--due')\n// -\u003e 'book --due'\n```\n\n## Examples\n\n### React\n\n```jsx\nimport React from 'react'\nimport classListBuilder from 'class-list-builder'\n\nexport default function ToggleButton(props) {\n    const [isOn, toggle] = useToggle() // A basic custom hook\n    return (\n        \u003cbutton\n            className={classListBuilder('ToggleButton', isOn \u0026\u0026 'ToggleButton--on')}\n            onClick={toggle}\n            {...props}\n        \u003e\n            ToggleButton\n        \u003c/button\u003e\n    )\n}\n```\n\n## LICENSE\n\n[MIT](/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanmcp%2Fclass-list-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseanmcp%2Fclass-list-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanmcp%2Fclass-list-builder/lists"}