Skip to content

Commit 4f07777

Browse files
committed
Add <CodeExampleStack>
1 parent 0ce525d commit 4f07777

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: src/docs/detecting-classes-in-source-files.mdx

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { TipGood, TipBad, TipInfo } from "@/components/tips";
22
import { Iframe } from "@/components/iframe";
33
import { Example } from "@/components/example";
44
import { Figure } from "@/components/figure";
5+
import { CodeExampleStack } from "@/components/code-example";
56

67
export const title = "Detecting classes in source files";
78
export const description = "Understanding and customizing how Tailwind scans your source files.";
@@ -199,6 +200,7 @@ This can be useful in projects that have multiple Tailwind stylesheets where you
199200

200201
If you need to make sure Tailwind generates certain class names that don’t exist in your content files, you can force them to be inlined by using `@source inline()`:
201202

203+
<CodeExampleStack>
202204
```css
203205
/* [!code filename:CSS] */
204206
@import "tailwindcss";
@@ -213,10 +215,13 @@ If you need to make sure Tailwind generates certain class names that don’t exi
213215
}
214216
```
215217

218+
</CodeExampleStack>
219+
216220
### Generating variants
217221

218222
You can also use `@source inline()` to generate classes with variants. For example, to generate the `underline` class with hover and focus variants, add `{hover:,focus:,}` to the source input:
219223

224+
<CodeExampleStack>
220225
```css
221226
/* [!code filename:CSS] */
222227
@import "tailwindcss";
@@ -241,19 +246,20 @@ You can also use `@source inline()` to generate classes with variants. For examp
241246
}
242247
```
243248

249+
</CodeExampleStack>
250+
244251
### Generating ranges
245252

246253
The source input is [brace expanded](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), so you can generate multiple classes at once. For example, to generate all the red shades with hover variants, you can add a range to the source input:
247254

255+
<CodeExampleStack>
248256
```css
249257
/* [!code filename:CSS] */
250258
@import "tailwindcss";
251259
/* [!code highlight:2] */
252260
@source inline("{hover:,}bg-red-{50,{100..900..100},950}");
253261
```
254262

255-
This will generate shades of red from 50 to 950 in increments of 100, along with hover variants for each shade:
256-
257263
```css
258264
/* [!code filename:Generated CSS] */
259265
.bg-red-50 {
@@ -290,6 +296,10 @@ This will generate shades of red from 50 to 950 in increments of 100, along with
290296
}
291297
```
292298

299+
</CodeExampleStack>
300+
301+
This generates shades of red from 100 to 900 in increments of 100, along with the first and last shades of 50 and 950. It also adds the `hover:` variant for each of those classes.
302+
293303
### Explicitly excluding classes
294304

295305
If you need to avoid specific classes from being generated you can use `@source not inline()`:

0 commit comments

Comments
 (0)