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: src/docs/functions-and-directives.mdx
+39-13Lines changed: 39 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,9 @@ export const description = "A reference for the custom functions and directives
7
7
8
8
Directives are custom Tailwind-specific [at-rules](https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule) you can use in your CSS that offer special functionality for Tailwind CSS projects.
9
9
10
-
<h3id="import-directive">@import</h3>
10
+
<h3id="import-directive">
11
+
<ahref="#import-directive">@import</a>
12
+
</h3>
11
13
12
14
Use the `@import` directive to inline import CSS files, including Tailwind itself:
13
15
@@ -16,7 +18,9 @@ Use the `@import` directive to inline import CSS files, including Tailwind itsel
16
18
@import"tailwindcss";
17
19
```
18
20
19
-
<h3id="theme-directive">@theme</h3>
21
+
<h3id="theme-directive">
22
+
<ahref="#theme-directive">@theme</a>
23
+
</h3>
20
24
21
25
Use the `@theme` directive to define your project's custom design tokens, like fonts, colors, and breakpoints:
22
26
@@ -43,7 +47,9 @@ Use the `@theme` directive to define your project's custom design tokens, like f
43
47
44
48
Learn more about customizing your theme in the [theme variables documentation](/docs/theme).
45
49
46
-
<h3id="source-directive">@source</h3>
50
+
<h3id="source-directive">
51
+
<ahref="#source-directive">@source</a>
52
+
</h3>
47
53
48
54
Use the `@source` directive to explicitly specify source files that aren't picked up by Tailwind's automatic content detection:
49
55
@@ -54,7 +60,9 @@ Use the `@source` directive to explicitly specify source files that aren't picke
54
60
55
61
Learn more about automatic content detection in the [detecting classes in source files documentation](/docs/detecting-classes-in-source-files).
56
62
57
-
<h3id="utility-directive">@utility</h3>
63
+
<h3id="utility-directive">
64
+
<ahref="#utility-directive">@utility</a>
65
+
</h3>
58
66
59
67
Use the `@utility` directive to add custom utilities to your project that work with variants like `hover`, `focus` and `lg`:
60
68
@@ -67,7 +75,9 @@ Use the `@utility` directive to add custom utilities to your project that work w
67
75
68
76
Learn more about registering custom utilities in the [adding custom utilities documentation](/docs/adding-custom-styles#adding-custom-utilities).
69
77
70
-
<h3 id="variant-directive">@variant</h3>
78
+
<h3 id="variant-directive">
79
+
<a href="#variant-directive">@variant</a>
80
+
</h3>
71
81
72
82
Use the `@variant` directive to apply a Tailwind variant to styles in your CSS:
73
83
@@ -85,7 +95,9 @@ Use the `@variant` directive to apply a Tailwind variant to styles in your CSS:
85
95
86
96
Learn more using variants in the [using variants documentation](/docs/adding-custom-styles#using-variants).
Use the `@custom-variant` directive to add a custom variant in your project:
91
103
@@ -98,7 +110,9 @@ This lets you write utilities `theme-midnight:bg-black` and `theme-midnight:text
98
110
99
111
Learn more about adding custom variants in the [adding custom variants documentation](/docs/adding-custom-styles#adding-custom-variants).
100
112
101
-
<h3id="apply-directive">@apply</h3>
113
+
<h3id="apply-directive">
114
+
<ahref="#apply-directive">@apply</a>
115
+
</h3>
102
116
103
117
Use the `@apply` directive to inline any existing utility classes into your own custom CSS:
104
118
@@ -122,7 +136,9 @@ Use the `@apply` directive to inline any existing utility classes into your own
122
136
123
137
This is useful when you need to write custom CSS (like to override the styles in a third-party library) but still want to work with your design tokens and use the same syntax you’re used to using in your HTML.
124
138
125
-
<h3id="reference-directive">@reference</h3>
139
+
<h3id="reference-directive">
140
+
<ahref="#reference-directive">@reference</a>
141
+
</h3>
126
142
127
143
If you want to use `@apply` or `@variant` in the `<style>` block of a Vue or Svelte component, or within CSS modules, you will need to import your theme variables, custom utilities, and custom variants to make those values available in that context.
128
144
@@ -166,7 +182,9 @@ If you’re just using the default theme with no customizations, you can import
166
182
167
183
Tailwind provides the following build-time functions to make working with colors and the spacing scale easier.
168
184
169
-
<h3id="alpha-function">--alpha()</h3>
185
+
<h3id="alpha-function">
186
+
<ahref="#alpha-function">--alpha()</a>
187
+
</h3>
170
188
171
189
Use the `--alpha()` function to adjust the opacity of a color:
172
190
@@ -189,7 +207,9 @@ Use the `--alpha()` function to adjust the opacity of a color:
189
207
190
208
</CodeExampleStack>
191
209
192
-
<h3id="spacing-function">--spacing()</h3>
210
+
<h3id="spacing-function">
211
+
<ahref="#spacing-function">--spacing()</a>
212
+
</h3>
193
213
194
214
Use the `--spacing()` function to generate a spacing value based on your theme:
195
215
@@ -226,7 +246,9 @@ This can also be useful in arbitrary values, especially in combination with `cal
226
246
227
247
The following directives and functions exist solely for compatibility with Tailwind CSS v3.x.
228
248
229
-
<h3id="config-directive">@config</h3>
249
+
<h3id="config-directive">
250
+
<ahref="#config-directive">@config</a>
251
+
</h3>
230
252
231
253
Use the `@config` directive to load a legacy JavaScript-based configuration file:
232
254
@@ -237,7 +259,9 @@ Use the `@config` directive to load a legacy JavaScript-based configuration file
237
259
238
260
The `corePlugins`, `safelist`, and `separator` options from the JavaScript-based config are not supported in v4.0.
239
261
240
-
<h3id="plugin-directive">@plugin</h3>
262
+
<h3id="plugin-directive">
263
+
<ahref="#plugin-directive">@plugin</a>
264
+
</h3>
241
265
242
266
Use the `@plugin` directive to load a legacy JavaScript-based plugin:
243
267
@@ -248,7 +272,9 @@ Use the `@plugin` directive to load a legacy JavaScript-based plugin:
248
272
249
273
The `@plugin` directive accepts either a package name or a local path.
250
274
251
-
<h3id="theme-function">theme()</h3>
275
+
<h3id="theme-function">
276
+
<ahref="#theme-function">theme()</a>
277
+
</h3>
252
278
253
279
Use the `theme()` function to access your Tailwind theme values using dot notation:
0 commit comments