|
14 | 14 | ### Table of Contents
|
15 | 15 | - [Installation](#installation)
|
16 | 16 | - [Usage](#usage)
|
| 17 | + - [Nested variants (quoted values)](#nested-variants-quoted-values) |
| 18 | + - [Quotes](#quotes) |
17 | 19 | - [Why use `tailwindcss-multi`](#why-use-tailwindcss-multi)
|
18 | 20 | - [New syntax explanation](#new-syntax-explanation)
|
19 | 21 | - [What's next?](#whats-next)
|
@@ -62,6 +64,34 @@ The plugin provides a `multi` directive, allowing you to group multiple utility
|
62 | 64 |
|
63 | 65 | The directive accepts a semicolon-delimited list of utility classes and applies them to the selected element. A key feature of `tailwindcss-multi` is its support for arbitrary values, which are not limited to predefined classes in Tailwind CSS.
|
64 | 66 |
|
| 67 | +### Nested variants (quoted values) |
| 68 | + |
| 69 | +When a value includes a colon `:`, the value must be quoted to ensure compatibility with newer versions of Tailwind CSS. This is due to a breaking change introduced in Tailwind CSS v3.3.6 ([explanation](#whats-next)). |
| 70 | + |
| 71 | +> [!NOTE] |
| 72 | +> One exception to this `:` rule is if the colon is used for a CSS property-value pair, like `multi-[[font-family:times]]`. In this case, quotes are not needed, as this is the expected case for using a colon `:`, which is actually what warranted the breaking change in the first place. |
| 73 | +> |
| 74 | +> So this is valid: |
| 75 | +> ```html |
| 76 | +> <div class="multi-[[font-family:times]]">...</div> |
| 77 | +> ``` |
| 78 | +
|
| 79 | +#### Quotes |
| 80 | +
|
| 81 | +Valid quotes include single `'`, double `"`, and backticks `` ` ``. The choice of quote is up to you, per usage. Quotes chosen must be kept consistent within the same value. |
| 82 | +
|
| 83 | +```html |
| 84 | +<!-- ✅ All valid --> |
| 85 | +<div class="multi-['hover:font-bold']">...</div> |
| 86 | +<div class='multi-["hover:font-bold"]'>...</div> |
| 87 | +<div class="multi-[`hover:font-bold`]">...</div> |
| 88 | +
|
| 89 | +<!-- ❌ Invalid mix of quotes --> |
| 90 | +<div class="multi-['hover:font-bold"]">...</div> |
| 91 | +<div class="multi-["hover:font-bold`]">...</div> |
| 92 | +<!-- etc. --> |
| 93 | +``` |
| 94 | +
|
65 | 95 | ## Why use `tailwindcss-multi`
|
66 | 96 |
|
67 | 97 | In some cases, you may need to apply several utilities to a long or convoluted variant or even chain of variants, which can start to look like this:
|
@@ -112,7 +142,7 @@ This change required a slight tweak to the syntax of the `multi` directive. When
|
112 | 142 | >
|
113 | 143 | > So this is valid:
|
114 | 144 | > ```html
|
115 |
| -> <div class="hover:multi-[[font-family:times]]">...</div> |
| 145 | +> <div class="multi-[[font-family:times]]">...</div> |
116 | 146 | > ```
|
117 | 147 |
|
118 | 148 | Versions of Tailwind CSS thereafter (v3.3.6+) are now incompatible with versions of the original unquoted syntax for this plugin (pre-v0.2.0) for values that contain a colon `:`. Update to `@latest` to ensure compatibility. This new version syntax is reverse-compatible with versions of Tailwind CSS prior to v3.3.6 as well.
|
|
0 commit comments