@@ -25,8 +25,9 @@ module.exports = {
25
25
theme: {
26
26
// ...
27
27
},
28
- // You have to disable the fontSize core
29
- // plugins otherwise it doesn't work
28
+ // You can disable the fontSize core plugin if you don't need the defaults.
29
+ // If you don't disable it, the fluid-type plugin simply overrule the defaults.
30
+ // Or you can use both alongside when you set an prefix in the settings
30
31
corePlugins: {
31
32
fontSize: false ,
32
33
// ...
@@ -60,35 +61,38 @@ As default, we use `rem` for better accessibility, but you can also use `px`.
60
61
// tailwind.config.js
61
62
module .exports = {
62
63
theme: {
63
- // your fluid type settings
64
- // works only with unitless numbers
65
- // This numbers are the defaults settings
66
- fluidTypeSettings: {
67
- fontSizeMin: 1.125 , // 1.125rem === 18px
68
- fontSizeMax: 1.25 , // 1.25rem === 20px
69
- ratioMin: 1.125 , // Multiplicator Min
70
- ratioMax: 1.2 , // Multiplicator Max
71
- screenMin: 20 , // 20rem === 320px
72
- screenMax: 96 , // 96rem === 1536px
73
- unit: ' rem' // default is rem but it's also possible to use 'px'
74
- },
75
- // Creates the text-xx classes
76
- // This are the default settings and analog to the tailwindcss defaults
77
- // Each `lineHeight` is set unitless and we think that's the way to go especially in context with fluid type.
78
64
fluidType: {
79
- ' xs' : [- 2 , 1.6 ],
80
- ' sm' : [- 1 , 1.6 ],
81
- ' base' : [0 , 1.6 ],
82
- ' lg' : [1 , 1.6 ],
83
- ' xl' : [2 , 1.2 ],
84
- ' 2xl' : [3 , 1.2 ],
85
- ' 3xl' : [4 , 1.2 ],
86
- ' 4xl' : [5 , 1.1 ],
87
- ' 5xl' : [6 , 1.1 ],
88
- ' 6xl' : [7 , 1.1 ],
89
- ' 7xl' : [8 , 1 ],
90
- ' 8xl' : [9 , 1 ],
91
- ' 9xl' : [10 , 1 ],
65
+ // your fluid type settings
66
+ // works only with unitless numbers
67
+ // This numbers are the defaults settings
68
+ settings: {
69
+ fontSizeMin: 1.125 , // 1.125rem === 18px
70
+ fontSizeMax: 1.25 , // 1.25rem === 20px
71
+ ratioMin: 1.125 , // Multiplicator Min
72
+ ratioMax: 1.2 , // Multiplicator Max
73
+ screenMin: 20 , // 20rem === 320px
74
+ screenMax: 96 , // 96rem === 1536px
75
+ unit: ' rem' , // default is rem but it's also possible to use 'px'
76
+ prefix: ' ' // set a prefix to use it alongside the default font sizes
77
+ },
78
+ // Creates the text-xx classes
79
+ // This are the default settings and analog to the tailwindcss defaults
80
+ // Each `lineHeight` is set unitless and we think that's the way to go especially in context with fluid type.
81
+ values: {
82
+ ' xs' : [- 2 , 1.6 ],
83
+ ' sm' : [- 1 , 1.6 ],
84
+ ' base' : [0 , 1.6 ],
85
+ ' lg' : [1 , 1.6 ],
86
+ ' xl' : [2 , 1.2 ],
87
+ ' 2xl' : [3 , 1.2 ],
88
+ ' 3xl' : [4 , 1.2 ],
89
+ ' 4xl' : [5 , 1.1 ],
90
+ ' 5xl' : [6 , 1.1 ],
91
+ ' 6xl' : [7 , 1.1 ],
92
+ ' 7xl' : [8 , 1 ],
93
+ ' 8xl' : [9 , 1 ],
94
+ ' 9xl' : [10 , 1 ],
95
+ }
92
96
},
93
97
},
94
98
variants: {
@@ -106,9 +110,11 @@ It is also possible to set just the `fontSize` without set the `lineHeight`
106
110
module .exports = {
107
111
theme: {
108
112
fluidType: {
109
- // ...
110
- ' base' : 0 ,
111
- // ...
113
+ values: {
114
+ // ...
115
+ ' base' : 0 ,
116
+ // ...
117
+ }
112
118
}
113
119
}
114
120
};
@@ -124,14 +130,16 @@ documentation. `letterSpacing` can be all values that you like.
124
130
module .exports = {
125
131
theme: {
126
132
fluidType: {
127
- // ...
128
- ' base' : [0 ,
129
- {
130
- lineHeight: 1.6 ,
131
- letterSpacing: ' -0.1rem' ,
132
- }
133
- ],
134
- // ...
133
+ values: {
134
+ // ...
135
+ ' base' : [0 ,
136
+ {
137
+ lineHeight: 1.6 ,
138
+ letterSpacing: ' -0.1rem' ,
139
+ }
140
+ ],
141
+ // ...
142
+ }
135
143
}
136
144
}
137
145
};
@@ -145,19 +153,22 @@ module.exports = {
145
153
// tailwind.config.js
146
154
module .exports = {
147
155
theme: {
148
- fluidTypeSettings: {
149
- fontSizeMin: 1.125 ,
150
- fontSizeMax: 1.25 ,
151
- ratioMin: 1.125 ,
152
- ratioMax: 1.2 ,
153
- screenMin: 20 ,
154
- screenMax: 96 ,
155
- unit: ' rem'
156
- },
157
156
fluidType: {
158
- // ...
159
- ' base' : 0 ,
160
- // ...
157
+ settings: {
158
+ fontSizeMin: 1.125 ,
159
+ fontSizeMax: 1.25 ,
160
+ ratioMin: 1.125 ,
161
+ ratioMax: 1.2 ,
162
+ screenMin: 20 ,
163
+ screenMax: 96 ,
164
+ unit: ' rem' ,
165
+ prefix: ' '
166
+ },
167
+ values: {
168
+ // ...
169
+ ' base' : 0 ,
170
+ // ...
171
+ }
161
172
}
162
173
}
163
174
};
@@ -179,19 +190,22 @@ module.exports = {
179
190
// tailwind.config.js
180
191
module .exports = {
181
192
theme: {
182
- fluidTypeSettings: {
183
- fontSizeMin: 1.125 ,
184
- fontSizeMax: 1.25 ,
185
- ratioMin: 1.125 ,
186
- ratioMax: 1.2 ,
187
- screenMin: 20 ,
188
- screenMax: 96 ,
189
- unit: ' rem'
190
- },
191
193
fluidType: {
192
- // ...
193
- ' base' : [0 , 1.6 ],
194
- // ...
194
+ settings: {
195
+ fontSizeMin: 1.125 ,
196
+ fontSizeMax: 1.25 ,
197
+ ratioMin: 1.125 ,
198
+ ratioMax: 1.2 ,
199
+ screenMin: 20 ,
200
+ screenMax: 96 ,
201
+ unit: ' rem' ,
202
+ prefix: ' '
203
+ },
204
+ values: {
205
+ // ...
206
+ ' base' : [0 , 1.6 ],
207
+ // ...
208
+ }
195
209
}
196
210
}
197
211
};
@@ -214,22 +228,25 @@ module.exports = {
214
228
// tailwind.config.js
215
229
module .exports = {
216
230
theme: {
217
- fluidTypeSettings: {
218
- fontSizeMin: 1.125 ,
219
- fontSizeMax: 1.25 ,
220
- ratioMin: 1.125 ,
221
- ratioMax: 1.2 ,
222
- screenMin: 20 ,
223
- screenMax: 96 ,
224
- unit: ' rem'
225
- },
226
231
fluidType: {
227
- // ...
228
- ' base' : [0 , {
229
- lineHeight: 1.6 ,
230
- letterSpacing: ' -0.1rem' ,
231
- }],
232
- // ...
232
+ settings: {
233
+ fontSizeMin: 1.125 ,
234
+ fontSizeMax: 1.25 ,
235
+ ratioMin: 1.125 ,
236
+ ratioMax: 1.2 ,
237
+ screenMin: 20 ,
238
+ screenMax: 96 ,
239
+ unit: ' rem' ,
240
+ prefix: ' ' ,
241
+ },
242
+ values: {
243
+ // ...
244
+ ' base' : [0 , {
245
+ lineHeight: 1.6 ,
246
+ letterSpacing: ' -0.1rem' ,
247
+ }],
248
+ // ...
249
+ }
233
250
}
234
251
}
235
252
};
@@ -247,5 +264,36 @@ module.exports = {
247
264
}
248
265
```
249
266
267
+ ### Set a prefix
268
+
269
+ ``` js
270
+ // tailwind.config.js
271
+ module .exports = {
272
+ theme: {
273
+ extend: {
274
+ fluidType: {
275
+ settings: {
276
+ // ...
277
+ prefix: ' fluid-' ,
278
+ },
279
+ }
280
+ }
281
+ }
282
+ };
283
+ ```
284
+
285
+ ``` html
286
+ <p class =" fluid-text-base" >The quick brown fox jumps over the lazy dogs</p >
287
+ ```
288
+
289
+ ``` css
290
+ .fluid-text-base {
291
+ font-size : clamp (1.125rem , calc (1.125rem + (1.25 - 1.125 ) * ((100vw - 20rem ) / (96 - 20 ))), 1.25rem );
292
+ line-height : 1.6 ;
293
+ letter-spacing : -0.1rem ;
294
+ }
295
+ ```
296
+
297
+
250
298
## 👉🏻 Live Demo
251
- [ Fluid Type Live Demo] ( https://play.tailwindcss.com/vxnQwJvrQA )
299
+ [ Fluid Type Live Demo] ( https://play.tailwindcss.com/3LDf3gzbhb )
0 commit comments