You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/basics/pseudos.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -478,6 +478,7 @@ When it creates a `::view-transition-group-children` pseudo element, the View Tr
478
478
479
479
You define the nesting by setting the `view-transition-group` property on an element. The `view-transition-group` property only works on an element that also has a `view-transition-name`, as it determines how the new group is inserted into the tree of view transition groups. Special values for `view-transition-group` are `normal`, `nearest`, and `contain`. You can also use the name of another group as a value to declare the new group being a child of the referenced group.
480
480
481
+
The parent group of a new group pseudo element is determined when the group is first created. I.e. for groups that are defined in the old state, the styling of the new state won't affect the parent-child relationship of the groups. This holds for both, same-document and cross-document view transitions.
481
482
482
483
If you do not explicitly set the `view-transition-group` property of an element, it defaults to `normal`.
Copy file name to clipboardExpand all lines: src/content/docs/basics/styling.mdx
+40-10Lines changed: 40 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -327,27 +327,57 @@ If multiple class names are used to identify a pseudo element, all must match. T
327
327
}
328
328
```
329
329
330
-
Or shorter, without the star:
330
+
331
+
This is how you assign the classes
331
332
332
333
```css
333
-
::view-transition-group(.nav-link) {
334
-
/* ... */
334
+
#navbara {
335
+
view-transition-class: nav-link; /* one class */
336
+
}
337
+
#prev,
338
+
#next {
339
+
view-transition-class: nav-link some-other-class; /* multiple classes, space separated */
335
340
}
336
341
```
337
342
338
-
This is an example on how to assign the class:
343
+
This might best be combined with [dynamically added view transition names](/tips/auto-names/).
344
+
345
+
As in normal pseudo-element selectors without view transition classes, you can also use a view transition name instead of the star to address the pseudo element for that name.
339
346
340
347
```css
341
-
#navbara {
342
-
view-transition-class: nav-link;
348
+
::view-transition-group(card5.card) {
349
+
/* ... */
343
350
}
344
-
#prev,
345
-
#next {
346
-
view-transition-class: nav-link some-other-class;
351
+
```
352
+
This will select the view transition group pseudo for the view transition name `card5`, but only if the element also has the `.card` view transition class.
353
+
Like with CSS classes, you can even have multiple view transition classes one selector.
354
+
355
+
```css
356
+
::view-transition-group(*.card.special) {
357
+
/* ... */
358
+
}
359
+
```
360
+
Make sure you have no whitespace in such a selector.
361
+
362
+
The above selector selects all groups that have both view transition classes:
363
+
364
+
```css
365
+
view-transition-class: card; /* won't be selected, view transition class special is missing */
366
+
view-transition-class: special; /* won't be selected, view transition class card is missing */
367
+
view-transition-class: special card; /* will be selected, order does not matter */
368
+
view-transition-class: card something special /* also fine, element might have additional classes */
369
+
```
370
+
371
+
The view transition class names for a group and all its children are defined when the group is last encountered [during capturing](/basics/pseudos/#view-transition-names). A group that is present in the new state will have the class names defined in the new state styles. Only groups that were only present in the old state will have the view transition class names defined on the old state styling. This holds for both, same-document and cross-document view transitions.
372
+
373
+
Does that sound a bit complicated? Good news: the most common case is also the simplest: the `*` can be omitted in selectors that use view transition class names. With a single class, the card example from above then looks like this:
374
+
375
+
```css
376
+
::view-transition-group(.nav-link) {
377
+
/* ... */
347
378
}
348
379
```
349
380
350
-
This might best be combined with dynamically (per script) added view transition names or tooling where you declaratively assign view transition names.
0 commit comments