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
2. Create a Tailwind config file for your project by copying the default config file from here:
17
+
2. Create a Tailwind config file foryour project by saving a copy of the default config file somewhere sensible, like `tailwind.js`in your project's root.
To use existing utility classes as mixins in your custom component classes, use the `@apply` custom at-rule:
82
90
83
91
```less
92
+
// Input
84
93
.btn-primary {
85
-
@apply .bg-blue;
86
-
@apply .px-4;
87
-
@apply .py-2;
88
-
@apply .text-light;
94
+
@apply .bg-blue;
95
+
@apply .px-4;
96
+
@apply .py-2;
97
+
@apply .text-light;
98
+
}
99
+
.btn-primary:hover {
100
+
@apply .bg-blue-dark;
101
+
}
89
102
90
-
&:hover {
91
-
@apply .bg-blue-dark;
92
-
}
103
+
// Output
104
+
.btn-primary {
105
+
background-color: #4aa2ea;
106
+
padding-left: 1rem;
107
+
padding-right: 1rem;
108
+
padding-top: .5rem;
109
+
padding-bottom: .5rem;
110
+
color: #fff;
111
+
}
112
+
.btn-primary:hover {
113
+
background-color: #3687c8;
93
114
}
94
115
```
95
116
117
+
96
118
### Referencing config values in your CSS
97
119
98
-
It's not always possible to build component purely out of existing utilities. If you need reference any of your Tailwind config values directly, you can do so with the `tailwind(...)` helper function:
120
+
It's not always possible to build components purely out of existing utilities. If you need to reference any of your Tailwind config values directly, you can do so with the `tailwind(...)` helper function:
99
121
100
122
```less
101
123
.markdown pre {
@@ -110,37 +132,37 @@ You can generate responsive versions of your own utilities by wrapping their def
110
132
111
133
```css
112
134
@responsive {
113
-
.bg-gradient-brand {
114
-
background-image: linear-gradient(blue, green);
115
-
}
135
+
.bg-gradient-brand {
136
+
background-image: linear-gradient(blue, green);
137
+
}
116
138
}
117
139
```
118
140
119
141
This will generate these classes (assuming you haven't changed the default breakpoints):
120
142
121
143
```css
122
144
.bg-gradient-brand {
123
-
background-image: linear-gradient(blue, green);
145
+
background-image: linear-gradient(blue, green);
124
146
}
125
147
@media (min-width: 576px) {
126
-
.sm\:bg-gradient-brand {
127
-
background-image: linear-gradient(blue, green);
128
-
}
148
+
.sm\:bg-gradient-brand {
149
+
background-image: linear-gradient(blue, green);
150
+
}
129
151
}
130
152
@media (min-width: 768px) {
131
-
.md\:bg-gradient-brand {
132
-
background-image: linear-gradient(blue, green);
133
-
}
153
+
.md\:bg-gradient-brand {
154
+
background-image: linear-gradient(blue, green);
155
+
}
134
156
}
135
157
@media (min-width: 992px) {
136
-
.lg\:bg-gradient-brand {
137
-
background-image: linear-gradient(blue, green);
138
-
}
158
+
.lg\:bg-gradient-brand {
159
+
background-image: linear-gradient(blue, green);
160
+
}
139
161
}
140
162
@media (min-width: 1200px) {
141
-
.xl\:bg-gradient-brand {
142
-
background-image: linear-gradient(blue, green);
143
-
}
163
+
.xl\:bg-gradient-brand {
164
+
background-image: linear-gradient(blue, green);
165
+
}
144
166
}
145
167
```
146
168
@@ -152,14 +174,14 @@ Instead of duplicating the values like this:
152
174
153
175
```css
154
176
@media (min-width: 576px) {
155
-
/* ... */
177
+
/* ... */
156
178
}
157
179
```
158
180
159
181
...you can use the `@screen` at-rule and pass the breakpoint name:
0 commit comments