You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+83-90Lines changed: 83 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@ TailwindCSS Plugin to integrate with Inter Typeface from Rasmus Andersson [@rsms
4
4
5
5
The plugin is inspired with [tailwind-plugin-inter-font](https://github.com/suburbicode/tailwind-plugin-font-inter) plugin developed by Imam Susanto [@imsus](https://github.com/imsus).
6
6
7
+
:warning:**This plugin produces pretty large amount of utility classes! It is highly recommended to use it in JIT-mode or with `purge` option.**
8
+
9
+
7
10
## Installation
8
11
9
12
```sh
@@ -21,19 +24,17 @@ Add plugin to your `tailwind.config.js`:
21
24
```js
22
25
// tailwind.config.js
23
26
module.exports= {
24
-
theme: {
25
-
extend: {}
26
-
},
27
-
variants: {},
28
-
plugins: [require('tailwindcss-font-inter')()]
29
-
};
27
+
theme: {},
28
+
variants: {},
29
+
plugins: [require('tailwindcss-font-inter')]
30
+
}
30
31
```
31
32
32
-
Now you can put `.font-inter` class to apply the font (by default `@font-face`defenitions will be added to your CSS).
33
+
Now you can put `.font-inter` class to apply the font (by default `@font-face`definitions will be added to your CSS).
@@ -64,111 +66,101 @@ The plugin has several adjustable options.
64
66
-`baseFontSize` — integer for base font size, default is `16`.
65
67
-`importFontFace` — flag to inject Inter's `@font-face` to the output, default is `true`. If `false`, you should import Inter by yourself (e.g. from Google Fonts).
66
68
69
+
67
70
### Theme Configuration
68
71
69
72
The plugin uses [`fontSize` core plugin](https://tailwindcss.com/docs/configuration#core-plugins) to generate proper letter spacing for Inter Typeface. Additionally it uses `fontFeatureSettings` to config font feature settings.
70
73
71
74
```js
72
75
// tailwind.config.js
73
76
module.exports= {
74
-
theme: {
75
-
fontFeatureSettings: {
76
-
numeric: ['tnum', 'salt', 'ss02']
77
-
},
78
-
fontSize: {
79
-
xs:'0.75rem',
80
-
sm:'0.875rem',
81
-
base:'1rem',
82
-
lg:'1.125rem',
83
-
xl:'36px',
84
-
'2xl':'1.5rem',
85
-
'3xl':'1.875rem',
86
-
'4xl':'2.25rem',
87
-
'5xl':'3rem',
88
-
'6xl':'4rem'
89
-
}
77
+
theme: {
78
+
fontFeatureSettings: {
79
+
numeric: ['tnum', 'salt', 'ss02']
90
80
},
91
-
plugins: [require('tailwindcss-font-inter')()]
92
-
};
81
+
fontSize: {
82
+
xs:'0.75rem',
83
+
sm:'0.875rem',
84
+
base:'1rem',
85
+
lg:'1.125rem',
86
+
xl:'36px',
87
+
'2xl':'1.5rem',
88
+
'3xl':'1.875rem',
89
+
'4xl':'2.25rem',
90
+
'5xl':'3rem',
91
+
'6xl':'4rem'
92
+
}
93
+
},
94
+
plugins: [require('tailwindcss-font-inter')]
95
+
}
93
96
```
94
97
98
+
95
99
### Font Family
96
100
97
101
The plugin will inject `@font-face` declaration from https://rsms.me/inter/inter.css (set `importFontFace` option to `false` to import font manually) and add `.font-inter` utility class.
98
102
103
+
99
104
## Font Sizes
100
105
101
-
Alongside with the default `text-lg` classes, the plugin will generate nested `text-lg` to set letter spacing according to Inter's **Dynamic Metrics**.
106
+
Alongside with the default `text-*` classes, the plugin will generate nested `text-*` to set letter spacing according to Inter's**Dynamic Metrics**. Also it will generate additional classes to adjust letter spacing for `tracking-*` modifiers according to the**Dynamic Metrics**.
102
107
103
108
```css
104
-
.font-inter.text-xs,
105
-
.font-inter.text-xs {
106
-
font-size: 0.75rem;
107
-
letter-spacing: 0.0004908em;
108
-
}
109
-
110
-
.font-inter.text-sm,
111
-
.font-inter.text-sm {
112
-
font-size: 0.875rem;
113
-
letter-spacing: -0.0062235em;
109
+
.font-inter.text-xs, .font-inter.text-xs {
110
+
font-size: 0.75rem;
111
+
letter-spacing: 0.000490774em
114
112
}
115
-
116
-
.font-inter.text-base,
117
-
.font-inter.text-base {
118
-
font-size: 1rem;
119
-
letter-spacing: -0.0109598em;
120
-
}
121
-
122
-
.font-inter.text-lg,
123
-
.font-inter.text-lg {
124
-
font-size: 1.125rem;
125
-
letter-spacing: -0.0143007em;
126
-
}
127
-
128
-
.font-inter.text-2xl,
129
-
.font-inter.text-2xl {
130
-
font-size: 1.5rem;
131
-
letter-spacing: -0.0194923em;
113
+
.font-inter.text-xs.tracking-tighter,
114
+
.font-inter.text-xs.tracking-tighter,
115
+
.font-inter.text-xs.tracking-tighter,
116
+
.font-inter.text-xs.tracking-tighter,
117
+
.tracking-tighter.font-inter.text-xs,
118
+
.tracking-tighter.font-inter.text-xs {
119
+
font-size: 0.75rem;
120
+
letter-spacing: -0.049509226em
132
121
}
122
+
/* ... */
123
+
```
133
124
134
-
.font-inter.text-3xl,
135
-
.font-inter.text-3xl {
136
-
font-size: 1.875rem;
137
-
letter-spacing: -0.0213145em;
138
-
}
125
+
And if the font size in config specified along with line height, it will be applied as well.
139
126
140
-
.font-inter.text-4xl,
141
-
.font-inter.text-4xl {
142
-
font-size: 2.25rem;
143
-
letter-spacing: -0.0219541em;
144
-
}
127
+
```js
128
+
module.exports= {
129
+
theme: {
130
+
fontSize: {
131
+
xs: ['0.75rem', { lineHeight:'1.25rem' }]
132
+
// ...
133
+
}
134
+
},
135
+
plugins: [require('tailwindcss-font-inter')]
136
+
};
137
+
```
145
138
146
-
.font-inter.text-5xl,
147
-
.font-inter.text-5xl {
148
-
font-size: 3rem;
149
-
letter-spacing: -0.0222574em;
150
-
}
139
+
Will generate classes like this:
151
140
152
-
.font-inter.text-6xl,
153
-
.font-inter.text-6xl {
154
-
font-size: 4rem;
155
-
letter-spacing: -0.0222974em;
141
+
```css
142
+
.font-inter.text-xs, .font-inter.text-xs {
143
+
line-height: 1.25rem;
144
+
font-size: 0.75rem;
145
+
letter-spacing: 0.000490774em
156
146
}
147
+
/* ... */
157
148
```
158
149
150
+
159
151
### Font features
160
152
161
153
Also the plugin generates utility classes which allow you to specify named sets of font feature settings.
162
154
163
155
```js
164
156
// tailwind.config.js
165
157
module.exports= {
166
-
theme: {
167
-
interFontFeatures: {
168
-
numeric: ['tnum', 'salt', 'ss02']
169
-
}
170
-
},
171
-
plugins: [require('tailwindcss-font-inter')()]
158
+
theme: {
159
+
interFontFeatures: {
160
+
numeric: ['tnum', 'salt', 'ss02']
161
+
}
162
+
},
163
+
plugins: [require('tailwindcss-font-inter')]
172
164
};
173
165
```
174
166
@@ -178,21 +170,22 @@ This will generate the following classes:
0 commit comments