Skip to content

Keep your coding agent up to date with the latest web best practices

Release v0.0.61

github-actions[bot]3c1baeca10f6
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 458fd7a..0409a3f 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -8,7 +8,7 @@
"name": "modern-web-guidance",
"source": "./",
"description": "Google Chrome's agent skills collection",
- "version": "0.0.60"
+ "version": "0.0.61"
}
]
}
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index b43d754..04c2aa2 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "modern-web-guidance",
"description": "Google Chrome's agent skills collection",
- "version": "0.0.60",
+ "version": "0.0.61",
"author": {
"name": "Google Chrome"
}
diff --git a/README.md b/README.md
index 04e1342..5a32a91 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
This curated collection of skills, tools, and AI-ready documentation injects Chrome's web platform knowledge directly into your workflow, ensuring your coding agent builds apps that are modern, fast, and secure by default.
-#### Skill Coverage in `v0.0.60`
+#### Skill Coverage in `v0.0.61`
<details>
<summary><strong>73 web features with implementation guidance from Chrome's experts</strong>: `::backdrop`, `:autofill`, `:has()`, `:not()`, `:user-valid and :user-invalid`, `@starting-style`, `&lt;details>`, `&lt;dialog closedby>`, `&lt;dialog>`, `&lt;link rel="expect">`, `&lt;link rel="preload">`, `AbortController and AbortSignal`, `accent-color`, `Active view transition`, `Anchor positioning`, `blocking="render"`, `calc-size()`, `color-scheme`, `content-visibility`, `Cross-document view transitions`, `Customizable &lt;select>`, `Email, telephone, and URL &lt;input> types`, `enterkeyhint`, `Fetch`, `Fetch priority`, `fetchLater`, `field-sizing`, `font-size-adjust`, `Form-associated WebMCP attributes`, `hidden="until-found"`, `image-set()`, `Individual transform properties`, `inert`, `inputmode`, `Interest invokers`, `interpolate-size`, `Intl.DurationFormat`, `Invoker commands`, `light-dark()`, `linear() easing`, `Long animation frames`, `Masks`, `moveBefore()`, `Mutually exclusive &lt;details> elements`, `Navigation API`, `navigator.modelContext`, `overlay`, `Page visibility state`, `Popover`, `popover="hint"`, `prefers-color-scheme media query`, `prefers-contrast media query`, `prefers-reduced-motion media query`, `Registered custom properties`, `Scheduler API`, `Scroll snap`, `Scroll-driven animations`, `scroll-initial-target`, `scrollbar-color`, `scrollbar-width`, `scrollIntoView()`, `sibling-count() and sibling-index()`, `sin(), cos(), tan(), asin(), acos(), atan(), and atan2() (CSS)`, `Speculation rules`, `Temporal`, `text-box`, `text-wrap`, `text-wrap: balance`, `text-wrap: pretty`, `Top-level await`, `transition-behavior`, `View transitions`, `view-transition-class`</summary>
@@ -157,6 +157,8 @@ This curated collection of skills, tools, and AI-ready documentation injects Chr
- **prevent-text-wrapping**: Ensure the browser does not insert line breaks into text and will allow text to overflow its container.
- **[Top-level await](https://webstatus.dev/features/top-level-await)**
- **conditional-async-dependencies**: Conditionally load or initialize async dependencies (such as importing polyfills for missing web features) without requiring complex orchestration across all of a page's script dependencies.
+- **[View transitions](https://webstatus.dev/features/view-transitions)**
+ - **same-document-transitions**: Visually connect persisting elements across different page states or navigations in a Single Page Application (SPA) (e.g. expanding a product thumbnail into a full-bleed hero image) by smoothly morphing their size, position, or other styling properties.
- **[view-transition-class](https://webstatus.dev/features/view-transition-class), [View transitions](https://webstatus.dev/features/view-transitions)**
- **group-element-transitions**: Transition a group of similar elements simultaneously using the same transition logic, such as removing a product from a shopping cart and having all the other products animate into their new positions.
</details>
diff --git a/gemini-extension.json b/gemini-extension.json
index 28b57ae..5473026 100644
--- a/gemini-extension.json
+++ b/gemini-extension.json
@@ -1,7 +1,7 @@
{
"name": "modern-web-guidance",
"description": "Google Chrome's web development agent skills.",
- "version": "0.0.60",
+ "version": "0.0.61",
"author": {
"name": "Google Chrome"
}
diff --git a/package.json b/package.json
index 8119151..ffe7cc1 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "modern-web-guidance",
"displayName": "Modern Web Guidance",
"description": "Curated collection of agent skills for modern web development.",
- "version": "0.0.60",
+ "version": "0.0.61",
"publisher": "GoogleChrome",
"engines": {
"vscode": "^1.90.0",
diff --git a/skills/modern-web/guides/user-experience/same-document-transitions.md b/skills/modern-web/guides/user-experience/same-document-transitions.md
new file mode 100644
index 0000000..e3fba69
--- /dev/null
+++ b/skills/modern-web/guides/user-experience/same-document-transitions.md
@@ -0,0 +1,166 @@
+# Same Document Transitions
+
+## The Problem
+
+Web sites often provide multiple views of an object, for instance a list of products, and then a detail page for each product. Navigating between the two views often feels disconnected. When a user clicks a product thumbnail to view its details, the thumbnail disappears and a new, larger image appears instantly elsewhere on the screen. This lack of continuity makes it harder for users to track relationships between elements.
+
+## The Solution
+
+The **View Transitions API** allows you to specify element pairs that exist in different states before and after a transition. When triggering a transition with `document.startViewTransition()` in a Single Page Navigation (SPA), the browser identifies these shared elements by their shared unique `view-transition-name`. It then automatically calculates the difference in their position, size, and styling, and animates them smoothly from the old state to the new state. This transition occurs in the top layer, above even elements with high `z-index` values.
+
+## Implementation Guide
+
+### Step 1: Wrap State Changes in `startViewTransition`
+
+For Single-Page Applications (SPAs) or simple state changes, wrap the logic that updates the DOM in `document.startViewTransition`. The browser captures a snapshot of the current state, runs the update, and then captures the new state.
+
+```javascript
+function navigate(view) {
+ // MANDATORY: Wrap the update in startViewTransition
+ document.startViewTransition(() => updateDOM(view));
+}
+```
+
+### Step 2: Assign Shared Transition Names
+
+Use the `view-transition-name` CSS property to tell the browser which elements should be morphed. The name can be anything (except `none`). **MANDATORY**: there must be no more than 1 element before and after with a given `view-transition-name`. If there are 2 or more elements with a given `view-transition-name`, the DOM will be updated to the new state immediately, without a transition.
+
+You can use multiple `view-transition-name`s to morph multiple pairs of elements. For example, you may want to transition both the product image and title with separate transitions.
+
+Because there are multiple items on the list view, you can not give the all of them the same `view-transition-name`. This can be solved in two ways in a SPA.
+
+1. **Dynamic detail page:** Assign each item on the list page a unique `view-transition-name`, and then dynamically apply that name to the matching element on the detail page when the list item is selected, as shown here.
+
+```css
+/* In the list view, give each */
+#product-1 { view-transition-name: p1 }
+#product-2 { view-transition-name: p2 }
+#product-3 { view-transition-name: p3 }
+```
+
+```js
+function updateDOM(clickedTransitionName){
+ const hero = document.getElementById("hero");
+ hero.style.viewTransitionName = clickedTransitionName;
+}
+```
+
+2. **Dynamic list item:** Assign the element on the detail page a `view-transition-name`, and apply that name to the item on the list page when it is selected. Remove the `view-transition-name` from the item on the list page when returning to the list page.
+
+The `#hero` element on the detail page and the selected `.thumbnail` element on the list page share a `view-transition-name`.
+
+```css
+#hero{
+ view-transition-name: hero;
+}
+.thumbnail.selected {
+ view-transition-name: hero;
+}
+```
+
+When a thumbnail is clicked, we need to prepare the list view by assigning the `view-transition-name` using the `.selected` class selector, and making any changes to the DOM before starting the transition.
+
+Then, you can call `document.startViewTransition()`, and apply the changes to transition the page from the detail to list view.
+
+After navigating back to the list view, you must clean up the view transition classes to prevent the next navigation from erroring. You can perform this cleanup after the transition's `finished` promise resolves.
+
+```javascript
+// Function called when a thumbnail is clicked
+function goFromListToDetail(e){
+ e.currentTarget.classList.add("selected");
+ const hero = document.getElementById("hero");
+ const bgColor = getComputedStyle(e.currentTarget).backgroundColor;
+ hero.style.background = bgColor;
+
+ // Trigger the transition, checking for support
+ if (!document.startViewTransition) {
+ document.body.classList.add("detail");
+ return; // MANDATORY: End function execution if view transitions are not supported.
+ }
+ const transition = document.startViewTransition(() => {
+ document.body.classList.add("detail");
+ });
+}
+
+// Function called when navigating from detail back to list view
+function goFromDetailToList() {
+ if (!document.startViewTransition) {
+ document.body.classList.remove("detail");
+ return;
+ }
+ const transition = document.startViewTransition(() => {
+ document.body.classList.remove("detail");
+ });
+ // Clean up the list view
+ transition.finished.finally(() => {
+ // Remove selected classList to remove view-transition-names
+ document.querySelectorAll(".selected").forEach(
+ (element) => {
+ element.classList.remove("selected");
+ },
+ );
+ });
+}
+```
+
+The method you choose will depend on the use case. The dynamic list item requires less repeated CSS, but more manual JavaScript cleanup.
+
+
+### Step 3: Fix Aspect Ratio "Stretching"
+
+By default, the browser cross-fades the old and new snapshots within a group that stretches to fit both. If you are transitioning text, set the width of the text element to `fit-content` on both the old and new views, so that the transitioned element's aspect ratio is stable.
+
+```css
+#list-page .title {
+ width: fit-content;
+}
+
+#detail-page #title {
+ width: fit-content;
+}
+```
+
+If you are transitioning elements that change aspect ratio, you may need to set the height of the old and new pseudo-elements to 100% of the `::view-transition-pair()` pseudo-element.
+
+```css
+::view-transition-old(hero),
+::view-transition-new(hero){
+ height: 100%;
+}
+```
+
+The pseudo-elements are snapshots of the live elements, so you can also use `object-fit` and `object-position` declarations for more control of the transitioning effect.
+
+## Best Practices
+
+- **DO NOT** specify too many transitions. Only use shared elements for primary content that the user is actively tracking (e.g., hero images, headings).
+- **DO** remove temporary `view-transition-name` values after the transition finishes to avoid side effects on future transitions.
+- **DO NOT** transition elements with active animations. View transitions operate on snapshots, so any animations will appear to be paused during the view transition.
+- **DO** respect user preferences for reduced motion using the `prefers-reduced-motion` media query.
+
+```css
+@media (prefers-reduced-motion: reduce) {
+ ::view-transition-group(*),
+ ::view-transition-old(*),
+ ::view-transition-new(*) {
+ animation: none !important;
+ }
+}
+```
+
+## Fallback Strategies
+
+Baseline status for View transitions: Newly available. It's been Baseline since 2025-10-14.
+
+The View Transitions API is designed for progressive enhancement. Browsers that do not support it will simply execute the DOM update immediately without animation.
+
+```javascript
+function navigate(){
+ if (!document.startViewTransition) {
+ // Fallback: Just update the DOM
+ updateDOM();
+ } else {
+ document.startViewTransition(() => updateDOM());
+ }
+}
+```