Skip to content

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

Release v0.0.88

github-actions[bot]ba33fedcc528
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 0729332..1ccd373 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.87"
+ "version": "0.0.88"
}
]
}
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index fe44485..ccb65ef 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.87",
+ "version": "0.0.88",
"author": {
"name": "Google Chrome"
}
diff --git a/README.md b/README.md
index 0623893..4e9ee10 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,10 @@
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.87`
+#### Skill Coverage in `v0.0.88`
<details>
-<summary><strong>80 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 position container queries`, `Anchor positioning`, `blocking="render"`, `calc-size()`, `color-scheme`, `Container queries`, `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`, `Intersection observer`, `Intl.DurationFormat`, `Invoker commands`, `Language detector`, `light-dark()`, `linear() easing`, `Long animation frames`, `Masks`, `moveBefore()`, `Mutually exclusive &lt;details> elements`, `Navigation API`, `navigator.modelContext`, `overlay`, `Page visibility`, `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`, `Summarizer`, `Temporal`, `text-box`, `text-wrap`, `text-wrap: balance`, `text-wrap: pretty`, `Top-level await`, `transition-behavior`, `Translator`, `View transitions`, `view-transition-class`</summary>
+<summary><strong>81 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 position container queries`, `Anchor positioning`, `blocking="render"`, `calc-size()`, `color-scheme`, `Container queries`, `Container scroll-state queries`, `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`, `Intersection observer`, `Intl.DurationFormat`, `Invoker commands`, `Language detector`, `light-dark()`, `linear() easing`, `Long animation frames`, `Masks`, `moveBefore()`, `Mutually exclusive &lt;details> elements`, `Navigation API`, `navigator.modelContext`, `overlay`, `Page visibility`, `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`, `Summarizer`, `Temporal`, `text-box`, `text-wrap`, `text-wrap: balance`, `text-wrap: pretty`, `Top-level await`, `transition-behavior`, `Translator`, `View transitions`, `view-transition-class`</summary>
- **[::backdrop](https://webstatus.dev/features/backdrop), [&lt;dialog>](https://webstatus.dev/features/dialog), [overlay](https://webstatus.dev/features/overlay), [Popover](https://webstatus.dev/features/popover), [@starting-style](https://webstatus.dev/features/starting-style), [transition-behavior](https://webstatus.dev/features/transition-behavior)**
- **animate-to-from-top-layer**: Animate elements such as dialogs, popovers, and tooltips as they're entering/exiting the top layer.
@@ -64,6 +64,8 @@ This curated collection of skills, tools, and AI-ready documentation injects Chr
- **[Container queries](https://webstatus.dev/features/container-queries)**
- **fluid-scaling**: Scale items like font size, spacing, and media sizes smoothly based on the parent container's size rather than using fixed breakpoints
- **size-aware-styling**: Build a component whose styles can be conditionally dependent on its own width or height, rather than the width or height of the viewport. For example a card component that can change its layouts depending on how large it is, or a call-to-action button that can conditionally display helper text based on its width.
+- **[Container scroll-state queries](https://webstatus.dev/features/container-scroll-state-queries)**
+ - **carousel-snap-highlights**: Visually highlight the currently snapped non-interactive item in scroll-snapping carousels, galleries, or full-page swipe experiences. For example, expanding a card when snapped, or revealing hidden content.
- **[content-visibility](https://webstatus.dev/features/content-visibility), [hidden="until-found"](https://webstatus.dev/features/hidden-until-found)**
- **defer-rendering-heavy-content**: Reduce rendering times in content-heavy web pages (e.g. pages with long feeds, lots of articles, or complex dashboards), by deferring rendering for any content that is not immediately visible to the user.
- **[content-visibility](https://webstatus.dev/features/content-visibility)**
diff --git a/gemini-extension.json b/gemini-extension.json
index bb20417..aaf5588 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.87",
+ "version": "0.0.88",
"author": {
"name": "Google Chrome"
}
diff --git a/package.json b/package.json
index 23076e5..0636257 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.87",
+ "version": "0.0.88",
"publisher": "GoogleChrome",
"engines": {
"vscode": "^1.90.0",
diff --git a/skills/modern-web/guides/user-experience/carousel-snap-highlights.md b/skills/modern-web/guides/user-experience/carousel-snap-highlights.md
new file mode 100644
index 0000000..e3a6a63
--- /dev/null
+++ b/skills/modern-web/guides/user-experience/carousel-snap-highlights.md
@@ -0,0 +1,110 @@
+Scroll-state container queries allow you to style elements based on their current scroll state, such as whether an element is "stuck" (via sticky positioning) or "snapped" (via scroll snapping). This enables carousel or gallery experiences where the active item can be visually distinguished without relying on JavaScript intersection observers or scroll event listeners.
+
+### Core implementation
+
+To highlight snapped items, you must establish a scroll-snap container, define the snap targets as scroll-state containers, and then query that state to style descendants.
+
+#### 1. Establish the scroll snap container
+The parent container must have `scroll-snap-type` enabled.
+
+```css
+.carousel {
+ display: flex;
+ overflow-x: auto;
+ /* MANDATORY: Enable scroll snapping on the container */
+ scroll-snap-type: x mandatory;
+}
+```
+
+#### 2. Define snap targets as scroll-state containers
+Each item in the carousel that should be tracked for snapping must be declared as a `scroll-state` container.
+
+```css
+.carousel-item {
+ /* Define where the item snaps within the container */
+ scroll-snap-align: center;
+
+ /* MANDATORY: Establish this element as a scroll-state query container */
+ container-type: scroll-state;
+}
+```
+
+#### 3. Query the `snapped` state
+
+Because container queries style **descendants**, you must apply the highlight styles to an element *inside* the snap target. Because the scroll container is set to overflow on the x axis, use the `scroll-state(snapped: x)` query.
+
+**MANDATORY**: Wrap the styles in ` @media (prefers-reduced-motion: no-preference)` to only show the effect to users who have not requested reduced motion. Depending on your use case, you may retain portions of the effect, but in this case, the cards flash from white to blue in a way that may cause problems for some users, so we disable it completely.
+
+```css
+/* Specify transition outside of queries so that it is applied regardless of state. */
+.card {
+ transition:
+ scale 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
+ background-color 0.4s,
+ color 0.4s,
+ box-shadow 0.4s;
+}
+/*
+Only show the effect for users not requesting reduced motion. Disable completely, including the color change, as it causes a flash that may be problematic.
+*/
+@media (prefers-reduced-motion: no-preference) {
+ /* Style the content when its parent .carousel-item is snapped on the x axis */
+ @container scroll-state(snapped: x) {
+ .card {
+ background: #007bff;
+ color: white;
+ scale: 1.15;
+ box-shadow: 0 10px 25px rgba(0, 123, 255, 0.3);
+ }
+ }
+}
+```
+
+The `snapped` descriptor can query specific axes: `x`, `y`, `inline`, `block`, or `both`.
+
+
+### Accessibility
+
+**AVOID**: using `scroll-state` with interactive elements.
+
+Visual highlights for snapped items can improve the UX, but the snapped item is not exposed to the accessibility tree. The visual theme applied to a snapped item should not convey that the element is active or focused, and a keyboard focus ring should be highly visible and distinct from the `snapped` highlight. If the snapped item is interactive, you must use other standard accessibility practices to make it accessible.
+
+Snapping occurs due to scrolling, which does not move keyboard focus. However, keyboard focus may cause the scroll container to move, causing a change in the snapped item, which may or may not be the focused item. This will likely be a source of confusion for users and is discouraged.
+
+### Fallback strategies
+Container scroll-state queries has limited availability.
+
+For browsers that do not support scroll-state queries, you should provide a functional base experience where all items are legible, even without the "active" highlight.
+
+#### Feature detection
+You can use `@supports` to provide enhancements only to supported browsers:
+
+```css
+@supports (container-type: scroll-state) {
+ /* Enhancement styles here */
+}
+```
+
+#### JavaScript fallback
+
+If the highlight is critical for the user experience, use `IntersectionObserver` to determine the snapped item. Adjust the observed area to a thin slice in the center of the carousel by providing a `rootMargin` with a negative inline value. For example, to consider an element to be intersecting if it is in the center 2% of the carousel, set the `rootMargin` to `"0px -49%"`.
+
+```javascript
+// Optional: detect support and apply a JS-based fallback
+if (!CSS.supports('container-type', 'scroll-state')) {
+ const observer = new IntersectionObserver((entries) => {
+ entries.forEach(entry => {
+ // Toggle a class based on intersection
+ entry.target.classList.toggle('is-snapped', entry.isIntersecting);
+ });
+ }, {
+ root: document.querySelector(".carousel"),
+ // Carousel item intersects if any part of the carousel item is in the middle 2% of the carousel.
+ rootMargin: "0px -49%"
+ });
+
+ document.querySelectorAll('.carousel-item').forEach(item => {
+ observer.observe(item);
+ });
+}
+```