@modern-js/module-tools-docs 2.32.1 → 2.33.0
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/.eslintrc.js +1 -1
- package/CHANGELOG.md +11 -0
- package/docs/en/api/config/build-config.mdx +17 -16
- package/docs/en/api/config/build-preset.mdx +11 -72
- package/docs/en/guide/advance/asset.mdx +1 -1
- package/docs/en/guide/advance/copy.md +17 -18
- package/docs/en/guide/advance/external-dependency.mdx +1 -1
- package/docs/en/guide/advance/in-depth-about-build.md +27 -28
- package/docs/en/guide/advance/in-depth-about-dev-command.md +1 -1
- package/docs/en/guide/basic/before-getting-started.md +1 -1
- package/docs/en/guide/basic/modify-output-product.md +44 -70
- package/docs/en/guide/basic/test-your-project.mdx +0 -2
- package/docs/en/guide/basic/use-micro-generator.md +12 -37
- package/docs/en/guide/basic/using-storybook.mdx +15 -0
- package/docs/en/guide/best-practices/components.mdx +5 -198
- package/docs/en/guide/best-practices/use-tailwindcss.mdx +289 -0
- package/docs/en/plugins/guide/setup-function.mdx +0 -1
- package/docs/zh/api/config/build-config.mdx +19 -20
- package/docs/zh/api/config/build-preset.mdx +12 -69
- package/docs/zh/guide/advance/asset.mdx +3 -6
- package/docs/zh/guide/advance/copy.md +0 -2
- package/docs/zh/guide/advance/external-dependency.mdx +1 -1
- package/docs/zh/guide/advance/in-depth-about-build.md +30 -56
- package/docs/zh/guide/basic/before-getting-started.md +1 -1
- package/docs/zh/guide/basic/modify-output-product.md +46 -69
- package/docs/zh/guide/basic/use-micro-generator.md +13 -33
- package/docs/zh/guide/basic/using-storybook.mdx +16 -5
- package/docs/zh/guide/best-practices/components.mdx +1 -196
- package/docs/zh/guide/best-practices/use-tailwindcss.mdx +289 -0
- package/docs/zh/plugins/guide/setup-function.mdx +0 -1
- package/package.json +7 -6
- package/rspress.config.ts +130 -0
- package/theme/index.ts +3 -2
- package/tsconfig.json +1 -1
- package/docs/en/api/config/design-system.md +0 -1166
- package/docs/en/guide/advance/theme-config.mdx +0 -60
- package/docs/zh/api/config/design-system.md +0 -1166
- package/docs/zh/guide/advance/theme-config.mdx +0 -64
- package/modern.config.ts +0 -124
|
@@ -1,1166 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 3
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# designSystem
|
|
6
|
-
|
|
7
|
-
This chapter describes the configuration related to designSystem.
|
|
8
|
-
|
|
9
|
-
:::tip
|
|
10
|
-
The Tailwind CSS feature needs to be enabled first via `pnpm run new`.
|
|
11
|
-
:::
|
|
12
|
-
|
|
13
|
-
- Type: `object`
|
|
14
|
-
- Default: `see configuration details below`.
|
|
15
|
-
|
|
16
|
-
<details>
|
|
17
|
-
<summary>designSystem configuration details</summary>
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
const designSystem = {
|
|
21
|
-
screens: {
|
|
22
|
-
sm: '640px',
|
|
23
|
-
md: '768px',
|
|
24
|
-
lg: '1024px',
|
|
25
|
-
xl: '1280px',
|
|
26
|
-
},
|
|
27
|
-
colors: {
|
|
28
|
-
transparent: 'transparent',
|
|
29
|
-
current: 'currentColor',
|
|
30
|
-
|
|
31
|
-
black: '#000',
|
|
32
|
-
white: '#fff',
|
|
33
|
-
|
|
34
|
-
gray: {
|
|
35
|
-
100: '#f7fafc',
|
|
36
|
-
200: '#edf2f7',
|
|
37
|
-
300: '#e2e8f0',
|
|
38
|
-
400: '#cbd5e0',
|
|
39
|
-
500: '#a0aec0',
|
|
40
|
-
600: '#718096',
|
|
41
|
-
700: '#4a5568',
|
|
42
|
-
800: '#2d3748',
|
|
43
|
-
900: '#1a202c',
|
|
44
|
-
},
|
|
45
|
-
red: {
|
|
46
|
-
100: '#fff5f5',
|
|
47
|
-
200: '#fed7d7',
|
|
48
|
-
300: '#feb2b2',
|
|
49
|
-
400: '#fc8181',
|
|
50
|
-
500: '#f56565',
|
|
51
|
-
600: '#e53e3e',
|
|
52
|
-
700: '#c53030',
|
|
53
|
-
800: '#9b2c2c',
|
|
54
|
-
900: '#742a2a',
|
|
55
|
-
},
|
|
56
|
-
orange: {
|
|
57
|
-
100: '#fffaf0',
|
|
58
|
-
200: '#feebc8',
|
|
59
|
-
300: '#fbd38d',
|
|
60
|
-
400: '#f6ad55',
|
|
61
|
-
500: '#ed8936',
|
|
62
|
-
600: '#dd6b20',
|
|
63
|
-
700: '#c05621',
|
|
64
|
-
800: '#9c4221',
|
|
65
|
-
900: '#7b341e',
|
|
66
|
-
},
|
|
67
|
-
yellow: {
|
|
68
|
-
100: '#fffff0',
|
|
69
|
-
200: '#fefcbf',
|
|
70
|
-
300: '#faf089',
|
|
71
|
-
400: '#f6e05e',
|
|
72
|
-
500: '#ecc94b',
|
|
73
|
-
600: '#d69e2e',
|
|
74
|
-
700: '#b7791f',
|
|
75
|
-
800: '#975a16',
|
|
76
|
-
900: '#744210',
|
|
77
|
-
},
|
|
78
|
-
green: {
|
|
79
|
-
100: '#f0fff4',
|
|
80
|
-
200: '#c6f6d5',
|
|
81
|
-
300: '#9ae6b4',
|
|
82
|
-
400: '#68d391',
|
|
83
|
-
500: '#48bb78',
|
|
84
|
-
600: '#38a169',
|
|
85
|
-
700: '#2f855a',
|
|
86
|
-
800: '#276749',
|
|
87
|
-
900: '#22543d',
|
|
88
|
-
},
|
|
89
|
-
teal: {
|
|
90
|
-
100: '#e6fffa',
|
|
91
|
-
200: '#b2f5ea',
|
|
92
|
-
300: '#81e6d9',
|
|
93
|
-
400: '#4fd1c5',
|
|
94
|
-
500: '#38b2ac',
|
|
95
|
-
600: '#319795',
|
|
96
|
-
700: '#2c7a7b',
|
|
97
|
-
800: '#285e61',
|
|
98
|
-
900: '#234e52',
|
|
99
|
-
},
|
|
100
|
-
blue: {
|
|
101
|
-
100: '#ebf8ff',
|
|
102
|
-
200: '#bee3f8',
|
|
103
|
-
300: '#90cdf4',
|
|
104
|
-
400: '#63b3ed',
|
|
105
|
-
500: '#4299e1',
|
|
106
|
-
600: '#3182ce',
|
|
107
|
-
700: '#2b6cb0',
|
|
108
|
-
800: '#2c5282',
|
|
109
|
-
900: '#2a4365',
|
|
110
|
-
},
|
|
111
|
-
indigo: {
|
|
112
|
-
100: '#ebf4ff',
|
|
113
|
-
200: '#c3dafe',
|
|
114
|
-
300: '#a3bffa',
|
|
115
|
-
400: '#7f9cf5',
|
|
116
|
-
500: '#667eea',
|
|
117
|
-
600: '#5a67d8',
|
|
118
|
-
700: '#4c51bf',
|
|
119
|
-
800: '#434190',
|
|
120
|
-
900: '#3c366b',
|
|
121
|
-
},
|
|
122
|
-
purple: {
|
|
123
|
-
100: '#faf5ff',
|
|
124
|
-
200: '#e9d8fd',
|
|
125
|
-
300: '#d6bcfa',
|
|
126
|
-
400: '#b794f4',
|
|
127
|
-
500: '#9f7aea',
|
|
128
|
-
600: '#805ad5',
|
|
129
|
-
700: '#6b46c1',
|
|
130
|
-
800: '#553c9a',
|
|
131
|
-
900: '#44337a',
|
|
132
|
-
},
|
|
133
|
-
pink: {
|
|
134
|
-
100: '#fff5f7',
|
|
135
|
-
200: '#fed7e2',
|
|
136
|
-
300: '#fbb6ce',
|
|
137
|
-
400: '#f687b3',
|
|
138
|
-
500: '#ed64a6',
|
|
139
|
-
600: '#d53f8c',
|
|
140
|
-
700: '#b83280',
|
|
141
|
-
800: '#97266d',
|
|
142
|
-
900: '#702459',
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
spacing: {
|
|
146
|
-
px: '1px',
|
|
147
|
-
0: '0',
|
|
148
|
-
1: '0.25rem',
|
|
149
|
-
2: '0.5rem',
|
|
150
|
-
3: '0.75rem',
|
|
151
|
-
4: '1rem',
|
|
152
|
-
5: '1.25rem',
|
|
153
|
-
6: '1.5rem',
|
|
154
|
-
8: '2rem',
|
|
155
|
-
10: '2.5rem',
|
|
156
|
-
12: '3rem',
|
|
157
|
-
16: '4rem',
|
|
158
|
-
20: '5rem',
|
|
159
|
-
24: '6rem',
|
|
160
|
-
32: '8rem',
|
|
161
|
-
40: '10rem',
|
|
162
|
-
48: '12rem',
|
|
163
|
-
56: '14rem',
|
|
164
|
-
64: '16rem',
|
|
165
|
-
},
|
|
166
|
-
backgroundColor: theme => theme('colors'),
|
|
167
|
-
backgroundOpacity: theme => theme('opacity'),
|
|
168
|
-
backgroundPosition: {
|
|
169
|
-
bottom: 'bottom',
|
|
170
|
-
center: 'center',
|
|
171
|
-
left: 'left',
|
|
172
|
-
'left-bottom': 'left bottom',
|
|
173
|
-
'left-top': 'left top',
|
|
174
|
-
right: 'right',
|
|
175
|
-
'right-bottom': 'right bottom',
|
|
176
|
-
'right-top': 'right top',
|
|
177
|
-
top: 'top',
|
|
178
|
-
},
|
|
179
|
-
backgroundSize: {
|
|
180
|
-
auto: 'auto',
|
|
181
|
-
cover: 'cover',
|
|
182
|
-
contain: 'contain',
|
|
183
|
-
},
|
|
184
|
-
borderColor: theme => ({
|
|
185
|
-
...theme('colors'),
|
|
186
|
-
default: theme('colors.gray.300', 'currentColor'),
|
|
187
|
-
}),
|
|
188
|
-
borderOpacity: theme => theme('opacity'),
|
|
189
|
-
borderRadius: {
|
|
190
|
-
none: '0',
|
|
191
|
-
sm: '0.125rem',
|
|
192
|
-
default: '0.25rem',
|
|
193
|
-
md: '0.375rem',
|
|
194
|
-
lg: '0.5rem',
|
|
195
|
-
full: '9999px',
|
|
196
|
-
},
|
|
197
|
-
borderWidth: {
|
|
198
|
-
default: '1px',
|
|
199
|
-
0: '0',
|
|
200
|
-
2: '2px',
|
|
201
|
-
4: '4px',
|
|
202
|
-
8: '8px',
|
|
203
|
-
},
|
|
204
|
-
boxShadow: {
|
|
205
|
-
xs: '0 0 0 1px rgba(0, 0, 0, 0.05)',
|
|
206
|
-
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
207
|
-
default: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
|
|
208
|
-
md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
|
209
|
-
lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
|
210
|
-
xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
|
|
211
|
-
'2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
|
|
212
|
-
inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
|
|
213
|
-
outline: '0 0 0 3px rgba(66, 153, 225, 0.5)',
|
|
214
|
-
none: 'none',
|
|
215
|
-
},
|
|
216
|
-
container: {},
|
|
217
|
-
cursor: {
|
|
218
|
-
auto: 'auto',
|
|
219
|
-
default: 'default',
|
|
220
|
-
pointer: 'pointer',
|
|
221
|
-
wait: 'wait',
|
|
222
|
-
text: 'text',
|
|
223
|
-
move: 'move',
|
|
224
|
-
'not-allowed': 'not-allowed',
|
|
225
|
-
},
|
|
226
|
-
divideColor: theme => theme('borderColor'),
|
|
227
|
-
divideOpacity: theme => theme('borderOpacity'),
|
|
228
|
-
divideWidth: theme => theme('borderWidth'),
|
|
229
|
-
fill: {
|
|
230
|
-
current: 'currentColor',
|
|
231
|
-
},
|
|
232
|
-
flex: {
|
|
233
|
-
1: '1 1 0%',
|
|
234
|
-
auto: '1 1 auto',
|
|
235
|
-
initial: '0 1 auto',
|
|
236
|
-
none: 'none',
|
|
237
|
-
},
|
|
238
|
-
flexGrow: {
|
|
239
|
-
0: '0',
|
|
240
|
-
default: '1',
|
|
241
|
-
},
|
|
242
|
-
flexShrink: {
|
|
243
|
-
0: '0',
|
|
244
|
-
default: '1',
|
|
245
|
-
},
|
|
246
|
-
fontFamily: {
|
|
247
|
-
sans: [
|
|
248
|
-
'system-ui',
|
|
249
|
-
'-apple-system',
|
|
250
|
-
'BlinkMacSystemFont',
|
|
251
|
-
'"Segoe UI"',
|
|
252
|
-
'Roboto',
|
|
253
|
-
'"Helvetica Neue"',
|
|
254
|
-
'Arial',
|
|
255
|
-
'"Noto Sans"',
|
|
256
|
-
'sans-serif',
|
|
257
|
-
'"Apple Color Emoji"',
|
|
258
|
-
'"Segoe UI Emoji"',
|
|
259
|
-
'"Segoe UI Symbol"',
|
|
260
|
-
'"Noto Color Emoji"',
|
|
261
|
-
],
|
|
262
|
-
serif: ['Georgia', 'Cambria', '"Times New Roman"', 'Times', 'serif'],
|
|
263
|
-
mono: [
|
|
264
|
-
'Menlo',
|
|
265
|
-
'Monaco',
|
|
266
|
-
'Consolas',
|
|
267
|
-
'"Liberation Mono"',
|
|
268
|
-
'"Courier New"',
|
|
269
|
-
'monospace',
|
|
270
|
-
],
|
|
271
|
-
},
|
|
272
|
-
fontSize: {
|
|
273
|
-
xs: '0.75rem',
|
|
274
|
-
sm: '0.875rem',
|
|
275
|
-
base: '1rem',
|
|
276
|
-
lg: '1.125rem',
|
|
277
|
-
xl: '1.25rem',
|
|
278
|
-
'2xl': '1.5rem',
|
|
279
|
-
'3xl': '1.875rem',
|
|
280
|
-
'4xl': '2.25rem',
|
|
281
|
-
'5xl': '3rem',
|
|
282
|
-
'6xl': '4rem',
|
|
283
|
-
},
|
|
284
|
-
fontWeight: {
|
|
285
|
-
hairline: '100',
|
|
286
|
-
thin: '200',
|
|
287
|
-
light: '300',
|
|
288
|
-
normal: '400',
|
|
289
|
-
medium: '500',
|
|
290
|
-
semibold: '600',
|
|
291
|
-
bold: '700',
|
|
292
|
-
extrabold: '800',
|
|
293
|
-
black: '900',
|
|
294
|
-
},
|
|
295
|
-
height: theme => ({
|
|
296
|
-
auto: 'auto',
|
|
297
|
-
...theme('spacing'),
|
|
298
|
-
full: '100%',
|
|
299
|
-
screen: '100vh',
|
|
300
|
-
}),
|
|
301
|
-
inset: {
|
|
302
|
-
0: '0',
|
|
303
|
-
auto: 'auto',
|
|
304
|
-
},
|
|
305
|
-
letterSpacing: {
|
|
306
|
-
tighter: '-0.05em',
|
|
307
|
-
tight: '-0.025em',
|
|
308
|
-
normal: '0',
|
|
309
|
-
wide: '0.025em',
|
|
310
|
-
wider: '0.05em',
|
|
311
|
-
widest: '0.1em',
|
|
312
|
-
},
|
|
313
|
-
lineHeight: {
|
|
314
|
-
none: '1',
|
|
315
|
-
tight: '1.25',
|
|
316
|
-
snug: '1.375',
|
|
317
|
-
normal: '1.5',
|
|
318
|
-
relaxed: '1.625',
|
|
319
|
-
loose: '2',
|
|
320
|
-
3: '.75rem',
|
|
321
|
-
4: '1rem',
|
|
322
|
-
5: '1.25rem',
|
|
323
|
-
6: '1.5rem',
|
|
324
|
-
7: '1.75rem',
|
|
325
|
-
8: '2rem',
|
|
326
|
-
9: '2.25rem',
|
|
327
|
-
10: '2.5rem',
|
|
328
|
-
},
|
|
329
|
-
listStyleType: {
|
|
330
|
-
none: 'none',
|
|
331
|
-
disc: 'disc',
|
|
332
|
-
decimal: 'decimal',
|
|
333
|
-
},
|
|
334
|
-
margin: (theme, { negative }) => ({
|
|
335
|
-
auto: 'auto',
|
|
336
|
-
...theme('spacing'),
|
|
337
|
-
...negative(theme('spacing')),
|
|
338
|
-
}),
|
|
339
|
-
maxHeight: {
|
|
340
|
-
full: '100%',
|
|
341
|
-
screen: '100vh',
|
|
342
|
-
},
|
|
343
|
-
maxWidth: (theme, { breakpoints }) => ({
|
|
344
|
-
none: 'none',
|
|
345
|
-
xs: '20rem',
|
|
346
|
-
sm: '24rem',
|
|
347
|
-
md: '28rem',
|
|
348
|
-
lg: '32rem',
|
|
349
|
-
xl: '36rem',
|
|
350
|
-
'2xl': '42rem',
|
|
351
|
-
'3xl': '48rem',
|
|
352
|
-
'4xl': '56rem',
|
|
353
|
-
'5xl': '64rem',
|
|
354
|
-
'6xl': '72rem',
|
|
355
|
-
full: '100%',
|
|
356
|
-
...breakpoints(theme('screens')),
|
|
357
|
-
}),
|
|
358
|
-
minHeight: {
|
|
359
|
-
0: '0',
|
|
360
|
-
full: '100%',
|
|
361
|
-
screen: '100vh',
|
|
362
|
-
},
|
|
363
|
-
minWidth: {
|
|
364
|
-
0: '0',
|
|
365
|
-
full: '100%',
|
|
366
|
-
},
|
|
367
|
-
objectPosition: {
|
|
368
|
-
bottom: 'bottom',
|
|
369
|
-
center: 'center',
|
|
370
|
-
left: 'left',
|
|
371
|
-
'left-bottom': 'left bottom',
|
|
372
|
-
'left-top': 'left top',
|
|
373
|
-
right: 'right',
|
|
374
|
-
'right-bottom': 'right bottom',
|
|
375
|
-
'right-top': 'right top',
|
|
376
|
-
top: 'top',
|
|
377
|
-
},
|
|
378
|
-
opacity: {
|
|
379
|
-
0: '0',
|
|
380
|
-
25: '0.25',
|
|
381
|
-
50: '0.5',
|
|
382
|
-
75: '0.75',
|
|
383
|
-
100: '1',
|
|
384
|
-
},
|
|
385
|
-
order: {
|
|
386
|
-
first: '-9999',
|
|
387
|
-
last: '9999',
|
|
388
|
-
none: '0',
|
|
389
|
-
1: '1',
|
|
390
|
-
2: '2',
|
|
391
|
-
3: '3',
|
|
392
|
-
4: '4',
|
|
393
|
-
5: '5',
|
|
394
|
-
6: '6',
|
|
395
|
-
7: '7',
|
|
396
|
-
8: '8',
|
|
397
|
-
9: '9',
|
|
398
|
-
10: '10',
|
|
399
|
-
11: '11',
|
|
400
|
-
12: '12',
|
|
401
|
-
},
|
|
402
|
-
padding: theme => theme('spacing'),
|
|
403
|
-
placeholderColor: theme => theme('colors'),
|
|
404
|
-
placeholderOpacity: theme => theme('opacity'),
|
|
405
|
-
space: (theme, { negative }) => ({
|
|
406
|
-
...theme('spacing'),
|
|
407
|
-
...negative(theme('spacing')),
|
|
408
|
-
}),
|
|
409
|
-
stroke: {
|
|
410
|
-
current: 'currentColor',
|
|
411
|
-
},
|
|
412
|
-
strokeWidth: {
|
|
413
|
-
0: '0',
|
|
414
|
-
1: '1',
|
|
415
|
-
2: '2',
|
|
416
|
-
},
|
|
417
|
-
textColor: theme => theme('colors'),
|
|
418
|
-
textOpacity: theme => theme('opacity'),
|
|
419
|
-
width: theme => ({
|
|
420
|
-
auto: 'auto',
|
|
421
|
-
...theme('spacing'),
|
|
422
|
-
'1/2': '50%',
|
|
423
|
-
'1/3': '33.333333%',
|
|
424
|
-
'2/3': '66.666667%',
|
|
425
|
-
'1/4': '25%',
|
|
426
|
-
'2/4': '50%',
|
|
427
|
-
'3/4': '75%',
|
|
428
|
-
'1/5': '20%',
|
|
429
|
-
'2/5': '40%',
|
|
430
|
-
'3/5': '60%',
|
|
431
|
-
'4/5': '80%',
|
|
432
|
-
'1/6': '16.666667%',
|
|
433
|
-
'2/6': '33.333333%',
|
|
434
|
-
'3/6': '50%',
|
|
435
|
-
'4/6': '66.666667%',
|
|
436
|
-
'5/6': '83.333333%',
|
|
437
|
-
'1/12': '8.333333%',
|
|
438
|
-
'2/12': '16.666667%',
|
|
439
|
-
'3/12': '25%',
|
|
440
|
-
'4/12': '33.333333%',
|
|
441
|
-
'5/12': '41.666667%',
|
|
442
|
-
'6/12': '50%',
|
|
443
|
-
'7/12': '58.333333%',
|
|
444
|
-
'8/12': '66.666667%',
|
|
445
|
-
'9/12': '75%',
|
|
446
|
-
'10/12': '83.333333%',
|
|
447
|
-
'11/12': '91.666667%',
|
|
448
|
-
full: '100%',
|
|
449
|
-
screen: '100vw',
|
|
450
|
-
}),
|
|
451
|
-
zIndex: {
|
|
452
|
-
auto: 'auto',
|
|
453
|
-
0: '0',
|
|
454
|
-
10: '10',
|
|
455
|
-
20: '20',
|
|
456
|
-
30: '30',
|
|
457
|
-
40: '40',
|
|
458
|
-
50: '50',
|
|
459
|
-
},
|
|
460
|
-
gap: theme => theme('spacing'),
|
|
461
|
-
gridTemplateColumns: {
|
|
462
|
-
none: 'none',
|
|
463
|
-
1: 'repeat(1, minmax(0, 1fr))',
|
|
464
|
-
2: 'repeat(2, minmax(0, 1fr))',
|
|
465
|
-
3: 'repeat(3, minmax(0, 1fr))',
|
|
466
|
-
4: 'repeat(4, minmax(0, 1fr))',
|
|
467
|
-
5: 'repeat(5, minmax(0, 1fr))',
|
|
468
|
-
6: 'repeat(6, minmax(0, 1fr))',
|
|
469
|
-
7: 'repeat(7, minmax(0, 1fr))',
|
|
470
|
-
8: 'repeat(8, minmax(0, 1fr))',
|
|
471
|
-
9: 'repeat(9, minmax(0, 1fr))',
|
|
472
|
-
10: 'repeat(10, minmax(0, 1fr))',
|
|
473
|
-
11: 'repeat(11, minmax(0, 1fr))',
|
|
474
|
-
12: 'repeat(12, minmax(0, 1fr))',
|
|
475
|
-
},
|
|
476
|
-
gridColumn: {
|
|
477
|
-
auto: 'auto',
|
|
478
|
-
'span-1': 'span 1 / span 1',
|
|
479
|
-
'span-2': 'span 2 / span 2',
|
|
480
|
-
'span-3': 'span 3 / span 3',
|
|
481
|
-
'span-4': 'span 4 / span 4',
|
|
482
|
-
'span-5': 'span 5 / span 5',
|
|
483
|
-
'span-6': 'span 6 / span 6',
|
|
484
|
-
'span-7': 'span 7 / span 7',
|
|
485
|
-
'span-8': 'span 8 / span 8',
|
|
486
|
-
'span-9': 'span 9 / span 9',
|
|
487
|
-
'span-10': 'span 10 / span 10',
|
|
488
|
-
'span-11': 'span 11 / span 11',
|
|
489
|
-
'span-12': 'span 12 / span 12',
|
|
490
|
-
},
|
|
491
|
-
gridColumnStart: {
|
|
492
|
-
auto: 'auto',
|
|
493
|
-
1: '1',
|
|
494
|
-
2: '2',
|
|
495
|
-
3: '3',
|
|
496
|
-
4: '4',
|
|
497
|
-
5: '5',
|
|
498
|
-
6: '6',
|
|
499
|
-
7: '7',
|
|
500
|
-
8: '8',
|
|
501
|
-
9: '9',
|
|
502
|
-
10: '10',
|
|
503
|
-
11: '11',
|
|
504
|
-
12: '12',
|
|
505
|
-
13: '13',
|
|
506
|
-
},
|
|
507
|
-
gridColumnEnd: {
|
|
508
|
-
auto: 'auto',
|
|
509
|
-
1: '1',
|
|
510
|
-
2: '2',
|
|
511
|
-
3: '3',
|
|
512
|
-
4: '4',
|
|
513
|
-
5: '5',
|
|
514
|
-
6: '6',
|
|
515
|
-
7: '7',
|
|
516
|
-
8: '8',
|
|
517
|
-
9: '9',
|
|
518
|
-
10: '10',
|
|
519
|
-
11: '11',
|
|
520
|
-
12: '12',
|
|
521
|
-
13: '13',
|
|
522
|
-
},
|
|
523
|
-
gridTemplateRows: {
|
|
524
|
-
none: 'none',
|
|
525
|
-
1: 'repeat(1, minmax(0, 1fr))',
|
|
526
|
-
2: 'repeat(2, minmax(0, 1fr))',
|
|
527
|
-
3: 'repeat(3, minmax(0, 1fr))',
|
|
528
|
-
4: 'repeat(4, minmax(0, 1fr))',
|
|
529
|
-
5: 'repeat(5, minmax(0, 1fr))',
|
|
530
|
-
6: 'repeat(6, minmax(0, 1fr))',
|
|
531
|
-
},
|
|
532
|
-
gridRow: {
|
|
533
|
-
auto: 'auto',
|
|
534
|
-
'span-1': 'span 1 / span 1',
|
|
535
|
-
'span-2': 'span 2 / span 2',
|
|
536
|
-
'span-3': 'span 3 / span 3',
|
|
537
|
-
'span-4': 'span 4 / span 4',
|
|
538
|
-
'span-5': 'span 5 / span 5',
|
|
539
|
-
'span-6': 'span 6 / span 6',
|
|
540
|
-
},
|
|
541
|
-
gridRowStart: {
|
|
542
|
-
auto: 'auto',
|
|
543
|
-
1: '1',
|
|
544
|
-
2: '2',
|
|
545
|
-
3: '3',
|
|
546
|
-
4: '4',
|
|
547
|
-
5: '5',
|
|
548
|
-
6: '6',
|
|
549
|
-
7: '7',
|
|
550
|
-
},
|
|
551
|
-
gridRowEnd: {
|
|
552
|
-
auto: 'auto',
|
|
553
|
-
1: '1',
|
|
554
|
-
2: '2',
|
|
555
|
-
3: '3',
|
|
556
|
-
4: '4',
|
|
557
|
-
5: '5',
|
|
558
|
-
6: '6',
|
|
559
|
-
7: '7',
|
|
560
|
-
},
|
|
561
|
-
transformOrigin: {
|
|
562
|
-
center: 'center',
|
|
563
|
-
top: 'top',
|
|
564
|
-
'top-right': 'top right',
|
|
565
|
-
right: 'right',
|
|
566
|
-
'bottom-right': 'bottom right',
|
|
567
|
-
bottom: 'bottom',
|
|
568
|
-
'bottom-left': 'bottom left',
|
|
569
|
-
left: 'left',
|
|
570
|
-
'top-left': 'top left',
|
|
571
|
-
},
|
|
572
|
-
scale: {
|
|
573
|
-
0: '0',
|
|
574
|
-
50: '.5',
|
|
575
|
-
75: '.75',
|
|
576
|
-
90: '.9',
|
|
577
|
-
95: '.95',
|
|
578
|
-
100: '1',
|
|
579
|
-
105: '1.05',
|
|
580
|
-
110: '1.1',
|
|
581
|
-
125: '1.25',
|
|
582
|
-
150: '1.5',
|
|
583
|
-
},
|
|
584
|
-
rotate: {
|
|
585
|
-
'-180': '-180deg',
|
|
586
|
-
'-90': '-90deg',
|
|
587
|
-
'-45': '-45deg',
|
|
588
|
-
0: '0',
|
|
589
|
-
45: '45deg',
|
|
590
|
-
90: '90deg',
|
|
591
|
-
180: '180deg',
|
|
592
|
-
},
|
|
593
|
-
translate: (theme, { negative }) => ({
|
|
594
|
-
...theme('spacing'),
|
|
595
|
-
...negative(theme('spacing')),
|
|
596
|
-
'-full': '-100%',
|
|
597
|
-
'-1/2': '-50%',
|
|
598
|
-
'1/2': '50%',
|
|
599
|
-
full: '100%',
|
|
600
|
-
}),
|
|
601
|
-
skew: {
|
|
602
|
-
'-12': '-12deg',
|
|
603
|
-
'-6': '-6deg',
|
|
604
|
-
'-3': '-3deg',
|
|
605
|
-
0: '0',
|
|
606
|
-
3: '3deg',
|
|
607
|
-
6: '6deg',
|
|
608
|
-
12: '12deg',
|
|
609
|
-
},
|
|
610
|
-
transitionProperty: {
|
|
611
|
-
none: 'none',
|
|
612
|
-
all: 'all',
|
|
613
|
-
default:
|
|
614
|
-
'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform',
|
|
615
|
-
colors: 'background-color, border-color, color, fill, stroke',
|
|
616
|
-
opacity: 'opacity',
|
|
617
|
-
shadow: 'box-shadow',
|
|
618
|
-
transform: 'transform',
|
|
619
|
-
},
|
|
620
|
-
transitionTimingFunction: {
|
|
621
|
-
linear: 'linear',
|
|
622
|
-
in: 'cubic-bezier(0.4, 0, 1, 1)',
|
|
623
|
-
out: 'cubic-bezier(0, 0, 0.2, 1)',
|
|
624
|
-
'in-out': 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
625
|
-
},
|
|
626
|
-
transitionDuration: {
|
|
627
|
-
75: '75ms',
|
|
628
|
-
100: '100ms',
|
|
629
|
-
150: '150ms',
|
|
630
|
-
200: '200ms',
|
|
631
|
-
300: '300ms',
|
|
632
|
-
500: '500ms',
|
|
633
|
-
700: '700ms',
|
|
634
|
-
1000: '1000ms',
|
|
635
|
-
},
|
|
636
|
-
transitionDelay: {
|
|
637
|
-
75: '75ms',
|
|
638
|
-
100: '100ms',
|
|
639
|
-
150: '150ms',
|
|
640
|
-
200: '200ms',
|
|
641
|
-
300: '300ms',
|
|
642
|
-
500: '500ms',
|
|
643
|
-
700: '700ms',
|
|
644
|
-
1000: '1000ms',
|
|
645
|
-
},
|
|
646
|
-
};
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
:::tip
|
|
650
|
-
More about [Tailwind CSS configuration](https://tailwindcss.com/docs/configuration#theme)
|
|
651
|
-
:::
|
|
652
|
-
|
|
653
|
-
</details>
|
|
654
|
-
|
|
655
|
-
The `designSystem` is used to define the project's color palette, typographic scales (Typographic Scales or Type Scale), font list, breakpoints, border rounding values, etc. Since Modern.js borrows the design approach from Tailwind Theme and integrates with Tailwind CSS internally, `designSystem` is used in the same way as Tailwind CSS Theme
|
|
656
|
-
|
|
657
|
-
The `designSystem` object contains the `screens`, `colors` and `spacing` properties, as well as each customizable core plugin.
|
|
658
|
-
|
|
659
|
-
## Screens
|
|
660
|
-
|
|
661
|
-
The responsive breakpoints in your project can be customized using `screens`: the
|
|
662
|
-
|
|
663
|
-
```js
|
|
664
|
-
const designSystem = {
|
|
665
|
-
screens: {
|
|
666
|
-
sm: '640px',
|
|
667
|
-
md: '768px',
|
|
668
|
-
lg: '1024px',
|
|
669
|
-
xl: '1280px',
|
|
670
|
-
},
|
|
671
|
-
};
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
where the property name in the `screens` object is the screen name (used as a prefix for the adaptive utility variants generated by `Tailwind CSS`, e.g. `md:text-center`) and the value is the `min-width` at which the breakpoint should start.
|
|
675
|
-
|
|
676
|
-
Default breakpoints are inspired by common device resolutions: the
|
|
677
|
-
|
|
678
|
-
```js
|
|
679
|
-
const designSystem = {
|
|
680
|
-
screens: {
|
|
681
|
-
sm: '640px',
|
|
682
|
-
// => @media (min-width: 640px) { ... }
|
|
683
|
-
|
|
684
|
-
md: '768px',
|
|
685
|
-
// => @media (min-width: 768px) { ... }
|
|
686
|
-
|
|
687
|
-
lg: '1024px',
|
|
688
|
-
// => @media (min-width: 1024px) { ... }
|
|
689
|
-
|
|
690
|
-
xl: '1280px',
|
|
691
|
-
// => @media (min-width: 1280px) { ... }
|
|
692
|
-
},
|
|
693
|
-
};
|
|
694
|
-
```
|
|
695
|
-
|
|
696
|
-
You can use any name you like as a breakpoint property in your project: the
|
|
697
|
-
|
|
698
|
-
```js
|
|
699
|
-
const designSystem = {
|
|
700
|
-
screens: {
|
|
701
|
-
tablet: '640px',
|
|
702
|
-
// => @media (min-width: 640px) { ... }
|
|
703
|
-
|
|
704
|
-
laptop: '1024px',
|
|
705
|
-
// => @media (min-width: 1024px) { ... }
|
|
706
|
-
|
|
707
|
-
desktop: '1280px',
|
|
708
|
-
// => @media (min-width: 1280px) { ... }
|
|
709
|
-
},
|
|
710
|
-
};
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
These screen names are reflected in `utilities`, so `text-center` now looks like this
|
|
714
|
-
|
|
715
|
-
```css
|
|
716
|
-
.text-center {
|
|
717
|
-
text-align: center;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
@media (min-width: 640px) {
|
|
721
|
-
.tablet\:text-center {
|
|
722
|
-
text-align: center;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
@media (min-width: 1024px) {
|
|
727
|
-
.laptop\:text-center {
|
|
728
|
-
text-align: center;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
@media (min-width: 1280px) {
|
|
733
|
-
.desktop\:text-center {
|
|
734
|
-
text-align: center;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
```
|
|
738
|
-
|
|
739
|
-
### Max-width breakpoints
|
|
740
|
-
|
|
741
|
-
To use the `max-width` breakpoint instead of `min-width`, you can specify the screen as an object with the `max` attribute.
|
|
742
|
-
|
|
743
|
-
```js
|
|
744
|
-
const designSystem = {
|
|
745
|
-
screens: {
|
|
746
|
-
xl: { max: '1279px' }
|
|
747
|
-
// => @media (max-width: 1279px) { ... }
|
|
748
|
-
|
|
749
|
-
lg: { max: '1023px' },
|
|
750
|
-
// => @media (max-width: 1023px) { ... }
|
|
751
|
-
|
|
752
|
-
md: { max: '767px' },
|
|
753
|
-
// => @media (max-width: 767px) { ... }
|
|
754
|
-
|
|
755
|
-
sm: { max: '639px' },
|
|
756
|
-
// => @media (max-width: 639px) { ... }
|
|
757
|
-
},
|
|
758
|
-
};
|
|
759
|
-
```
|
|
760
|
-
|
|
761
|
-
If necessary, to create breakpoints with `min-width` and `max-width` definitions, e.g.
|
|
762
|
-
|
|
763
|
-
```js
|
|
764
|
-
const designSystem = {
|
|
765
|
-
screens: {
|
|
766
|
-
sm: { min: '640px', max: '767px' }
|
|
767
|
-
md: { min: '768px', max: '1023px' }
|
|
768
|
-
lg: { min: '1024px', max: '1279px' }, lg: { min: '1024px', max: '1279px' },
|
|
769
|
-
xl: { min: '1280px' }
|
|
770
|
-
},
|
|
771
|
-
};
|
|
772
|
-
```
|
|
773
|
-
|
|
774
|
-
### Multiple range breakpoints
|
|
775
|
-
|
|
776
|
-
Sometimes it can be useful to apply a single breakpoint definition to multiple scopes.
|
|
777
|
-
|
|
778
|
-
For example, suppose you have a `sidebar` and want the breakpoint to be based on the width of the content area rather than the entire viewport. You can simulate this situation by using a smaller breakpoint style when the `sidebar` is visible and the content area is narrowed: the
|
|
779
|
-
|
|
780
|
-
```js
|
|
781
|
-
const designSystem = {
|
|
782
|
-
screens: {
|
|
783
|
-
sm: '500px',
|
|
784
|
-
md: [
|
|
785
|
-
// Sidebar appears at 768px, so revert to `sm:` styles between 768px
|
|
786
|
-
// and 868px, after which the main content area is wide enough again to
|
|
787
|
-
// apply the `md:` styles.
|
|
788
|
-
{ min: '668px', max: '767px' }
|
|
789
|
-
{ min: '868px' }, { min: '868px' },
|
|
790
|
-
],
|
|
791
|
-
lg: '1100px',
|
|
792
|
-
xl: '1400px',
|
|
793
|
-
},
|
|
794
|
-
};
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
### Custom media queries
|
|
798
|
-
|
|
799
|
-
If a fully customizable media query is required for a breakpoint, an object with the `raw` attribute can be used.
|
|
800
|
-
|
|
801
|
-
```js
|
|
802
|
-
const designSystem = {
|
|
803
|
-
extend: {
|
|
804
|
-
screens: {
|
|
805
|
-
portrait: { raw: '(orientation: portrait)' },
|
|
806
|
-
// => @media (orientation: portrait) { ... }
|
|
807
|
-
},
|
|
808
|
-
},
|
|
809
|
-
};
|
|
810
|
-
```
|
|
811
|
-
|
|
812
|
-
### Print styles
|
|
813
|
-
|
|
814
|
-
The `raw` option may be particularly useful if you need to apply different styles to printing.
|
|
815
|
-
|
|
816
|
-
All that needs to be done is to add a `print` under `designSystem.extend.screens`.
|
|
817
|
-
|
|
818
|
-
```js
|
|
819
|
-
const designSystem = {
|
|
820
|
-
extend: {
|
|
821
|
-
screens: {
|
|
822
|
-
print: { raw: 'print' },
|
|
823
|
-
// => @media print { ... }
|
|
824
|
-
},
|
|
825
|
-
},
|
|
826
|
-
};
|
|
827
|
-
```
|
|
828
|
-
|
|
829
|
-
Then, a class such as `print:text-black` can be used to specify a style that is applied only when someone tries to print a page: ``
|
|
830
|
-
|
|
831
|
-
```html
|
|
832
|
-
<div class="text-gray-700 print:text-black">
|
|
833
|
-
<! -- ... -->
|
|
834
|
-
</div>
|
|
835
|
-
```
|
|
836
|
-
|
|
837
|
-
### Dark Mode
|
|
838
|
-
|
|
839
|
-
`raw` 选项可以用于实现 “暗模式” 屏幕:
|
|
840
|
-
|
|
841
|
-
```js
|
|
842
|
-
const designSystem = {
|
|
843
|
-
extend: {
|
|
844
|
-
screens: {
|
|
845
|
-
dark: { raw: '(prefers-color-scheme: dark)' },
|
|
846
|
-
// => @media (prefers-color-scheme: dark) { ... }
|
|
847
|
-
},
|
|
848
|
-
},
|
|
849
|
-
};
|
|
850
|
-
```
|
|
851
|
-
|
|
852
|
-
然后,您可以使用 `dark:` 前缀在暗模式下为元素设置不同的样式:
|
|
853
|
-
|
|
854
|
-
```html
|
|
855
|
-
<div class="text-gray-700 dark:text-gray-200">
|
|
856
|
-
<! -- ... -->
|
|
857
|
-
</div>
|
|
858
|
-
```
|
|
859
|
-
|
|
860
|
-
请注意,由于这些 `screen variants` 是在 `Tailwind CSS` 中实现的,因此**无法使用这种方法将断点与暗模式结合使用** ,例如 `md:dark:text-gray-300` 将不起作用。
|
|
861
|
-
|
|
862
|
-
## Colors
|
|
863
|
-
|
|
864
|
-
`colors` 属性可让您自定义项目的全局调色板。
|
|
865
|
-
|
|
866
|
-
```js
|
|
867
|
-
const designSystem = {
|
|
868
|
-
colors: {
|
|
869
|
-
transparent: 'transparent',
|
|
870
|
-
black: '#000',
|
|
871
|
-
white: '#fff',
|
|
872
|
-
gray: {
|
|
873
|
-
100: '#f7fafc',
|
|
874
|
-
// ...
|
|
875
|
-
900: '#1a202c',
|
|
876
|
-
},
|
|
877
|
-
|
|
878
|
-
// ...
|
|
879
|
-
},
|
|
880
|
-
};
|
|
881
|
-
```
|
|
882
|
-
|
|
883
|
-
By default, these colors are inherited by the `backgroundColor`, `textColor` and `borderColor` core plugins.
|
|
884
|
-
|
|
885
|
-
To learn more, you can check out: [Customizing Colors](https://tailwindcss.com/docs/customizing-colors).
|
|
886
|
-
|
|
887
|
-
## Spacing
|
|
888
|
-
|
|
889
|
-
The global spacing and scaling of items can be customized using the `space` attribute: the
|
|
890
|
-
|
|
891
|
-
```js
|
|
892
|
-
const designSystem = {
|
|
893
|
-
spacing: {
|
|
894
|
-
px: '1px',
|
|
895
|
-
0: '0',
|
|
896
|
-
1: '0.25rem',
|
|
897
|
-
2: '0.5rem',
|
|
898
|
-
3: '0.75rem',
|
|
899
|
-
4: '1rem',
|
|
900
|
-
5: '1.25rem',
|
|
901
|
-
6: '1.5rem',
|
|
902
|
-
8: '2rem',
|
|
903
|
-
10: '2.5rem',
|
|
904
|
-
12: '3rem',
|
|
905
|
-
16: '4rem',
|
|
906
|
-
20: '5rem',
|
|
907
|
-
24: '6rem',
|
|
908
|
-
32: '8rem',
|
|
909
|
-
40: '10rem',
|
|
910
|
-
48: '12rem',
|
|
911
|
-
56: '14rem',
|
|
912
|
-
64: '16rem',
|
|
913
|
-
},
|
|
914
|
-
};
|
|
915
|
-
```
|
|
916
|
-
|
|
917
|
-
By default, these values are inherited by the `padding`, `margin`, `negativeMargin`, `width` and `height` core plugins.
|
|
918
|
-
|
|
919
|
-
To learn more, see [Customizing Spacing](https://tailwindcss.com/docs/customizing-spacing).
|
|
920
|
-
|
|
921
|
-
## Core plugins
|
|
922
|
-
|
|
923
|
-
The rest of the theme section is used to configure the values available for each core plugin.
|
|
924
|
-
|
|
925
|
-
For example, the `borderRadius` property allows you to customize the ``utilities` that will generate the rounded corners.
|
|
926
|
-
|
|
927
|
-
```js
|
|
928
|
-
const designSystem = {
|
|
929
|
-
borderRadius: {
|
|
930
|
-
none: '0',
|
|
931
|
-
sm: '.125rem',
|
|
932
|
-
default: '.25rem',
|
|
933
|
-
lg: '.5rem',
|
|
934
|
-
full: '9999px',
|
|
935
|
-
},
|
|
936
|
-
};
|
|
937
|
-
```
|
|
938
|
-
|
|
939
|
-
** The attribute name determines the suffix of the generated class, and the value determines the value of the actual CSS declaration. **
|
|
940
|
-
The example `borderRadius` configuration above will generate the following CSS classes.
|
|
941
|
-
|
|
942
|
-
```css
|
|
943
|
-
.rounded-none {
|
|
944
|
-
border-radius: 0;
|
|
945
|
-
}
|
|
946
|
-
.rounded-sm {
|
|
947
|
-
border-radius: 0.125rem;
|
|
948
|
-
}
|
|
949
|
-
.rounded {
|
|
950
|
-
border-radius: 0.25rem;
|
|
951
|
-
}
|
|
952
|
-
.rounded-lg {
|
|
953
|
-
border-radius: 0.5rem;
|
|
954
|
-
}
|
|
955
|
-
.rounded-full {
|
|
956
|
-
border-radius: 9999px;
|
|
957
|
-
}
|
|
958
|
-
```
|
|
959
|
-
|
|
960
|
-
You will notice that the `rounded` class is created without the suffix in the theme configuration using the `default` attribute. This is a common convention in Tailwind CSS supported by many (though not all) of the core plugins.
|
|
961
|
-
|
|
962
|
-
To learn more about customizing a specific core plugin, please visit the documentation for that plugin.
|
|
963
|
-
|
|
964
|
-
## Customizing the default configuration
|
|
965
|
-
|
|
966
|
-
Out of the box, your project will automatically inherit values from the default theme configuration. If you want to customize the default theme, there are several different options depending on the goal.
|
|
967
|
-
|
|
968
|
-
### Override the default configuration
|
|
969
|
-
|
|
970
|
-
To override the options in the default configuration, add the properties to be overridden to `designSystem` at
|
|
971
|
-
|
|
972
|
-
```js title="modern.config.ts"
|
|
973
|
-
import { defineConfig } from '@modern-js/module-tools';
|
|
974
|
-
|
|
975
|
-
const designSystem = {
|
|
976
|
-
// Replaces all of the default `opacity` values
|
|
977
|
-
opacity: {
|
|
978
|
-
0: '0',
|
|
979
|
-
20: '0.2',
|
|
980
|
-
40: '0.4',
|
|
981
|
-
60: '0.6',
|
|
982
|
-
80: '0.8',
|
|
983
|
-
100: '1',
|
|
984
|
-
},
|
|
985
|
-
};
|
|
986
|
-
|
|
987
|
-
export default defineConfig({
|
|
988
|
-
designSystem,
|
|
989
|
-
});
|
|
990
|
-
```
|
|
991
|
-
|
|
992
|
-
This will completely replace the default property configuration, so in the above example, the default `opacity utilities` will not be generated.
|
|
993
|
-
|
|
994
|
-
Any properties you do not provide will be inherited from the default theme, so in the example above, the default theme configuration for color, spacing, border rounding, background position, etc. will be retained.
|
|
995
|
-
|
|
996
|
-
### Extending the default configuration
|
|
997
|
-
|
|
998
|
-
If you want to keep the default values of the theme options but add new values, add the extensions under the `designSystem.extend` property.
|
|
999
|
-
|
|
1000
|
-
For example, if you want to add an additional breakpoint but keep the existing one, you can extend the `screens` property with.
|
|
1001
|
-
|
|
1002
|
-
```js title="modern.config.ts"
|
|
1003
|
-
import { defineConfig } from '@modern-js/module-tools';
|
|
1004
|
-
|
|
1005
|
-
const designSystem = {
|
|
1006
|
-
extend: {
|
|
1007
|
-
// Adds a new breakpoint in addition to the default breakpoints
|
|
1008
|
-
screens: {
|
|
1009
|
-
'2xl': '1440px',
|
|
1010
|
-
},
|
|
1011
|
-
},
|
|
1012
|
-
};
|
|
1013
|
-
|
|
1014
|
-
export default defineConfig({
|
|
1015
|
-
designSystem,
|
|
1016
|
-
});
|
|
1017
|
-
```
|
|
1018
|
-
|
|
1019
|
-
You can certainly override some parts of the default theme and extend other parts of the default theme in the same configuration: the
|
|
1020
|
-
|
|
1021
|
-
```js title="modern.config.ts"
|
|
1022
|
-
import { defineConfig } from '@modern-js/module-tools';
|
|
1023
|
-
|
|
1024
|
-
const designSystem = {
|
|
1025
|
-
opacity: {
|
|
1026
|
-
0: '0',
|
|
1027
|
-
20: '0.2',
|
|
1028
|
-
40: '0.4',
|
|
1029
|
-
60: '0.6',
|
|
1030
|
-
80: '0.8',
|
|
1031
|
-
100: '1',
|
|
1032
|
-
},
|
|
1033
|
-
extend: {
|
|
1034
|
-
screens: {
|
|
1035
|
-
'2xl': '1440px',
|
|
1036
|
-
},
|
|
1037
|
-
},
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
export default defineConfig({
|
|
1041
|
-
designSystem,
|
|
1042
|
-
});
|
|
1043
|
-
```
|
|
1044
|
-
|
|
1045
|
-
### Referencing other values
|
|
1046
|
-
|
|
1047
|
-
If you need to reference another value in the configuration, you can do so by providing a closure function instead of a static value. The function will receive the `theme()` function as an argument, and you can use this function to find other values in the configuration using a dot representation.
|
|
1048
|
-
|
|
1049
|
-
For example, you can generate `fill` utilities for each color in the palette by referring to `theme('colors')` on the `fill` configuration.
|
|
1050
|
-
|
|
1051
|
-
```js title="modern.config.ts"
|
|
1052
|
-
import { defineConfig } from '@modern-js/module-tools';
|
|
1053
|
-
|
|
1054
|
-
const designSystem = {
|
|
1055
|
-
colors: {
|
|
1056
|
-
// ...
|
|
1057
|
-
},
|
|
1058
|
-
fill: theme => theme('colors'),
|
|
1059
|
-
};
|
|
1060
|
-
|
|
1061
|
-
export default defineConfig({
|
|
1062
|
-
designSystem,
|
|
1063
|
-
});
|
|
1064
|
-
```
|
|
1065
|
-
|
|
1066
|
-
The `theme()` function tries to find the value you are looking for from an already fully merged configuration object, so it can reference your own custom settings as well as the default theme value. It also works recursively, so as long as there is a static value at the end of the chain, it can resolve the value you are looking for.
|
|
1067
|
-
|
|
1068
|
-
**Reference to the default configuration**
|
|
1069
|
-
|
|
1070
|
-
If for any reason you want to reference a value in the default configuration, you can import it from `tailwindcss/defaultTheme`. A useful example would be to add one of the fonts provided by the default configuration to.
|
|
1071
|
-
|
|
1072
|
-
```js title="modern.config.ts"
|
|
1073
|
-
import { defineConfig } from '@modern-js/module-tools';
|
|
1074
|
-
|
|
1075
|
-
const defaultTheme = require('tailwindcss/defaultTheme');
|
|
1076
|
-
|
|
1077
|
-
const designSystem = {
|
|
1078
|
-
extend: {
|
|
1079
|
-
fontFamily: {
|
|
1080
|
-
sans: ['Lato', ... .defaultTheme.fontFamily.sans],
|
|
1081
|
-
},
|
|
1082
|
-
},
|
|
1083
|
-
};
|
|
1084
|
-
|
|
1085
|
-
export default defineConfig({
|
|
1086
|
-
designSystem,
|
|
1087
|
-
});
|
|
1088
|
-
```
|
|
1089
|
-
|
|
1090
|
-
### Disabling the entire core plugin
|
|
1091
|
-
|
|
1092
|
-
If you don't want to generate any classes for a core plugin, it's better to set the plugin to `false` in the `corePlugins` configuration, rather than providing an empty object for the property in the configuration: ``
|
|
1093
|
-
|
|
1094
|
-
```js
|
|
1095
|
-
// Don't assign an empty object in your theme configuration
|
|
1096
|
-
|
|
1097
|
-
const designSystem = {
|
|
1098
|
-
opacity: {},
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
// Do disable the plugin in your corePlugins configuration
|
|
1102
|
-
const designSyttem = {
|
|
1103
|
-
corePlugins: {
|
|
1104
|
-
opacity: { false,
|
|
1105
|
-
},
|
|
1106
|
-
};
|
|
1107
|
-
```
|
|
1108
|
-
|
|
1109
|
-
The end result is the same, but since many core plugins don't expose any configuration, it's best to keep it consistent by only disabling them with corePlugins anyway.
|
|
1110
|
-
|
|
1111
|
-
### Adding your own key
|
|
1112
|
-
|
|
1113
|
-
In many cases it may be useful to add your own properties to the configuration object.
|
|
1114
|
-
|
|
1115
|
-
One example is to add new properties for multiplexing between multiple core plugins. For example, you can extract a `positions` object that both the `backgroundPosition` and `objectPosition` plugins can refer to.
|
|
1116
|
-
|
|
1117
|
-
```js
|
|
1118
|
-
const designSystem = {
|
|
1119
|
-
positions: {
|
|
1120
|
-
bottom: 'bottom',
|
|
1121
|
-
center: 'center',
|
|
1122
|
-
left: 'left',
|
|
1123
|
-
'left-bottom': 'left bottom',
|
|
1124
|
-
'left-top': 'left top',
|
|
1125
|
-
right: 'right',
|
|
1126
|
-
'right-bottom': 'right bottom',
|
|
1127
|
-
'right-top': 'right top',
|
|
1128
|
-
top: 'top',
|
|
1129
|
-
},
|
|
1130
|
-
backgroundPosition: theme => theme('positions'),
|
|
1131
|
-
objectPosition: theme => theme('positions'),
|
|
1132
|
-
};
|
|
1133
|
-
```
|
|
1134
|
-
|
|
1135
|
-
Another example is to add a new property to a custom plugin for referencing. For example, if you write a gradient plugin for your project, you can add a gradient property to the theme object referenced by that plugin.
|
|
1136
|
-
|
|
1137
|
-
```js title="modern.config.ts"
|
|
1138
|
-
import { defineConfig } from '@modern-js/module-tools';
|
|
1139
|
-
|
|
1140
|
-
const designSystem = {
|
|
1141
|
-
gradients: theme => ({
|
|
1142
|
-
'blue-green': [theme('colors.blue.500'), theme('colors.green.500')],
|
|
1143
|
-
'purple-blue': [theme('colors.purple.500'), theme('colors.blue.500')],
|
|
1144
|
-
// ...
|
|
1145
|
-
}),
|
|
1146
|
-
};
|
|
1147
|
-
|
|
1148
|
-
export default defineConfig({
|
|
1149
|
-
designSystem,
|
|
1150
|
-
buildConfig: {
|
|
1151
|
-
style: {
|
|
1152
|
-
postcss: {
|
|
1153
|
-
plugins: [require('. /plugins/gradients')],
|
|
1154
|
-
},
|
|
1155
|
-
},
|
|
1156
|
-
},
|
|
1157
|
-
});
|
|
1158
|
-
```
|
|
1159
|
-
|
|
1160
|
-
## Configuration references
|
|
1161
|
-
|
|
1162
|
-
All properties in the configuration object, except `screens`, `colors` and `spacing`, are mapped to the core plugins of `Tailwind CSS`. Since many plugins are responsible for CSS properties that accept only static sets of values (e.g., e.g., `float`), please note that not every plugin has a corresponding property in the theme object.
|
|
1163
|
-
|
|
1164
|
-
All of these properties can also be used under the `designSystem.extend` property to extend the default theme.
|
|
1165
|
-
|
|
1166
|
-
For more information about what all the properties do, check out this [link](https://tailwindcss.com/docs/theme#configuration-reference).
|