diff --git a/src/docs/adding-custom-styles.mdx b/src/docs/adding-custom-styles.mdx index 765d2e58b..c393912bb 100644 --- a/src/docs/adding-custom-styles.mdx +++ b/src/docs/adding-custom-styles.mdx @@ -526,9 +526,14 @@ If you need to apply multiple variants at the same time, use nesting: ```css /* [!code filename:CSS] */ -@variant dark { - @variant hover { - background: black; +.my-element { + background: white; + + /* [!code highlight:6] */ + @variant dark { + @variant hover { + background: black; + } } } ``` diff --git a/src/docs/dark-mode.mdx b/src/docs/dark-mode.mdx index 20812c7a0..cd093011a 100644 --- a/src/docs/dark-mode.mdx +++ b/src/docs/dark-mode.mdx @@ -116,7 +116,7 @@ If you want your dark theme to be driven by a CSS selector instead of the `prefe @import "tailwindcss"; /* [!code highlight:2] */ -@variant dark (&:where(.dark, .dark *)); +@custom-variant dark (&:where(.dark, .dark *)); ``` Now instead of `dark:*` utilities being applied based on `prefers-color-scheme`, they will be applied whenever the `dark` class is present earlier in the HTML tree: @@ -145,7 +145,7 @@ To use a data attribute instead of a class to activate dark mode, just override @import "tailwindcss"; /* [!code highlight:2] */ -@variant dark (&:where([data-theme=dark], [data-theme=dark] *)); +@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *)); ``` Now dark mode utilities will be applied whenever the `data-theme` attribute is set to `dark` somewhere up the tree: diff --git a/src/docs/functions-and-directives.mdx b/src/docs/functions-and-directives.mdx index 87cf98014..d8149d444 100644 --- a/src/docs/functions-and-directives.mdx +++ b/src/docs/functions-and-directives.mdx @@ -85,9 +85,14 @@ If you need to apply multiple variants at the same time, use nesting: ```css /* [!code filename:CSS] */ -@variant dark { - @variant hover { - background: black; +.my-element { + background: white; + + /* [!code highlight:6] */ + @variant dark { + @variant hover { + background: black; + } } } ``` @@ -106,7 +111,7 @@ Use the `@custom-variant` directive to add a custom variant in your project: This lets you write utilities like `pointer-coarse:size-48` and `theme-midnight:bg-slate-900`. -Learn more about adding custom variants in the [adding custom variants documentation](/docs/adding-custom-styles#adding-custom-variants). +Learn more about adding custom variants in the [registering a custom variant documentation](/docs/hover-focus-and-other-states#registering-a-custom-variant).