Skip to content

Fix view-transition-class custom-ident description#43836

Open
TGianella wants to merge 3 commits intomdn:mainfrom
TGianella:fix/43784-view-transition-class
Open

Fix view-transition-class custom-ident description#43836
TGianella wants to merge 3 commits intomdn:mainfrom
TGianella:fix/43784-view-transition-class

Conversation

@TGianella
Copy link
Copy Markdown

@TGianella TGianella commented Apr 17, 2026

Description

Corrects several issues related to custom-ident value description in view-transition-class doc (1 commit for each, in this order):

  • It does not need to be unique
  • It does not cause the element to participate in a separate view-transition group
  • Several custom-ident are supported but apart from the formal syntax the first sentence of the doc implies that only one class can be given.

Motivation

I came to this article to know whether I could use several custom-idents on one element and I missed the + in the formal syntax but nowhere else in the doc this is said and I feel readers could benefit from a bit of redundancy and more clarity.

The value description field was plain wrong, the info is true for view-transition-name but not for view-transition-class so it contributes to keep the confusion going between these two.

Related issues and pull requests

Fixes #43784

@TGianella TGianella requested a review from a team as a code owner April 17, 2026 07:52
@TGianella TGianella requested review from pepelsbey and removed request for a team April 17, 2026 07:52
@github-actions github-actions Bot added Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed labels Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thank you 🙂

I would go the extra step and make sure it’s clear, both from the description and additional examples. What do you think?


- {{cssxref("custom-ident")}}
- : An identifying name that causes the selected element to participate in a separate [view transition](/en-US/docs/Web/API/View_Transition_API) from the root view transition. The identifier must be unique. If two rendered elements have the same `view-transition-name` at the same time, {{domxref("ViewTransition.ready")}} will reject and the transition will be skipped.
- : An identifying name that allows the element to be selected by view transition pseudo-elements in order to apply styles during the transition.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- : An identifying name that allows the element to be selected by view transition pseudo-elements in order to apply styles during the transition.
- : An identifying name used to select view transition pseudo-elements for styling. Unlike `view-transition-name`, a class does not need to be unique and does not cause the element to participate in a separate view transition group.

I would not only remove the factual mistake but double down on the fact.

Comment on lines 55 to 71
```css
::view-transition-group(.fast-card-slide) {
animation-duration: 3s;
}

.product {
view-transition-class: fast-card-slide;
}

.product#card1 {
view-transition-name: show-card;
}

.product#card2 {
view-transition-name: hide-card;
}
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Styling a shared class across multiple elements
In this example, three cards each have a unique {{cssxref("view-transition-name")}} (required for pairing old and new states), but they all share the same `view-transition-class`. This lets you write a single rule that styles all their transitions at once, rather than repeating styles for each name individually. Unlike `view-transition-name`, a `view-transition-class` does not need to be unique.
```html
<div class="card" id="card1">Card 1</div>
<div class="card" id="card2">Card 2</div>
<div class="card" id="card3">Card 3</div>
```
```css
/* Each element must have a unique view-transition-name */
#card1 {
view-transition-name: card-1;
}
#card2 {
view-transition-name: card-2;
}
#card3 {
view-transition-name: card-3;
}
/* But they can all share the same view-transition-class */
.card {
view-transition-class: card;
}
/* This single rule applies to all three cards' transitions */
::view-transition-group(*.card) {
animation-duration: 0.5s;
animation-timing-function: ease-in-out;
}
```
### Using multiple classes on a single element
In this example, both product cards are assigned `fast-card-slide` via `view-transition-class`, while each still has its own unique {{cssxref("view-transition-name")}}. A single `::view-transition-group(.fast-card-slide)` rule then applies the same animation duration to both cards' transitions, without needing to target each name individually.
```html
<div class="product" id="card1">Card 1</div>
<div class="product" id="card2">Card 2</div>
```
```css
.product {
view-transition-class: fast-card-slide;
}
.product#card1 {
view-transition-name: show-card;
}
.product#card2 {
view-transition-name: hide-card;
}
::view-transition-group(.fast-card-slide) {
animation-duration: 3s;
}
```

Copy link
Copy Markdown
Author

@TGianella TGianella Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition, I agree with you on going the extra mile!

Unless I'm mistaken in the Using multiple classes on a single element section example you only use one class on several elements.

Here is what I have in mind to better exemplify this section with different "atomic" styles (animation-name/animation-duration) that you might want to apply separately across a codebase:

<div class="card" id="card1">Card 1</div>
<div class="card" id="card2">Card 2</div>
.card {
  view-transition-class: slide fast-transition;
}

.product#card1 {
  view-transition-name: card1;
}

.product#card2 {
  view-transition-name: card2;
}

::view-transition-new(.slide) {
  animation-name: slide-in;
}

::view-transition-old(.slide) {
  animation-name: slide-out;
}

::view-transition-group(.fast-transition) {
  animation-duration: .5s;
}

What do you think ?

@TGianella TGianella requested a review from pepelsbey April 22, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

view-transition-class <custom-ident> value description is wrong

3 participants