Keep your coding agent up to date with the latest web best practices
Release v0.0.90
github-actions[bot]1bf5689baad2
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 3fd1dcb..909dad0 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.89"+ "version": "0.0.90"}]}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 7497f2b..2488e30 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.89",+ "version": "0.0.90","author": {"name": "Google Chrome"}diff --git a/README.md b/README.mdindex 99c0a63..b689df6 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.89`+#### Skill Coverage in `v0.0.90`<details><summary><strong>82 web features with implementation guidance from Chrome's experts</strong>: `::backdrop`, `:autofill`, `:has()`, `:not()`, `:user-valid and :user-invalid`, `@starting-style`, `<details>`, `<dialog closedby>`, `<dialog>`, `<link rel="expect">`, `<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 <select>`, `Email, telephone, and URL <input> types`, `enterkeyhint`, `Event timing`, `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 <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>@@ -66,6 +66,8 @@ This curated collection of skills, tools, and AI-ready documentation injects Chr- **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.+ - **scroll-position-aware-elements**: Build floating buttons or widgets (back-to-top, scroll-to-bottom, chat launchers, etc.) that appear and disappear based on whether the user has scrolled at all.+ - **scrollability-affordance-hints**: Build scroll-shadow overlays, gradient fades, or directional arrow indicators that appear only when there's actually more content to scroll to in that direction.- **[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.jsonindex 4c4d45e..6aede20 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.89",+ "version": "0.0.90","author": {"name": "Google Chrome"}diff --git a/package.json b/package.jsonindex dd9761d..28ffcb9 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.89",+ "version": "0.0.90","publisher": "GoogleChrome","engines": {"vscode": "^1.90.0",diff --git a/skills/modern-web/guides/user-experience/scroll-position-aware-elements.md b/skills/modern-web/guides/user-experience/scroll-position-aware-elements.mdnew file mode 100644index 0000000..532f16f--- /dev/null+++ b/skills/modern-web/guides/user-experience/scroll-position-aware-elements.md@@ -0,0 +1,126 @@+## Overview++Improve the user experience of floating buttons, like a "Back to Top" link, by showing them only when they are useful. This guide shows how to build these elements using CSS `container-scroll-state-queries`, which allows styling elements based on the scroll position of their container without relying on JavaScript scroll listeners or observers.++## Implementation++### 1. Establish the Scroll Container++The scroll container must be declared as a scroll-state query container.++```css+.scroller {+ overflow-y: auto;+ /* Establish this element as a scroll-state query container */+ container-type: scroll-state;+}+```++### 2. Style the Floating Element++Place the element inside the container and style it. By default, it should be hidden.++```css+.back-to-top {+ position: sticky;+ bottom: 20px;+ visibility: hidden;+ opacity: 0;+ translate: 0 20px;+ transition:+ visibility 0.3s,+ opacity 0.3s ease,+ translate 0.3s ease;+}+```++> **Important:** Sticky or floating elements hover above the scrollable content. Ensure that the main content has sufficient bottom padding or margin so that the last few elements are not permanently covered by the button when the user scrolls completely to the bottom.++### 3. Respond to the Scroll State++Use the `@container` rule with the `scroll-state` function. To check if the user has scrolled down, check if the container is scrollable to the top.++```css+/* When the container can be scrolled toward the top, it means the user has scrolled down */+@container scroll-state(scrollable: top) {+ .back-to-top {+ visibility: visible;+ opacity: 1;+ translate: 0 0;+ }+}+```++## Fallback strategies++Container scroll-state queries has limited availability.++### Basic Fallback+If `container-scroll-state-queries` is not supported, the floating element will remain invisible because of the default `visibility: hidden`. To ensure functionality, you can choose to make the element always visible in unsupported browsers.++```css+/* Fallback for browsers that do not support the feature */+.back-to-top {+ visibility: visible; /* Always visible */+ opacity: 1;+}++/* Override for supported browsers to handle dynamic visibility */+@supports (container-type: scroll-state) {+ .back-to-top {+ visibility: hidden;+ opacity: 0;+ }++ @container scroll-state(scrollable: top) {+ .back-to-top {+ visibility: visible;+ opacity: 1;+ translate: 0 0;+ }+ }+}+```++### Advanced Fallback (Intersection Observer)+If dynamic visibility is required, use an `IntersectionObserver` to toggle a class when a sentinel element at the top of the scroller goes out of view.++```html+<!-- Sentinel element placed at the top of the scroller -->+<div class="scroll-sentinel"></div>+```++```css+/* Marker styling to ensure it does not affect layout */+.scroll-sentinel {+ height: 0;+ width: 0;+ visibility: hidden;+}++.scrolled .back-to-top {+ visibility: visible;+ opacity: 1;+ translate: 0 0;+}+```++```javascript+if (!CSS.supports('container-type', 'scroll-state')) {+ const sentinel = document.querySelector('.scroll-sentinel');+ const scroller = document.querySelector('.scroller');++ const observer = new IntersectionObserver((entries) => {+ entries.forEach(entry => {+ // If the sentinel is NOT intersecting, it means the user has scrolled down+ if (!entry.isIntersecting) {+ scroller.classList.add('scrolled');+ } else {+ scroller.classList.remove('scrolled');+ }+ });+ }, { root: scroller });++ observer.observe(sentinel);+}+```diff --git a/skills/modern-web/guides/user-experience/scrollability-affordance-hints.md b/skills/modern-web/guides/user-experience/scrollability-affordance-hints.mdnew file mode 100644index 0000000..2175216--- /dev/null+++ b/skills/modern-web/guides/user-experience/scrollability-affordance-hints.md@@ -0,0 +1,122 @@+## Overview++Visual hints, like shadows or gradients, help users understand that they can scroll to see more content. This guide shows how to build these hints using CSS `container-scroll-state-queries`, which allows styling elements based on the scrollable state of their container without relying on JavaScript scroll listeners or observers.++## Implementation++### 1. Establish the Scroll Container++The scroll container must be declared as a scroll-state query container.++```css+.scroller {+ overflow-y: auto;+ /* Establish this element as a scroll-state query container */+ container-type: scroll-state;+ position: relative;+}+```++### 2. Style the Indicators++Place the indicator elements (like shadows, gradients, or arrows) inside the container and style them. By default, they should not be visible. When they are shown, they should not be interactive, by setting `pointer-events: none`.++```css+.indicator-top, .indicator-bottom {+ position: sticky;+ left: 0;+ right: 0;+ height: 20px;+ opacity: 0;+ transition: opacity 0.2s;+ pointer-events: none; /* Let clicks pass through */+}++.indicator-top {+ top: 0;+ background: linear-gradient(to bottom, rgba(0,0,0,0.2), transparent); /* Example: Shadow */+}++.indicator-bottom {+ bottom: 0;+ background: linear-gradient(to top, rgba(0,0,0,0.2), transparent); /* Example: Shadow */+}+```++### 3. Query the Scroll State++Use the `@container` rule with the `scroll-state` function. Check if the container is scrollable up or down to show the respective indicator.++```css+/* Show top indicator when the user can scroll up */+@container scroll-state(scrollable: top) {+ .indicator-top {+ opacity: 1;+ }+}++/* Show bottom indicator when the user can scroll down */+@container scroll-state(scrollable: bottom) {+ .indicator-bottom {+ opacity: 1;+ }+}+```++## Fallback strategies++Container scroll-state queries has limited availability.++### Basic Fallback+If the feature is not supported, the indicators will remain invisible. Since these are hints and not critical for functionality, it is acceptable to omit them in unsupported browsers.++### Advanced Fallback (Intersection Observer)+If the hints are required, use an `IntersectionObserver` to toggle classes when sentinel elements at the top and bottom of the scroller move in and out of the scrollport.++```html+<!-- Sentinel elements placed at the ends of the scroller -->+<div class="sentinel-top"></div>+<!-- Content goes here -->+<div class="sentinel-bottom"></div>+```++```css+/* Marker styling to ensure it does not affect layout */+.sentinel-top, .sentinel-bottom {+ height: 0;+ width: 0;+ visibility: hidden;+}++.scroller.scrolled-down .indicator-top {+ opacity: 1;+}++.scroller.can-scroll-down .indicator-bottom {+ opacity: 1;+}+```++```javascript+if (!CSS.supports('container-type', 'scroll-state')) {+ const topSentinel = document.querySelector('.sentinel-top');+ const bottomSentinel = document.querySelector('.sentinel-bottom');+ const scroller = document.querySelector('.scroller');++ const observer = new IntersectionObserver((entries) => {+ entries.forEach(entry => {+ if (entry.target === topSentinel) {+ // If top sentinel is not intersecting, we have scrolled down+ scroller.classList.toggle('scrolled-down', !entry.isIntersecting);+ }+ if (entry.target === bottomSentinel) {+ // If bottom sentinel is intersecting, we reached the bottom+ scroller.classList.toggle('can-scroll-down', !entry.isIntersecting);+ }+ });+ }, { root: scroller });++ observer.observe(topSentinel);+ observer.observe(bottomSentinel);+}+```