{"id":43998027,"url":"https://github.com/vuolter/klsx","last_synced_at":"2026-02-07T12:03:31.566Z","repository":{"id":325404497,"uuid":"1098597122","full_name":"vuolter/klsx","owner":"vuolter","description":"Same as clsx but \"maybe\" better","archived":false,"fork":false,"pushed_at":"2025-12-19T23:19:03.000Z","size":154,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-22T10:27:21.513Z","etag":null,"topics":["bun","class","classname","classnames","clsx"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/klsx","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/vuolter.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":"2025-11-17T22:39:36.000Z","updated_at":"2025-12-19T23:18:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/vuolter/klsx","commit_stats":null,"previous_names":["vuolter/klsx"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/vuolter/klsx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuolter%2Fklsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuolter%2Fklsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuolter%2Fklsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuolter%2Fklsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vuolter","download_url":"https://codeload.github.com/vuolter/klsx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vuolter%2Fklsx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29194010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["bun","class","classname","classnames","clsx"],"created_at":"2026-02-07T12:03:29.410Z","updated_at":"2026-02-07T12:03:31.537Z","avatar_url":"https://github.com/vuolter.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎨 𝒌𝒍𝒔𝒙\n\nA simple replacement for [clsx](https://www.npmjs.com/package/clsx) **_you may not actually need_** (see the [benchmark](https://github.com/vuolter/klsx/blob/main/BENCHMARK.md))\n\nUsed to construct `class` conditionally with strings, arrays and key-value objects.\n\nDeveloped as a case study, [Bun](https://bun.com) friendly. 🌿\n\n### Features\n\n- 🚀 Unnecessarily fast (~20M ops/s)\n- 🎯 Same functionality and API of clsx\n- 👑 Modern ESM syntax\n- 💎 Zero dependencies\n- ☀️ No \"lite\" mode (simply doesn't make any sense)\n- 🎈 Only 277B (~190B compressed)\n- 🐳 Deeply typed and tested\n- 🚨 [Experimental WASM variant](https://github.com/vuolter/klsx/tree/wasm) (for research purposes, do not use it)\n\n## Installation\n\n```bash\nbun add klsx\n```\n\nor with `npm`:\n\n```bash\nnpm install klsx\n```\n\n## Quick Start\n\n```typescript\nimport { klsx } from 'klsx'\n\nklsx('foo', 'bar', 'baz')\n// =\u003e \"foo bar baz\"\n\nklsx({ foo: 'string', bar: true, bux: null }, 'baz')\n// =\u003e \"foo bar baz\"\n\nklsx(['foo', ['bar', true \u0026\u0026 'baz']])\n// =\u003e \"foo bar baz\"\n```\n\nor importing the short alias `kx`:\n\n### React\n\n```jsx\nimport React, { useState } from 'react'\nimport { kx } from 'klsx'\n\nconst MyComponent = () =\u003e {\n  const [isActive, setIsActive] = useState(false)\n  return (\n    \u003cdiv\u003e\n      \u003cdiv className={kx('base-class', isActive ? 'active' : 'inactive')}\u003e\n        {/* ... */}\n      \u003c/div\u003e\n\n      \u003cdiv className={kx('base-class', { active: isActive, inactive: !isActive })}\u003e\n        {/* ... */}\n      \u003c/div\u003e\n\n      \u003cdiv\n        className={kx('base-class', [isActive \u0026\u0026 'active', !isActive \u0026\u0026 'inactive'])}\n      \u003e\n        {/* ... */}\n      \u003c/div\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\n### Migrate from `clsx`\n\nJust replace every `c` with a `k`, as in the example below.\n\nFrom:\n\n```typescript\n// clsx\n\nimport { clsx, type ClassValue } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n```\n\nTo:\n\n```typescript\n// KLSX\n\nimport { klsx, type KlassValue } from 'klsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn(...inputs: KlassValue[]) {\n  return twMerge(klsx(inputs))\n}\n```\n\n## Integrations\n\n### Tailwind CSS\n\n#### Visual Studio Code\n\n1. Install the [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) extension:\n\n```bash\ncode --install-extension bradlc.vscode-tailwindcss\n```\n\n2. Update your [`settings.json`](https://code.visualstudio.com/docs/getstarted/settings) configuration with:\n\n```json\n{\n  \"tailwindCSS.classFunctions\": [\"klsx\", \"kx\"]\n}\n```\n\n#### Prettier\n\n1. Install the [prettier-plugin-tailwindcss](https://www.npmjs.com/package/prettier-plugin-tailwindcss) plugin:\n\n```bash\nbun add -D prettier prettier-plugin-tailwindcss\n```\n\n2. Update your `prettier.config.js` configuration to handle `klsx`:\n\n```javascript\n/** @type {import('prettier').Config \u0026 import('prettier-plugin-tailwindcss').PluginOptions} */\nexport default {\n  plugins: ['prettier-plugin-tailwindcss'],\n  tailwindFunctions: ['klsx', 'kx'],\n}\n```\n\n### ESLint\n\n1. Install the [eslint-plugin-clsx](https://www.npmjs.com/package/eslint-plugin-clsx) plugin:\n\n```bash\nbun add -D eslint eslint-plugin-clsx\n```\n\n2. Update your `eslint.config.js` configuration to handle `klsx`:\n\n```javascript\nimport { defineConfig } from 'eslint/config'\nimport clsx from 'eslint-plugin-clsx'\n\nexport default defineConfig({\n  plugins: { clsx },\n  settings: {\n    clsxOptions: {\n      klsx: ['default', 'klsx', 'kx'],\n    },\n  },\n})\n```\n\n## Development\n\nInstall dependencies:\n\n```bash\nbun install\n```\n\nBuild dist files:\n\n```bash\nbun run build\n```\n\n## Testing\n\nRun test suite:\n\n```bash\nbun test\n```\n\nRun benchmark suite:\n\n```bash\nbun bench\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuolter%2Fklsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvuolter%2Fklsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuolter%2Fklsx/lists"}