diff --git a/src/docs/adding-custom-styles.mdx b/src/docs/adding-custom-styles.mdx index 56069ae8a..bf3792fc3 100644 --- a/src/docs/adding-custom-styles.mdx +++ b/src/docs/adding-custom-styles.mdx @@ -328,7 +328,7 @@ Use the `@variant` directive to apply a Tailwind variant within custom CSS: -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: @@ -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; } } ``` @@ -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; } } @@ -364,6 +362,43 @@ If you need to apply multiple variants at the same time, use nesting: +To apply the same styles for multiple variants, separate each variant with a comma: + + + +```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; + } +} +``` + + + ## Adding custom utilities ### Simple utilities