Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 45 additions & 10 deletions src/docs/adding-custom-styles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Use the `@variant` directive to apply a Tailwind variant within custom CSS:

</CodeExampleStack>

If you need to apply multiple variants at the same time, use nesting:
If you need to apply multiple variants at the same time, stack them using the same syntax you would in HTML:

<CodeExampleStack>

Expand All @@ -337,11 +337,9 @@ If you need to apply multiple variants at the same time, use nesting:
.my-element {
background: white;

/* [!code highlight:6] */
@variant dark {
@variant hover {
background: black;
}
/* [!code highlight:4] */
@variant hover:focus {
background: black;
}
}
```
Expand All @@ -351,10 +349,10 @@ If you need to apply multiple variants at the same time, use nesting:
.my-element {
background: white;

/* [!code highlight:7] */
@media (prefers-color-scheme: dark) {
&:hover {
@media (hover: hover) {
/* [!code highlight:8] */
&:hover {
@media (hover: hover) {
&:focus {
background: black;
}
}
Expand All @@ -364,6 +362,43 @@ If you need to apply multiple variants at the same time, use nesting:

</CodeExampleStack>

To apply the same styles for multiple variants, separate each variant with a comma:

<CodeExampleStack>

```css
/* [!code filename:app.css] */
.my-element {
background: white;

/* [!code highlight:4] */
@variant hover, focus {
background: black;
}
}
```

```css
/* [!code filename:Compiled CSS] */
.my-element {
background: white;

/* [!code highlight:6] */
&:hover {
@media (hover: hover) {
background: black;
}
}

/* [!code highlight:4] */
&:focus {
background: black;
}
}
```

</CodeExampleStack>

## Adding custom utilities

### Simple utilities
Expand Down