类变体权威 (Class Variance Authority)

#Tech

类变体权威 (Class Variance Authority)

cva旨在解决使用传统CSS方法创建UI组件变体时面临的困难,例如手动匹配类名和类型。

它是一个免费的开源项目,旨在消除在CSS-in-TS或CSS-in-JS方案不适用时(如需要对样式输出有完全控制权或使用Tailwind CSS等框架)的繁琐操作,从而让开发者专注于UI开发中更有趣的部分。

该项目受到Stitches、Vanilla Extract等CSS-in-TS库的启发,并感谢clb作者分享了相关工作,以及clsx提供额外的类名处理功能。

查看原文开头(英文 · 仅前 3 段)

DocumentationIntroduction

Class Variance Authority

CSS-in-TS libraries such as Stitches (opens in a new tab) and Vanilla Extract (opens in a new tab) are fantastic options for building type-safe UI components; taking away all the worries of class names and StyleSheet composition.

※ 出于版权考虑,仅引用前 3 段。完整内容请阅读原文。

阅读原文 ↗