tailwind-preset-antd 0.1.1 → 0.1.3
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.
- package/README.en-US.md +135 -135
- package/README.md +135 -135
- package/dist/components.js +0 -3
- package/dist/preset/tokens/semanticColors.js +2 -0
- package/package.json +75 -76
package/README.en-US.md
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
Use antd design token like using tailwindcss.
|
|
2
|
-
|
|
3
|
-
Provides common antd design token easier to use. Recommended to use antd v6 and tailwindcss v4, but also supports antd v5 and tailwindcss v3.
|
|
4
|
-
|
|
5
|
-
[简体中文](./README.md) | English
|
|
6
|
-
|
|
7
|
-
# Project Introduction
|
|
8
|
-
|
|
9
|
-
Before:
|
|
10
|
-
|
|
11
|
-
```tsx
|
|
12
|
-
import { theme } from "antd";
|
|
13
|
-
|
|
14
|
-
function App() {
|
|
15
|
-
const { token } = theme.useToken();
|
|
16
|
-
|
|
17
|
-
return <div style={{ backgroundColor: token.colorPrimary }}></div>;
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Now:
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
function App() {
|
|
25
|
-
return <div className="bg-colorPrimary"></div>;
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Basic Usage
|
|
30
|
-
|
|
31
|
-
### tailwindcss v4
|
|
32
|
-
|
|
33
|
-
Use plugin in your css
|
|
34
|
-
|
|
35
|
-
```css
|
|
36
|
-
@plugin "tailwind-preset-antd/plugin";
|
|
37
|
-
|
|
38
|
-
/* or
|
|
39
|
-
@plugin "tailwind-preset-antd/plugin" {
|
|
40
|
-
twPrefix: "ant";
|
|
41
|
-
cssVarPrefix: "abcd";
|
|
42
|
-
}
|
|
43
|
-
*/
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```tsx
|
|
49
|
-
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
50
|
-
|
|
51
|
-
export default function App() {
|
|
52
|
-
return (
|
|
53
|
-
<>
|
|
54
|
-
<AntdTokenCssVar />
|
|
55
|
-
</>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### tailwindcss v3
|
|
61
|
-
|
|
62
|
-
Use plugin in your `tailwind.config.ts`
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
// tailwind.config.ts
|
|
66
|
-
import type { Config } from "tailwindcss/types/config";
|
|
67
|
-
import tailwindPresetAntd from "tailwind-preset-antd/plugin";
|
|
68
|
-
|
|
69
|
-
const config: Config = {
|
|
70
|
-
// ...
|
|
71
|
-
// or custom plugins config: [tailwindPresetAntd({ twPrefix: 'ant', cssVarPrefix: 'abcd' })],
|
|
72
|
-
plugins: [tailwindPresetAntd],
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default config;
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
81
|
-
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
82
|
-
|
|
83
|
-
export default function App() {
|
|
84
|
-
return (
|
|
85
|
-
<>
|
|
86
|
-
<AntdTokenCssVar />
|
|
87
|
-
</>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
If you use the `tailwind-merge` plugin, additional configuration is required. See [Using with tailwind-merge](#using-with-tailwind-merge) for details
|
|
93
|
-
|
|
94
|
-
## Configuration Options
|
|
95
|
-
|
|
96
|
-
- `twPrefix`: tw class name prefix, default is `''`
|
|
97
|
-
- `cssVarPrefix`: Generated css var variable prefix, default is `'a'` (you must also set `AntdTokenCssVar`'s `cssVarPrefix`)
|
|
98
|
-
|
|
99
|
-
For example: when `twPrefix` is `ant` and `cssVarPrefix` is `abcd`, the generated css var variable and style are as follows:
|
|
100
|
-
|
|
101
|
-
```tsx
|
|
102
|
-
/**
|
|
103
|
-
* :root{
|
|
104
|
-
* --abcd-colorPrimary: 47 84 235;
|
|
105
|
-
* }
|
|
106
|
-
*/
|
|
107
|
-
function App() {
|
|
108
|
-
return <div className="bg-ant-colorPrimary"></div>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Generated css: .bg-ant-colorPrimary { background-color: rgb(var(--abcd-colorPrimary)); }
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Using with tailwind-merge
|
|
115
|
-
|
|
116
|
-
If you use `tailwind-merge`, additional configuration is required. See [discussions](https://github.com/tailwindlabs/tailwindcss/discussions/19260) for details on this issue
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
120
|
-
import { fontSizes } from "tailwind-preset-antd/preset";
|
|
121
|
-
|
|
122
|
-
const twMerge = extendTailwindMerge({
|
|
123
|
-
// prefix:"" // if twPrefix is configured
|
|
124
|
-
extend: {
|
|
125
|
-
theme: {
|
|
126
|
-
text: [...fontSizes], // tw-merge v3
|
|
127
|
-
// colors:[...colorPresets] // tw-merge v2
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Acknowledgments
|
|
134
|
-
|
|
135
|
-
- [react-antd-admin](https://github.com/condorheroblog/react-antd-admin): The tailwindcss plugin used in this project inspired the development of this repository
|
|
1
|
+
Use antd design token like using tailwindcss.
|
|
2
|
+
|
|
3
|
+
Provides common antd design token easier to use. Recommended to use antd v6 and tailwindcss v4, but also supports antd v5 and tailwindcss v3.
|
|
4
|
+
|
|
5
|
+
[简体中文](./README.md) | English
|
|
6
|
+
|
|
7
|
+
# Project Introduction
|
|
8
|
+
|
|
9
|
+
Before:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { theme } from "antd";
|
|
13
|
+
|
|
14
|
+
function App() {
|
|
15
|
+
const { token } = theme.useToken();
|
|
16
|
+
|
|
17
|
+
return <div style={{ backgroundColor: token.colorPrimary }}></div>;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
function App() {
|
|
25
|
+
return <div className="bg-colorPrimary"></div>;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Basic Usage
|
|
30
|
+
|
|
31
|
+
### tailwindcss v4
|
|
32
|
+
|
|
33
|
+
Use plugin in your css
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
@plugin "tailwind-preset-antd/plugin";
|
|
37
|
+
|
|
38
|
+
/* or
|
|
39
|
+
@plugin "tailwind-preset-antd/plugin" {
|
|
40
|
+
twPrefix: "ant";
|
|
41
|
+
cssVarPrefix: "abcd";
|
|
42
|
+
}
|
|
43
|
+
*/
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Import `AntdTokenCssVar` in your component. If you use theme switching, `AntdTokenCssVar` must be used inside antd `ConfigProvider`
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
50
|
+
|
|
51
|
+
export default function App() {
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<AntdTokenCssVar />
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### tailwindcss v3
|
|
61
|
+
|
|
62
|
+
Use plugin in your `tailwind.config.ts`
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
// tailwind.config.ts
|
|
66
|
+
import type { Config } from "tailwindcss/types/config";
|
|
67
|
+
import tailwindPresetAntd from "tailwind-preset-antd/plugin";
|
|
68
|
+
|
|
69
|
+
const config: Config = {
|
|
70
|
+
// ...
|
|
71
|
+
// or custom plugins config: [tailwindPresetAntd({ twPrefix: 'ant', cssVarPrefix: 'abcd' })],
|
|
72
|
+
plugins: [tailwindPresetAntd],
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default config;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Import `AntdTokenCssVar` in your component. If you use theme switching, `AntdTokenCssVar` must be used inside antd `ConfigProvider`
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
82
|
+
|
|
83
|
+
export default function App() {
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<AntdTokenCssVar />
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If you use the `tailwind-merge` plugin, additional configuration is required. See [Using with tailwind-merge](#using-with-tailwind-merge) for details
|
|
93
|
+
|
|
94
|
+
## Configuration Options
|
|
95
|
+
|
|
96
|
+
- `twPrefix`: tw class name prefix, default is `''`
|
|
97
|
+
- `cssVarPrefix`: Generated css var variable prefix, default is `'a'` (you must also set `AntdTokenCssVar`'s `cssVarPrefix`)
|
|
98
|
+
|
|
99
|
+
For example: when `twPrefix` is `ant` and `cssVarPrefix` is `abcd`, the generated css var variable and style are as follows:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
/**
|
|
103
|
+
* :root{
|
|
104
|
+
* --abcd-colorPrimary: 47 84 235;
|
|
105
|
+
* }
|
|
106
|
+
*/
|
|
107
|
+
function App() {
|
|
108
|
+
return <div className="bg-ant-colorPrimary"></div>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Generated css: .bg-ant-colorPrimary { background-color: rgb(var(--abcd-colorPrimary)); }
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Using with tailwind-merge
|
|
115
|
+
|
|
116
|
+
If you use `tailwind-merge`, additional configuration is required. See [discussions](https://github.com/tailwindlabs/tailwindcss/discussions/19260) for details on this issue
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
120
|
+
import { fontSizes } from "tailwind-preset-antd/preset";
|
|
121
|
+
|
|
122
|
+
const twMerge = extendTailwindMerge({
|
|
123
|
+
// prefix:"" // if twPrefix is configured
|
|
124
|
+
extend: {
|
|
125
|
+
theme: {
|
|
126
|
+
text: [...fontSizes], // tw-merge v3
|
|
127
|
+
// colors:[...colorPresets] // tw-merge v2
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Acknowledgments
|
|
134
|
+
|
|
135
|
+
- [react-antd-admin](https://github.com/condorheroblog/react-antd-admin): The tailwindcss plugin used in this project inspired the development of this repository
|
package/README.md
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
像使用 tailwindcss 一样使用 antd design token。
|
|
2
|
-
|
|
3
|
-
提供常用 antd design token 更易于使用。推荐使用 antd v6 和 tailwindcss v4,但同样支持 antd v5 和 tailwindcss v3。
|
|
4
|
-
|
|
5
|
-
[English](./README.en-US.md) | 简体中文
|
|
6
|
-
|
|
7
|
-
# 项目介绍
|
|
8
|
-
|
|
9
|
-
以前:
|
|
10
|
-
|
|
11
|
-
```tsx
|
|
12
|
-
import { theme } from "antd";
|
|
13
|
-
|
|
14
|
-
function App() {
|
|
15
|
-
const { token } = theme.useToken();
|
|
16
|
-
|
|
17
|
-
return <div style={{ backgroundColor: token.colorPrimary }}></div>;
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
现在:
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
function App() {
|
|
25
|
-
return <div className="bg-colorPrimary"></div>;
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 基础使用
|
|
30
|
-
|
|
31
|
-
### tailwindcss v4
|
|
32
|
-
|
|
33
|
-
在你的 css 中使用插件
|
|
34
|
-
|
|
35
|
-
```css
|
|
36
|
-
@plugin "tailwind-preset-antd/plugin";
|
|
37
|
-
|
|
38
|
-
/* or
|
|
39
|
-
@plugin "tailwind-preset-antd/plugin" {
|
|
40
|
-
twPrefix: "ant";
|
|
41
|
-
cssVarPrefix: "abcd";
|
|
42
|
-
}
|
|
43
|
-
*/
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```tsx
|
|
49
|
-
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
50
|
-
|
|
51
|
-
export default function App() {
|
|
52
|
-
return (
|
|
53
|
-
<>
|
|
54
|
-
<AntdTokenCssVar />
|
|
55
|
-
</>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### tailwindcss v3
|
|
61
|
-
|
|
62
|
-
在你的 `tailwind.config.ts` 中使用插件
|
|
63
|
-
|
|
64
|
-
```js
|
|
65
|
-
// tailwind.config.ts
|
|
66
|
-
import type { Config } from "tailwindcss/types/config";
|
|
67
|
-
import tailwindPresetAntd from "tailwind-preset-antd/plugin";
|
|
68
|
-
|
|
69
|
-
const config: Config = {
|
|
70
|
-
// ...
|
|
71
|
-
// or custom plugins config: [tailwindPresetAntd({ twPrefix: 'ant', cssVarPrefix: 'abcd' })],
|
|
72
|
-
plugins: [tailwindPresetAntd],
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default config;
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
81
|
-
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
82
|
-
|
|
83
|
-
export default function App() {
|
|
84
|
-
return (
|
|
85
|
-
<>
|
|
86
|
-
<AntdTokenCssVar />
|
|
87
|
-
</>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
如果使用了 `tailwind-merge` 插件,则需要进行额外配置,具体使用见 [与 tailwind-merge 配合使用](#与-tailwind-merge-配合使用)
|
|
93
|
-
|
|
94
|
-
## 配置项
|
|
95
|
-
|
|
96
|
-
- `twPrefix`: tw 类名前缀,默认为 `''`
|
|
97
|
-
- `cssVarPrefix`: 生成的 css var 变量前缀,默认为 `'a'`(你必须同时设置 `AntdTokenCssVar` 的 `cssVarPrefix`)
|
|
98
|
-
|
|
99
|
-
例如:当 twPrefix 为 `ant` 时,`cssVarPrefix` 为 `abcd` 时,生成的 css var 变量及样式如下:
|
|
100
|
-
|
|
101
|
-
```tsx
|
|
102
|
-
/**
|
|
103
|
-
* :root{
|
|
104
|
-
* --abcd-colorPrimary: 47 84 235;
|
|
105
|
-
* }
|
|
106
|
-
*/
|
|
107
|
-
function App() {
|
|
108
|
-
return <div className="bg-ant-colorPrimary"></div>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// 生成的 css: .bg-ant-colorPrimary { background-color: rgb(var(--abcd-colorPrimary)); }
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### 与 tailwind-merge 配合使用
|
|
115
|
-
|
|
116
|
-
如果使用 `tailwind-merge`,需进行额外配置,此问题详见 [discussions](https://github.com/tailwindlabs/tailwindcss/discussions/19260)
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
120
|
-
import { fontSizes } from "tailwind-preset-antd/preset";
|
|
121
|
-
|
|
122
|
-
const twMerge = extendTailwindMerge({
|
|
123
|
-
// prefix:"" // 如果配置了 twPrefix
|
|
124
|
-
extend: {
|
|
125
|
-
theme: {
|
|
126
|
-
text: [...fontSizes], // tw-merge v3
|
|
127
|
-
// colors:[...colorPresets] // tw-merge v2
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## 鸣谢
|
|
134
|
-
|
|
135
|
-
- [react-antd-admin](https://github.com/condorheroblog/react-antd-admin):此项目的 tailwindcss 插件使用启发了此仓库的开发
|
|
1
|
+
像使用 tailwindcss 一样使用 antd design token。
|
|
2
|
+
|
|
3
|
+
提供常用 antd design token 更易于使用。推荐使用 antd v6 和 tailwindcss v4,但同样支持 antd v5 和 tailwindcss v3。
|
|
4
|
+
|
|
5
|
+
[English](./README.en-US.md) | 简体中文
|
|
6
|
+
|
|
7
|
+
# 项目介绍
|
|
8
|
+
|
|
9
|
+
以前:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { theme } from "antd";
|
|
13
|
+
|
|
14
|
+
function App() {
|
|
15
|
+
const { token } = theme.useToken();
|
|
16
|
+
|
|
17
|
+
return <div style={{ backgroundColor: token.colorPrimary }}></div>;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
现在:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
function App() {
|
|
25
|
+
return <div className="bg-colorPrimary"></div>;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 基础使用
|
|
30
|
+
|
|
31
|
+
### tailwindcss v4
|
|
32
|
+
|
|
33
|
+
在你的 css 中使用插件
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
@plugin "tailwind-preset-antd/plugin";
|
|
37
|
+
|
|
38
|
+
/* or
|
|
39
|
+
@plugin "tailwind-preset-antd/plugin" {
|
|
40
|
+
twPrefix: "ant";
|
|
41
|
+
cssVarPrefix: "abcd";
|
|
42
|
+
}
|
|
43
|
+
*/
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
在你的组件中导入 `AntdTokenCssVar`。如果你使用主题切换,则 `AntdTokenCssVar` 必须在 antd `ConfigProvider` 中使用
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
50
|
+
|
|
51
|
+
export default function App() {
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<AntdTokenCssVar />
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### tailwindcss v3
|
|
61
|
+
|
|
62
|
+
在你的 `tailwind.config.ts` 中使用插件
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
// tailwind.config.ts
|
|
66
|
+
import type { Config } from "tailwindcss/types/config";
|
|
67
|
+
import tailwindPresetAntd from "tailwind-preset-antd/plugin";
|
|
68
|
+
|
|
69
|
+
const config: Config = {
|
|
70
|
+
// ...
|
|
71
|
+
// or custom plugins config: [tailwindPresetAntd({ twPrefix: 'ant', cssVarPrefix: 'abcd' })],
|
|
72
|
+
plugins: [tailwindPresetAntd],
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default config;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
在你的组件中导入 `AntdTokenCssVar`。如果你使用主题切换,则 `AntdTokenCssVar` 必须在 antd `ConfigProvider` 中使用
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import AntdTokenCssVar from "tailwind-preset-antd/components";
|
|
82
|
+
|
|
83
|
+
export default function App() {
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<AntdTokenCssVar />
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
如果使用了 `tailwind-merge` 插件,则需要进行额外配置,具体使用见 [与 tailwind-merge 配合使用](#与-tailwind-merge-配合使用)
|
|
93
|
+
|
|
94
|
+
## 配置项
|
|
95
|
+
|
|
96
|
+
- `twPrefix`: tw 类名前缀,默认为 `''`
|
|
97
|
+
- `cssVarPrefix`: 生成的 css var 变量前缀,默认为 `'a'`(你必须同时设置 `AntdTokenCssVar` 的 `cssVarPrefix`)
|
|
98
|
+
|
|
99
|
+
例如:当 twPrefix 为 `ant` 时,`cssVarPrefix` 为 `abcd` 时,生成的 css var 变量及样式如下:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
/**
|
|
103
|
+
* :root{
|
|
104
|
+
* --abcd-colorPrimary: 47 84 235;
|
|
105
|
+
* }
|
|
106
|
+
*/
|
|
107
|
+
function App() {
|
|
108
|
+
return <div className="bg-ant-colorPrimary"></div>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 生成的 css: .bg-ant-colorPrimary { background-color: rgb(var(--abcd-colorPrimary)); }
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 与 tailwind-merge 配合使用
|
|
115
|
+
|
|
116
|
+
如果使用 `tailwind-merge`,需进行额外配置,此问题详见 [discussions](https://github.com/tailwindlabs/tailwindcss/discussions/19260)
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
120
|
+
import { fontSizes } from "tailwind-preset-antd/preset";
|
|
121
|
+
|
|
122
|
+
const twMerge = extendTailwindMerge({
|
|
123
|
+
// prefix:"" // 如果配置了 twPrefix
|
|
124
|
+
extend: {
|
|
125
|
+
theme: {
|
|
126
|
+
text: [...fontSizes], // tw-merge v3
|
|
127
|
+
// colors:[...colorPresets] // tw-merge v2
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 鸣谢
|
|
134
|
+
|
|
135
|
+
- [react-antd-admin](https://github.com/condorheroblog/react-antd-admin):此项目的 tailwindcss 插件使用启发了此仓库的开发
|
package/dist/components.js
CHANGED
|
@@ -17,9 +17,6 @@ function AntdTokenCssVar(props) {
|
|
|
17
17
|
style.setAttribute("plugin-name", "tailwind-preset-antd");
|
|
18
18
|
style.textContent = `:root{${cssVar}}`;
|
|
19
19
|
document.head.appendChild(style);
|
|
20
|
-
return () => {
|
|
21
|
-
document.head.removeChild(style);
|
|
22
|
-
};
|
|
23
20
|
}, [token, cssVarPrefix]);
|
|
24
21
|
return null;
|
|
25
22
|
}
|
package/package.json
CHANGED
|
@@ -1,76 +1,75 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tailwind-preset-antd",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Use antd design token like using tailwindcss",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"antd",
|
|
7
|
-
"tailwindcss"
|
|
8
|
-
],
|
|
9
|
-
"homepage": "https://json-q.github.io/tailwind-preset-antd/",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"author": "json-q",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/json-q/tailwind-preset-antd.git"
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"type": "module",
|
|
20
|
-
"sideEffects": false,
|
|
21
|
-
"exports": {
|
|
22
|
-
"./components": "./dist/components.js",
|
|
23
|
-
"./plugin": "./dist/plugin.js",
|
|
24
|
-
"./preset": "./dist/preset.js",
|
|
25
|
-
"./package.json": "./package.json"
|
|
26
|
-
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tailwind-preset-antd",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Use antd design token like using tailwindcss",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"antd",
|
|
7
|
+
"tailwindcss"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://json-q.github.io/tailwind-preset-antd/",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "json-q",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/json-q/tailwind-preset-antd.git"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"exports": {
|
|
22
|
+
"./components": "./dist/components.js",
|
|
23
|
+
"./plugin": "./dist/plugin.js",
|
|
24
|
+
"./preset": "./dist/preset.js",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"hex-rgb": "^5.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@tailwindcss/vite": "^4.2.4",
|
|
32
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
33
|
+
"@testing-library/react": "^16.3.2",
|
|
34
|
+
"@types/node": "^25.6.2",
|
|
35
|
+
"@types/react": "^19.2.14",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
38
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
39
|
+
"bumpp": "^11.1.0",
|
|
40
|
+
"jsdom": "^29.1.1",
|
|
41
|
+
"oxfmt": "^0.48.0",
|
|
42
|
+
"oxlint": "^1.63.0",
|
|
43
|
+
"postcss": "^8.5.14",
|
|
44
|
+
"publint": "^0.3.19",
|
|
45
|
+
"react-dom": "^19.2.6",
|
|
46
|
+
"tailwindcss": "^4.2.4",
|
|
47
|
+
"tsdown": "^0.22.0",
|
|
48
|
+
"typescript": "^6.0.3",
|
|
49
|
+
"vite": "^8.0.11",
|
|
50
|
+
"vitest": "^4.1.5"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"antd": ">=5",
|
|
54
|
+
"react": ">=16.9.0",
|
|
55
|
+
"tailwindcss": "^3 || ^4"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"play": "vite",
|
|
59
|
+
"build:play": "vite build",
|
|
60
|
+
"preview:play": "vite preview",
|
|
61
|
+
"build": "tsdown",
|
|
62
|
+
"dev": "tsdown --watch",
|
|
63
|
+
"test": "vitest",
|
|
64
|
+
"ui": "vitest --ui",
|
|
65
|
+
"snapshot": "vitest -u",
|
|
66
|
+
"coverage": "vitest run --coverage",
|
|
67
|
+
"release": "bumpp",
|
|
68
|
+
"lint:package": "publint",
|
|
69
|
+
"typecheck": "tsc --noEmit",
|
|
70
|
+
"lint": "oxlint",
|
|
71
|
+
"lint:fix": "oxlint --fix",
|
|
72
|
+
"fmt": "oxfmt",
|
|
73
|
+
"fmt:check": "oxfmt --check"
|
|
74
|
+
}
|
|
75
|
+
}
|