css-variants 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +8 -6
  2. package/LICENSE +0 -19
  3. package/README.md +0 -147
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-variants",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Lightweight helpers to compose class names and inline styles using variants. Zero runtime deps, small bundle, and first-class TypeScript support.",
5
5
  "homepage": "https://css-variants.vercel.app",
6
6
  "type": "module",
@@ -45,10 +45,9 @@
45
45
  "scripts": {
46
46
  "lint": "eslint .",
47
47
  "test": "vitest run --coverage",
48
- "bench": "vitest bench ./src",
49
- "bench:cva": "npm install class-variance-authority --no-save --no-package-lock && vitest bench ./benchmark/cva.bench.ts --outputJson ./benchmark/cva.bench.json --run",
50
- "bench:tailwind-variants": "npm install tailwind-variants --no-save --no-package-lock && vitest bench ./benchmark/tailwind-variants.bench.ts --outputJson ./benchmark/tailwind-variants.bench.json --run",
51
- "build": "tsup"
48
+ "bench": "vitest bench",
49
+ "build": "tsup",
50
+ "prepublishOnly": "yarn build"
52
51
  },
53
52
  "repository": {
54
53
  "type": "git",
@@ -68,7 +67,10 @@
68
67
  "classname variants",
69
68
  "style variants",
70
69
  "cva",
71
- "class variance authority"
70
+ "class variance authority",
71
+ "tw",
72
+ "tailwind variants",
73
+ "stitches"
72
74
  ],
73
75
  "authors": [
74
76
  {
package/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- MIT License
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to
5
- deal in the Software without restriction, including without limitation the
6
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- sell copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
- DEALINGS IN THE SOFTWARE.
package/README.md DELETED
@@ -1,147 +0,0 @@
1
- <div align="center">
2
-
3
- # css-variants
4
-
5
- **Zero-dependency, type-safe CSS variant composition for modern JavaScript**
6
-
7
- Build powerful, flexible component style systems with variants.<br/>
8
- Perfect for Tailwind CSS, vanilla CSS, or any CSS-in-JS solution.
9
-
10
- [![test](https://github.com/timphandev/css-variants/actions/workflows/ci.yml/badge.svg)](https://github.com/timphandev/css-variants/actions/workflows/ci.yml)
11
- [![npm version](https://img.shields.io/npm/v/css-variants.svg)](https://www.npmjs.com/package/css-variants)
12
- [![Bundle Size](https://img.shields.io/bundlephobia/minzip/css-variants)](https://bundlephobia.com/package/css-variants)
13
- [![TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue)](https://www.typescriptlang.org/)
14
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
15
-
16
- [Documentation](https://css-variants.vercel.app/) · [Getting Started](https://css-variants.vercel.app/getting-started/introduction/) · [API Reference](https://css-variants.vercel.app/api/cv/)
17
-
18
- </div>
19
-
20
- ---
21
-
22
- ## Why css-variants?
23
-
24
- | | Feature |
25
- |---|---------|
26
- | ⚡ | **~1KB** — Zero dependencies, tree-shakeable |
27
- | 🔒 | **Type-Safe** — Full TypeScript inference for variants & props |
28
- | 🧩 | **Flexible** — Works with Tailwind, CSS Modules, vanilla CSS, inline styles |
29
- | 🚀 | **Fast** — Up to 10x faster than alternatives in complex scenarios |
30
-
31
- ## Installation
32
-
33
- ```bash
34
- npm install css-variants
35
- ```
36
-
37
- ## Quick Start
38
-
39
- ### Single-Element Variants (`cv`)
40
-
41
- ```typescript
42
- import { cv } from 'css-variants'
43
-
44
- const button = cv({
45
- base: 'font-semibold rounded-lg transition-colors',
46
- variants: {
47
- color: {
48
- primary: 'bg-blue-600 text-white hover:bg-blue-700',
49
- secondary: 'bg-gray-200 text-gray-900 hover:bg-gray-300',
50
- },
51
- size: {
52
- sm: 'px-3 py-1.5 text-sm',
53
- lg: 'px-6 py-3 text-lg',
54
- },
55
- },
56
- defaultVariants: { color: 'primary', size: 'sm' },
57
- })
58
-
59
- button() // Primary + Small (defaults)
60
- button({ color: 'secondary' }) // Secondary + Small
61
- button({ size: 'lg', className: 'w-full' }) // Primary + Large + custom class
62
- ```
63
-
64
- ### Multi-Element Components (`scv`)
65
-
66
- ```typescript
67
- import { scv } from 'css-variants'
68
-
69
- const card = scv({
70
- slots: ['root', 'header', 'body', 'footer'],
71
- base: {
72
- root: 'rounded-xl border shadow-sm',
73
- header: 'px-6 py-4 border-b',
74
- body: 'px-6 py-4',
75
- footer: 'px-6 py-3 bg-gray-50',
76
- },
77
- variants: {
78
- variant: {
79
- default: { root: 'bg-white border-gray-200' },
80
- danger: { root: 'bg-red-50 border-red-200', header: 'text-red-900' },
81
- },
82
- },
83
- })
84
-
85
- const styles = card({ variant: 'danger' })
86
- // styles.root → 'rounded-xl border shadow-sm bg-red-50 border-red-200'
87
- // styles.header → 'px-6 py-4 border-b text-red-900'
88
- ```
89
-
90
- ### Compound Variants
91
-
92
- Apply styles when multiple variants match:
93
-
94
- ```typescript
95
- const button = cv({
96
- variants: {
97
- color: { primary: '...', danger: '...' },
98
- size: { sm: '...', lg: '...' },
99
- },
100
- compoundVariants: [
101
- { color: 'danger', size: 'lg', className: 'font-bold uppercase' },
102
- ],
103
- })
104
- ```
105
-
106
- ### Style Variants (`sv`)
107
-
108
- For inline styles instead of class names:
109
-
110
- ```typescript
111
- import { sv } from 'css-variants'
112
-
113
- const box = sv({
114
- base: { display: 'flex', borderRadius: '8px' },
115
- variants: {
116
- size: {
117
- sm: { padding: '8px' },
118
- lg: { padding: '24px' },
119
- },
120
- },
121
- })
122
-
123
- box({ size: 'lg' }) // => { display: 'flex', borderRadius: '8px', padding: '24px' }
124
- ```
125
-
126
- ## Performance
127
-
128
- | vs cva | vs tailwind-variants |
129
- |:------:|:--------------------:|
130
- | 3-4x faster (compound variants) | 5-6x faster (compound variants) |
131
- | 4-9x faster (complex components) | 10-11x faster (complex components) |
132
-
133
- ## Documentation
134
-
135
- **[Full documentation →](https://css-variants.vercel.app/)**
136
-
137
- ## Contributing
138
-
139
- ```bash
140
- git clone https://github.com/timphandev/css-variants.git
141
- cd css-variants && yarn install
142
- yarn test && yarn build
143
- ```
144
-
145
- ## License
146
-
147
- MIT © [Tim Phan](https://github.com/timphandev)