Skip to content

Commit a6eabb0

Browse files
committed
WIP
1 parent 05ea803 commit a6eabb0

File tree

1 file changed

+69
-8
lines changed

1 file changed

+69
-8
lines changed

src/pages/docs/v4-beta.mdx

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -926,23 +926,84 @@ It works with `supports-*` variants too, so you can style an element based on th
926926

927927
### \`inert\` variant
928928

929+
The new `inert` variant lets you style elements marked with the `inert` attribute:
930+
931+
```html
932+
<main **inert** class="**inert:opacity-50** **inert:blur**">
933+
<!-- ... -->
934+
</main>
935+
```
936+
937+
This is useful for adding visual cues that make it clear that an element isn't interactive.
938+
929939
### \`nth-*\` variants
930940

941+
We've added four new variants for the `:nth-child(…)`, `:nth-last-child(…)`, `:nth-of-type(…)`, and `:nth-last-of-type(…)` pseudo-classes:
942+
943+
```html
944+
<div class="**nth-3:underline**">…</div>
945+
<div class="**nth-last-5:underline**">…</div>
946+
<div class="**nth-of-type-4:underline**">…</div>
947+
<div class="**nth-last-of-type-6:underline**">…</div>
948+
```
949+
950+
You can pass any number you want to these by default, and use arbitrary values for more complex expressions like `nth-[2n+1_of_li]`.
951+
931952
### \`in-*\` variant
932953

954+
You know our `group-*` variants like `group-focus`? The new `in-*` variant is just like that except you don't need to add `group` to the parent element:
955+
956+
```diff-html
957+
- <div tabindex="0" class="group">
958+
- <div class="opacity-50 group-focus:opacity-100">
959+
+ <div tabindex="0">
960+
+ <div class="opacity-50 in-focus:opacity-100">
961+
<!-- ... -->
962+
</div>
963+
</div>
964+
```
965+
966+
You'll still want the `group-*` stuff a lot of the time when you need fine control, but this will save you some characters the rest of the time.
967+
933968
### \`:popover-open\` support
934969

970+
We've updated our existing `open` variant to target the `:popover-open` pseudo-class as well as the `[open]` attribute:
971+
972+
```html
973+
<div>
974+
<button popovertarget="my-popover">Open Popover</button>
975+
<div popover id="my-popover" class="opacity-0 **open:opacity-100** ...">
976+
<!-- ... -->
977+
</div>
978+
</div>
979+
```
980+
981+
I'm sure I'm eventually going to regret not making it a separate `popover-open` variant but I thought _really_ hard about it and couldn't think of any situations where an element would use both `[open]` and `:popover-open` and have different styles for each condition. Someone is going to update the spec and screw me on this one down the road though for sure.
982+
935983
### Descendant variant
936984

937-
- Simplified theme configuration
938-
- Bare values in variants (`data-potato` instead of `data-[potato]`)
939-
- Infinite spacing scale, grid columns/rows, opacities, z-index, scale transforms
940-
- Bare aspect-ratio values
941-
- CSS variables for your theme
942-
- Can override variants
943-
- Heuristic-driven sorting so custom utilities sort more intuitively with built-in utilities
944-
- Individual transforms
985+
You know the `*` variant we shipped a while ago for targeting direct children?
986+
987+
```html
988+
<ul class="*:p-4">
989+
<li>One</li>
990+
<li>Two</li>
991+
<li>Three</li>
992+
</ul>
993+
```
994+
995+
In v4.0 we've added a new `**` variant for targeting all descendants — most useful in my opinion if you combine it with another variant for narrowing the thing you're selecting:
996+
997+
```html
998+
<div class="**:img:rounded-full">
999+
<div>
1000+
<img src="" />
1001+
</div>
1002+
<p>…</p>
1003+
</div>
1004+
```
9451005

1006+
Fun fact — the syntax is inspired by globs, for better or for worse.
9461007

9471008
---
9481009

0 commit comments

Comments
 (0)