项目
在 GitHub 查看
aidenybai/cnfast
关于
速度提升 25 倍的 `cn` 即插即用替代方案
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -3
- 1个月
- -6
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文[!NOTE] Check out
cnby shadcn for an even fastercnpackage.cnfastwill no longer be maintained in favor ofcn. I recommend you go use that package instead!
cnfast
Fast drop-in replacement for tailwind-merge + clsx.
cnfast runs 25× faster than tailwind-merge + clsx across 58 real-world repositories, with byte-identical output. Same API, no code changes.
import { cn } from "cnfast";
cn("px-2 py-1", isActive && "px-4", { "text-red-500": hasError });
// "py-1 px-4 text-red-500"
Install
npm install cnfast
Migrate an existing clsx, classnames, or tailwind-merge project in one command:
npx cnfast migrate
On a shadcn/ui project, add or replace your cn utility through the registry. This rewrites lib/utils.ts to re-export cnfast and installs the package:
npx shadcn@latest add aidenybai/cnfast/cn
Usage
Swap the shadcn/ui cn helper for cnfast:
// before
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));
// after
export { cn } from "cnfast";
cnfast also exports clsx, twMerge, and twJoin.
Development
ni
nr build
nr test
License
MIT
探索相关项目
加载中…