Skip to content

Commit 16f89ab

Browse files
authored
[v3.2] Add supports-[] modifier documentation (tailwindlabs#1390)
* Add `supports-[]` modifier * Add `supports-[]` to "Quick reference" * Rename "Media queries" section to "Media and feature queries" * Move "supports" to last item in "Media and feature queries" section * Rename "Supports" title to "Supports rules"
1 parent dd5089f commit 16f89ab

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/pages/docs/hover-focus-and-other-states.mdx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ If you're using native `<dialog>` elements in your project, you may also want to
672672

673673
---
674674

675-
## Media queries
675+
## Media and feature queries
676676

677677
### Responsive breakpoints
678678

@@ -855,6 +855,26 @@ Use the `print` modifier to conditionally add styles that only apply when the do
855855
</div>
856856
```
857857

858+
### Supports rules
859+
860+
Use the `supports-[...]` modifier to style things based on whether a certain feature is supported in the user's browser.
861+
862+
```html
863+
<div class="flex **supports-[display:grid]:grid** ...">
864+
<!-- ... -->
865+
</div>
866+
```
867+
868+
Under the hood the `supports-[...]` modifier generates [`@supports rules`](https://developer.mozilla.org/en-US/docs/Web/CSS/@supports) and takes anything you’d use with `@supports (...)` between the square brackets, like a property/value pair, and even expressions using `and` and `or`.
869+
870+
For terseness, if you only need to check if a property is supported (and not a specific value), you can just specify the property name:
871+
872+
```html
873+
<div class="bg-black/75 **supports-[backdrop-filter]:bg-black/25** **supports-[backdrop-filter]:backdrop-blur** ...">
874+
<!-- ... -->
875+
</div>
876+
```
877+
858878
---
859879

860880
## Attribute selectors
@@ -1226,6 +1246,7 @@ A quick reference table of every single modifier included in Tailwind by default
12261246
| <a href="#prefers-contrast" className="whitespace-nowrap">contrast-more</a> | <code className="whitespace-nowrap before:content-none after:content-none">@media (prefers-contrast: more)</code> |
12271247
| <a href="#prefers-contrast" className="whitespace-nowrap">contrast-less</a> | <code className="whitespace-nowrap before:content-none after:content-none">@media (prefers-contrast: less)</code> |
12281248
| <a href="#print-styles" className="whitespace-nowrap">print</a> | <code className="whitespace-nowrap before:content-none after:content-none">@media print</code> |
1249+
| <a href="#supports" className="whitespace-nowrap">supports-[<span className="text-slate-400">...</span>]</a> | <code className="whitespace-nowrap before:content-none after:content-none">@supports (<span className="text-slate-400">...</span>)</code> |
12291250
| <a href="#rtl-support" className="whitespace-nowrap">rtl</a> | <code className="whitespace-nowrap before:content-none after:content-none">[dir="rtl"] <span className="text-slate-400">&</span></code> |
12301251
| <a href="#rtl-support" className="whitespace-nowrap">ltr</a> | <code className="whitespace-nowrap before:content-none after:content-none">[dir="ltr"] <span className="text-slate-400">&</span></code> |
12311252

0 commit comments

Comments
 (0)