Skip to content

Commit 4cf484f

Browse files
Update README
1 parent 47b46dc commit 4cf484f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
### Table of Contents
1515
- [Installation](#installation)
1616
- [Usage](#usage)
17+
- [Nested variants (quoted values)](#nested-variants-quoted-values)
18+
- [Quotes](#quotes)
1719
- [Why use `tailwindcss-multi`](#why-use-tailwindcss-multi)
1820
- [New syntax explanation](#new-syntax-explanation)
1921
- [What's next?](#whats-next)
@@ -62,6 +64,34 @@ The plugin provides a `multi` directive, allowing you to group multiple utility
6264

6365
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.
6466

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+
6595
## Why use `tailwindcss-multi`
6696

6797
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
112142
>
113143
> So this is valid:
114144
> ```html
115-
> <div class="hover:multi-[[font-family:times]]">...</div>
145+
> <div class="multi-[[font-family:times]]">...</div>
116146
> ```
117147
118148
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

Comments
 (0)