Skip to content

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

Release v0.0.70

github-actions[bot]ebb2b780cb41
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index dffb382..e9d6a36 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.69"
+ "version": "0.0.70"
}
]
}
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index b9c4ff5..589e34c 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.69",
+ "version": "0.0.70",
"author": {
"name": "Google Chrome"
}
diff --git a/README.md b/README.md
index 134ce9d..9c34e7e 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.69`
+#### Skill Coverage in `v0.0.70`
<details>
<summary><strong>78 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`, `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 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>
diff --git a/gemini-extension.json b/gemini-extension.json
index 6d24cde..3df44c8 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.69",
+ "version": "0.0.70",
"author": {
"name": "Google Chrome"
}
diff --git a/package.json b/package.json
index 836078d..f4ef81e 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.69",
+ "version": "0.0.70",
"publisher": "GoogleChrome",
"engines": {
"vscode": "^1.90.0",
diff --git a/skills/modern-web/guides/forms/animated-select-picker.md b/skills/modern-web/guides/forms/animated-select-picker.md
index 425487e..88de7b3 100644
--- a/skills/modern-web/guides/forms/animated-select-picker.md
+++ b/skills/modern-web/guides/forms/animated-select-picker.md
@@ -86,7 +86,7 @@ The following example demonstrates a custom select styled with standard page ani
transform: rotate(180deg);
}
-/*
+/*
* The Picker Container
* Uses top-layer animations with `allow-discrete` visibility hooks
*/
@@ -137,13 +137,26 @@ The following example demonstrates a custom select styled with standard page ani
- **DO** use `@starting-style` when you need animations to trigger exactly when an element transitions from `display: none` to visible.
- **DO NOT** use ad-hoc scroll locking. Top-layer elements managed by ‘base-select’ should allow natural backdrop dismiss behaviors.
- **DO** verify reduced motion preferences. Always wrap animation constraints in a `prefers-reduced-motion` media query to ensure accessible environments for those affected by motion sickness.
+- **DO** test layout behavior. Setting `appearance: base-select` removes the default browser behavior of sizing the select based on its longest option width. You may need to set a fixed width or use flex/grid constraints to prevent layout shifts.
- **DO** ensure your `<select>` has a `name` attribute and an associated `<label>`. This ensures that even with a custom UI, the component remains accessible to screen readers and works correctly with standard form submissions.
## Fallback strategies
+### Fallbacks & browser support for Customizable <select>
+
Customizable <select> has limited availability.
For browsers that do not yet support `appearance: base-select`, the `<select>` element degrades gracefully to a standard operating system dropdown.
- **Non-Text Content Ignored**: Older browsers strip HTML tags (like `<svg>` or `<div>`) inside `<option>` tags and render only the text nodes. Ensure the text content of the `<option>` is readable and meaningful on its own.
- **HTML Structure Handling**: Standard parsers may ignore the `<button>` and `<selectedcontent>` tags inside `<select>` or treat them as invalid. No heavy JavaScript polyfills are strictly required for progressive enhancement if you view standard text as a readable fallback.
+
+
+```javascript
+document.addEventListener("DOMContentLoaded", () => {
+ // Check if browser supports base-select value
+ if (!CSS.supports("appearance", "base-select")) {
+ // Custom select overrides are not supported natively.
+ }
+});
+```
diff --git a/skills/modern-web/guides/forms/branded-select-styling.md b/skills/modern-web/guides/forms/branded-select-styling.md
index 7ccdbf3..f4aaa2d 100644
--- a/skills/modern-web/guides/forms/branded-select-styling.md
+++ b/skills/modern-web/guides/forms/branded-select-styling.md
@@ -92,6 +92,8 @@ The following example demonstrates a custom select styled with a monospace font
## Fallback strategies
+### Fallbacks & browser support for Customizable <select>
+
Customizable <select> has limited availability.
For browsers that do not yet support `appearance: base-select`, the `<select>` element degrades gracefully to a standard operating system dropdown.
@@ -99,11 +101,12 @@ For browsers that do not yet support `appearance: base-select`, the `<select>` e
- **Non-Text Content Ignored**: Older browsers strip HTML tags (like `<svg>` or `<div>`) inside `<option>` tags and render only the text nodes. Ensure the text content of the `<option>` is readable and meaningful on its own.
- **HTML Structure Handling**: Standard parsers may ignore the `<button>` and `<selectedcontent>` tags inside `<select>` or treat them as invalid. No heavy JavaScript polyfills are strictly required for progressive enhancement if you view standard text as a readable fallback.
+
```javascript
document.addEventListener("DOMContentLoaded", () => {
// Check if browser supports base-select value
if (!CSS.supports("appearance", "base-select")) {
- console.log("Custom select overrides are not supported natively.");
+ // Custom select overrides are not supported natively.
}
});
-```
\ No newline at end of file
+```
diff --git a/skills/modern-web/guides/forms/custom-select-picker-layouts.md b/skills/modern-web/guides/forms/custom-select-picker-layouts.md
index 1643c2a..6f4e641 100644
--- a/skills/modern-web/guides/forms/custom-select-picker-layouts.md
+++ b/skills/modern-web/guides/forms/custom-select-picker-layouts.md
@@ -79,17 +79,21 @@ To implement a custom select picker layout:
## Fallback Strategy
-For browsers that do not yet support `appearance: base-select`, the select will degrade gracefully to a standard `<select>` element. The grid styles will be ignored, but the select will remain functional.
+### Fallbacks & browser support for Customizable <select>
+
+Customizable <select> has limited availability.
+
+For browsers that do not yet support `appearance: base-select`, the `<select>` element degrades gracefully to a standard operating system dropdown.
+
+- **Non-Text Content Ignored**: Older browsers strip HTML tags (like `<svg>` or `<div>`) inside `<option>` tags and render only the text nodes. Ensure the text content of the `<option>` is readable and meaningful on its own.
+- **HTML Structure Handling**: Standard parsers may ignore the `<button>` and `<selectedcontent>` tags inside `<select>` or treat them as invalid. No heavy JavaScript polyfills are strictly required for progressive enhancement if you view standard text as a readable fallback.
-If the grid layout is critical and must be preserved, use a feature detection check and a JavaScript fallback (or use a framework component).
```javascript
document.addEventListener("DOMContentLoaded", () => {
+ // Check if browser supports base-select value
if (!CSS.supports("appearance", "base-select")) {
- console.log("Custom select layout not supported. Falling back to native UI.");
+ // Custom select overrides are not supported natively.
}
});
-```
-
-- **Non-Text Content Ignored**: Older browsers strip HTML tags (like `<svg>` or `<div>`) inside `<option>` tags and render only the text nodes. Ensure the text content of the `<option>` is readable and meaningful on its own.
-- **HTML Structure Handling**: Standard parsers may ignore the `<button>` and `<selectedcontent>` tags inside `<select>` or treat them as invalid. No heavy JavaScript polyfills are strictly required for progressive enhancement if you view standard text as a readable fallback.
\ No newline at end of file
+```
\ No newline at end of file
diff --git a/skills/modern-web/guides/forms/required-field-feedback.md b/skills/modern-web/guides/forms/required-field-feedback.md
index 276c76d..707a1e4 100644
--- a/skills/modern-web/guides/forms/required-field-feedback.md
+++ b/skills/modern-web/guides/forms/required-field-feedback.md
@@ -65,9 +65,12 @@ input:required:user-valid {
## Fallbacking & Browser Support
-The `:user-invalid` pseudo-class is widely supported (Baseline 2023), but if you need to support older browsers, you must ensure consistency of the implementation.
+### Fallbacks & browser support for :user-valid and :user-invalid
+
+Baseline status for :user-valid and :user-invalid: Newly available. It's been Baseline since 2023-11-02.
### CSS for Fallback
+
```css
input:user-invalid,
input.user-invalid-fallback {
@@ -83,7 +86,7 @@ input.user-invalid-fallback + .error-msg {
### JavaScript Fallback
-DO: Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
+Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
```javascript
const UserInvalidFallback = (() => {
diff --git a/skills/modern-web/guides/forms/rich-media-picker.md b/skills/modern-web/guides/forms/rich-media-picker.md
index 325f44d..abb2b82 100644
--- a/skills/modern-web/guides/forms/rich-media-picker.md
+++ b/skills/modern-web/guides/forms/rich-media-picker.md
@@ -19,7 +19,7 @@ To implement a rich media picker using the Customizable Select API:
<button>
<selectedcontent></selectedcontent> <!-- Mirrors the selected option's content automatically so you do not need JS to update the button -->
</button>
-
+
<option value="frontend">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<rect x="2" y="3" width="20" height="14" rx="2" ry="2"></rect>
@@ -29,7 +29,7 @@ To implement a rich media picker using the Customizable Select API:
<span class="option-desc">React, Vue, CSS</span>
</div>
</option>
-
+
<option value="backend">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<rect x="2" y="12" width="20" height="14" rx="2" ry="2"></rect>
@@ -95,13 +95,26 @@ select.custom-select option::before {
- **DO NOT** use ad-hoc elements if you notice performance lags; the browser handles native keyboard focus natively.
- **DO** account for top-layer rendering. The picker renders in the top-layer, meaning it overrides relative `z-index` of page content.
- **DO** hide secondary details (like descriptions) in the button state if they take too much space, by styling `.custom-select selectedcontent .option-desc { display: none; }`.
+- **DO** test layout behavior. Setting `appearance: base-select` removes the default browser behavior of sizing the select based on its longest option width. You may need to set a fixed width or use flex/grid constraints to prevent layout shifts.
- **DO** ensure your `<select>` has a `name` attribute and an associated `<label>`. This ensures that even with a custom UI, the component remains accessible to screen readers and works correctly with standard form submissions.
## Fallback Strategies
+### Fallbacks & browser support for Customizable <select>
+
Customizable <select> has limited availability.
For browsers that do not yet support `appearance: base-select`, the `<select>` element degrades gracefully to a standard operating system dropdown.
- **Non-Text Content Ignored**: Older browsers strip HTML tags (like `<svg>` or `<div>`) inside `<option>` tags and render only the text nodes. Ensure the text content of the `<option>` is readable and meaningful on its own.
- **HTML Structure Handling**: Standard parsers may ignore the `<button>` and `<selectedcontent>` tags inside `<select>` or treat them as invalid. No heavy JavaScript polyfills are strictly required for progressive enhancement if you view standard text as a readable fallback.
+
+
+```javascript
+document.addEventListener("DOMContentLoaded", () => {
+ // Check if browser supports base-select value
+ if (!CSS.supports("appearance", "base-select")) {
+ // Custom select overrides are not supported natively.
+ }
+});
+```
diff --git a/skills/modern-web/guides/forms/select-menu-interaction.md b/skills/modern-web/guides/forms/select-menu-interaction.md
index 1ab9ba3..26cc038 100644
--- a/skills/modern-web/guides/forms/select-menu-interaction.md
+++ b/skills/modern-web/guides/forms/select-menu-interaction.md
@@ -69,23 +69,28 @@ select:user-valid {
The `:user-invalid` pseudo-class is widely supported (Baseline 2023), but if you need to support older browsers, you must ensure consistency of the implementation.
+### Fallbacks & browser support for :user-valid and :user-invalid
+
+Baseline status for :user-valid and :user-invalid: Newly available. It's been Baseline since 2023-11-02.
+
### CSS for Fallback
+
```css
-select:user-invalid,
-select.user-invalid-fallback {
+input:user-invalid,
+input.user-invalid-fallback {
border-color: #d93025;
background-color: #fce8e6;
}
-select:user-invalid + .error-msg,
-select.user-invalid-fallback + .error-msg {
+input:user-invalid + .error-msg,
+input.user-invalid-fallback + .error-msg {
display: block;
}
```
### JavaScript Fallback
-DO: Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
+Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
```javascript
const UserInvalidFallback = (() => {
@@ -155,7 +160,6 @@ const form = document.querySelector('#demo-form');
UserInvalidFallback.init(form);
```
-
## Other Considerations
1. **Mobile behavior**: On mobile devices, "blur" might happen differently depending on the OS picker. Testing on actual devices is recommended.
diff --git a/skills/modern-web/guides/forms/validate-input-after-interaction.md b/skills/modern-web/guides/forms/validate-input-after-interaction.md
index 424cfa8..dfa3964 100644
--- a/skills/modern-web/guides/forms/validate-input-after-interaction.md
+++ b/skills/modern-web/guides/forms/validate-input-after-interaction.md
@@ -133,45 +133,37 @@ input:user-valid + .rules-list {
## Fallbacking & Browser Support
-The `:user-invalid` pseudo-class is widely supported (Baseline 2023), but if you need to support older browsers, you must ensure consistency of the implementation.
+### Fallbacks & browser support for :user-valid and :user-invalid
+
+Baseline status for :user-valid and :user-invalid: Newly available. It's been Baseline since 2023-11-02.
### CSS for Fallback
-DO: Ensure your fallback class shares the native styles. Group your selectors to ensure consistent styling.
```css
-/* DO: Ensure native and fallback class share the same styles */
input:user-invalid,
input.user-invalid-fallback {
border-color: #d93025;
background-color: #fce8e6;
}
-/* DO: Ensure the fallback triggers error messages equally */
input:user-invalid + .error-msg,
input.user-invalid-fallback + .error-msg {
display: block;
}
-
-/* DO: Ensure the fallback highlights rule lists equally */
-input:user-invalid + .rules-list,
-input.user-invalid-fallback + .rules-list {
- color: #d93025;
-}
```
### JavaScript Fallback
-DO: Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
+Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
```javascript
-/* DO: Keep state in a WeakMap for automatic cleanup */
const UserInvalidFallback = (() => {
const dirtyState = new WeakMap();
const updateState = (input) => {
const isValid = input.checkValidity();
- // DO: Update both visual and ARIA state
+ // Update both visual and ARIA state
input.classList.toggle('user-invalid-fallback', !isValid);
input.classList.toggle('user-valid-fallback', isValid);
@@ -189,7 +181,6 @@ const UserInvalidFallback = (() => {
const controls = input.elements || [];
for (const control of controls) {
dirtyState.delete(control);
- /* DO: Clean up dirty states whenever the form is reset */
control.classList.remove('user-invalid-fallback');
control.classList.remove('user-valid-fallback');
control.removeAttribute('aria-invalid');
@@ -217,19 +208,18 @@ const UserInvalidFallback = (() => {
};
const init = (root = document) => {
- /* DO: Short-circuit initialization if CSS natively supported */
if (CSS.supports('selector(:user-invalid)')) return;
- root.addEventListener('blur', handleEvent, true); // DO: Use Capture phase for blur
+ root.addEventListener('blur', handleEvent, true); // Capture phase
root.addEventListener('input', handleEvent);
root.addEventListener('change', handleEvent);
- root.addEventListener('reset', handleEvent, true); // DO: Capture resets
+ root.addEventListener('reset', handleEvent, true); // Capture resets
};
return { init };
})();
-// DO: Initialize for a specific form container
+// Initialize for a specific form
const form = document.querySelector('#demo-form');
UserInvalidFallback.init(form);
```
@@ -242,7 +232,7 @@ UserInvalidFallback.init(form);
2. **Pattern Attribute Limits**: MANDATORY: The `pattern` attribute performs a full match (implied `^...$`). Ensure your password regex accounts for the entire string.
3. **Validation Strictness**: DO note that the browser's default `type="email"` validation is quite permissive (e.g., `user@localserver` might pass). If you need stricter validation, you may need to use a more robust validation library or a custom validation function alongside `type="email"`.
4. **Focus Management**: MANDATORY: If a user submits the form with an invalid field, the browser will automatically focus the first invalid field. Your `:user-invalid` styles will apply immediately because a submission attempt counts as an interaction.
-5. **Consistent ARIA Experience**: Native `:user-invalid` does not automatically sync with ARIA attributes. Add the following JavaScript to keep `aria-invalid` in sync with the visual state:
+5. **Consistent ARIA Experience**: Native `:user-invalid` does not automatically sync with ARIA attributes. Add the following JavaScript to keep `aria-invalid` in sync with the visual state:
```javascript
// Sync aria-invalid with the CSS :user-invalid state
diff --git a/skills/modern-web/guides/user-experience/adapt-scrollbar-to-contrast-preferences.md b/skills/modern-web/guides/user-experience/adapt-scrollbar-to-contrast-preferences.md
index faf0b0a..4954ade 100644
--- a/skills/modern-web/guides/user-experience/adapt-scrollbar-to-contrast-preferences.md
+++ b/skills/modern-web/guides/user-experience/adapt-scrollbar-to-contrast-preferences.md
@@ -2,7 +2,7 @@
Users who enable high-contrast modes in their operating system or browser expect UI elements (like scrollbars) to be extremely legible, often relying on stark foreground-background separation rather than subtle grays or theme colors.
-This guide provides optional instructions on how to use the `@media (prefers-contrast: more)` CSS media feature to enforce high-contrast scrollbar styling.
+This guide provides optional instructions on how to use the `@media (prefers-contrast: more)` CSS media feature to enforce high-contrast scrollbar styling.
## Enhance Legibility
@@ -15,7 +15,7 @@ OPTIONAL: Use a `@media (prefers-contrast: more)` block to define dark, distinct
.scroller {
--scrollbar-thumb: #bbb;
--scrollbar-track: #f1f1f1;
-
+
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
scrollbar-width: thin;
scrollbar-gutter: stable;
@@ -31,31 +31,43 @@ OPTIONAL: Use a `@media (prefers-contrast: more)` block to define dark, distinct
}
```
-IMPORTANT: Do NOT animate or transition `scrollbar-color`. A [WebKit bug](https://bugs.webkit.org/show_bug.cgi?id=311752) causes the scrollbar to flicker every time `scrollbar-color` changes.
+### Issues to be aware of when using scrollbar-color
+
+- Do NOT animate or transition `scrollbar-color`. A [WebKit bug](https://bugs.webkit.org/show_bug.cgi?id=311752) causes the scrollbar to flicker every time `scrollbar-color` changes.
+- On macOS, `scrollbar-color` (standard) and `::-webkit-scrollbar` (legacy) properties are ignored by default because macOS uses native "overlay" scrollbars. You MUST pair custom colors with `scrollbar-width` (e.g., `thin` or `auto`) to force macOS to render them.
+- Even with `scrollbar-width` applied, macOS overlay scrollbars render the track (gutter) as transparent by default. If the design requires a visible track background color on MacOS, you MUST apply `scrollbar-gutter: stable;` to the scrollable container, but note that it only appears after the user hovers over the scrollbar.
+- Even with `scrollbar-gutter: stable` the track may be transparent on MacOS. The thumb should not depend on the track color to be visible.
## Fallbacks & Browser Support
+### Fallbacks & browser support for scrollbar-color
+
Baseline status for scrollbar-color: Newly available. It's been Baseline since 2025-12-12.
-If you are using legacy WebKit pseudo-elements to ensure custom colored scrollbars on older versions of Safari/Chrome, the variable assignments from the media query above will automatically cascade to the fallback.
+This feature is progressive enhancement and does not always require fallbacks.
+
+If the styling is important and the user's Baseline target is "Baseline Widely Available" or earlier, you SHOULD include the non-standard `::-webkit-scrollbar` pseudo-elements as fallbacks.
-OPTIONAL: If the user's Baseline target is "Baseline Widely Available" or earlier, you SHOULD ensure you provide the legacy fallback code block securely isolated behind `@supports not (scrollbar-color: auto)`.
+Wrap legacy fallbacks in an `@supports not (scrollbar-color: auto)` block to prevent conflicts between standard properties and legacy WebKit selectors in browsers that support both natively.
+
+If you are using custom properties to define colors, these will cascade to the legacy WebKit selectors automatically. You do NOT need to duplicate them.
```css
/* Legacy fallback for WebKit/Blink browsers */
@supports not (scrollbar-color: auto) {
.scroller::-webkit-scrollbar {
+ /* Must define base size in WebKit for custom colors to be visual */
width: 12px;
height: 12px;
}
+
.scroller::-webkit-scrollbar-thumb {
- /* Will inherit the high-contrast #000000 */
background: var(--scrollbar-thumb);
- border: 3px solid var(--scrollbar-track);
}
+
.scroller::-webkit-scrollbar-track {
- /* Will inherit the high-contrast #ffffff */
background: var(--scrollbar-track);
}
}
```
+
diff --git a/skills/modern-web/guides/user-experience/adapt-scrollbar-to-light-dark-preferences.md b/skills/modern-web/guides/user-experience/adapt-scrollbar-to-light-dark-preferences.md
index c2eb8e4..4232a43 100644
--- a/skills/modern-web/guides/user-experience/adapt-scrollbar-to-light-dark-preferences.md
+++ b/skills/modern-web/guides/user-experience/adapt-scrollbar-to-light-dark-preferences.md
@@ -1,4 +1,4 @@
-# Adapt scrollbar to light/dark preferences
+# Adapt scrollbar colors to light/dark preferences
Users expect UI components, including scrollbars, to match the color scheme (light or dark mode) chosen in their operating system settings. The most essential step to achieving this is utilizing the `color-scheme` property. If you choose to apply explicit custom colors, you can use the `@media (prefers-color-scheme: dark)` CSS media feature to modify those colors dynamically.
@@ -19,19 +19,43 @@ MANDATORY: Define `color-scheme` on the `:root` pseudo-class.
If you are using `scrollbar-color` or the non-standard `::-webkit-scrollbar` pseudo-elements to explicitly define custom scrollbar colors, you MUST ensure these colors are legible and appropriate in both light and dark modes.
-MANDATORY: Use CSS custom properties (variables) to define your colors and update them within a `prefers-color-scheme` media query to avoid repetition.
+When using `scrollbar-color`, use CSS variables to keep thumb and track colors separate, for readability and maintainability (especially when using fallbacks).
+
+```css
+.scroller {
+ --scrollbar-thumb: var(--color-neutral-70);
+ --scrollbar-track: var(--color-neutral-90);
+
+ scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
+}
+```
+
+You can use either the `prefers-color-scheme` media query or the `light-dark()` function to define how these colors behave in light and dark mode. The latter will adapt to color-scheme overrides as well (local or global), but has narrower browser support.
+
+Using `light-dark()`:
+
+```css
+/* DO: Define light mode colors as variables */
+.scroller {
+ --scrollbar-thumb: light-dark(#bbb, #555555);
+ --scrollbar-track: light-dark(#f1f1f1, #222222);
+
+ scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
+ scrollbar-width: thin;
+ scrollbar-gutter: stable;
+}
+```
+
+Using `prefers-color-scheme`:
```css
/* DO: Define light mode colors as variables */
.scroller {
--scrollbar-thumb: #bbb;
--scrollbar-track: #f1f1f1;
-
- /* DO: Apply standard property natively */
+
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
- /* DO: Must define width to force macOS to apply the custom colors */
scrollbar-width: thin;
- /* DO: Force the track background to be visible on macOS */
scrollbar-gutter: stable;
}
@@ -44,34 +68,44 @@ MANDATORY: Use CSS custom properties (variables) to define your colors and updat
}
```
-IMPORTANT: Do NOT animate or transition `scrollbar-color`. A [WebKit bug](https://bugs.webkit.org/show_bug.cgi?id=311752) causes the scrollbar to flicker every time `scrollbar-color` changes.
+### Issues to be aware of when using scrollbar-color
+
+- Do NOT animate or transition `scrollbar-color`. A [WebKit bug](https://bugs.webkit.org/show_bug.cgi?id=311752) causes the scrollbar to flicker every time `scrollbar-color` changes.
+- On macOS, `scrollbar-color` (standard) and `::-webkit-scrollbar` (legacy) properties are ignored by default because macOS uses native "overlay" scrollbars. You MUST pair custom colors with `scrollbar-width` (e.g., `thin` or `auto`) to force macOS to render them.
+- Even with `scrollbar-width` applied, macOS overlay scrollbars render the track (gutter) as transparent by default. If the design requires a visible track background color on MacOS, you MUST apply `scrollbar-gutter: stable;` to the scrollable container, but note that it only appears after the user hovers over the scrollbar.
+- Even with `scrollbar-gutter: stable` the track may be transparent on MacOS. The thumb should not depend on the track color to be visible.
## Fallbacks & Browser Support
+### Fallbacks & browser support for scrollbar-color
+
Baseline status for scrollbar-color: Newly available. It's been Baseline since 2025-12-12.
-MANDATORY: If the user's Baseline target is "Baseline Widely Available" or earlier, you SHOULD include the non-standard `::-webkit-scrollbar` pseudo-elements as fallbacks.
-MANDATORY: To prevent conflicts between standard properties and legacy WebKit selectors in browsers that support both natively (like modern Chrome), you MUST wrap legacy WebKit fallbacks in an `@supports not (scrollbar-color: auto)` block.
-MANDATORY: On macOS, `scrollbar-color` (standard) and `::-webkit-scrollbar` (legacy) properties are ignored by default because macOS uses native "overlay" scrollbars. You MUST pair custom colors with `scrollbar-width` (e.g., `thin` or `auto`) to force macOS to render them.
-MANDATORY: Even with `scrollbar-width` applied, macOS overlay scrollbars render the track (gutter) as transparent by default. If your design requires a visible track background color on MacOS, you MUST apply `scrollbar-gutter: stable;` to the scrollable container, but note that it only appears after the user hovers over the scrollbar.
+This feature is progressive enhancement and does not always require fallbacks.
+If the styling is important and the user's Baseline target is "Baseline Widely Available" or earlier, you SHOULD include the non-standard `::-webkit-scrollbar` pseudo-elements as fallbacks.
+Wrap legacy fallbacks in an `@supports not (scrollbar-color: auto)` block to prevent conflicts between standard properties and legacy WebKit selectors in browsers that support both natively.
+
+If you are using custom properties to define colors, these will cascade to the legacy WebKit selectors automatically. You do NOT need to duplicate them.
```css
/* Legacy fallback for WebKit/Blink browsers */
@supports not (scrollbar-color: auto) {
.scroller::-webkit-scrollbar {
- /* DO: Must define base size in WebKit for custom colors to be visual */
+ /* Must define base size in WebKit for custom colors to be visual */
width: 12px;
height: 12px;
}
+
.scroller::-webkit-scrollbar-thumb {
- /* DO: Apply the thumb variable */
background: var(--scrollbar-thumb);
}
+
.scroller::-webkit-scrollbar-track {
- /* DO: Apply the track variable */
background: var(--scrollbar-track);
}
}
```
+
+
diff --git a/skills/modern-web/guides/user-experience/calculate-event-differentials.md b/skills/modern-web/guides/user-experience/calculate-event-differentials.md
index 9428abb..7530e94 100644
--- a/skills/modern-web/guides/user-experience/calculate-event-differentials.md
+++ b/skills/modern-web/guides/user-experience/calculate-event-differentials.md
@@ -60,10 +60,14 @@ if (isExpired) {
## Fallback Strategy
+### Fallbacks & browser support for Temporal
+
Temporal has limited availability.
For browsers that do not yet support the native `Temporal` API, use feature detection and a polyfill. The standard reference polyfill is `@js-temporal/polyfill`.
+Note that the polyfill does not automatically assign the `Temporal` object to the global scope to avoid conflicts. You must manually assign it if your code relies on the global `Temporal` object.
+
```javascript
// Check if Temporal is supported natively
(async () => {
@@ -76,9 +80,4 @@ For browsers that do not yet support the native `Temporal` API, use feature dete
initializeApp();
}
})();
-
-function initializeApp() {
- const now = Temporal.Now.zonedDateTimeISO();
- console.log(now.toString());
-}
```
\ No newline at end of file
diff --git a/skills/modern-web/guides/user-experience/capture-location-agnostic-data.md b/skills/modern-web/guides/user-experience/capture-location-agnostic-data.md
index ef1863f..b4bd78b 100644
--- a/skills/modern-web/guides/user-experience/capture-location-agnostic-data.md
+++ b/skills/modern-web/guides/user-experience/capture-location-agnostic-data.md
@@ -38,9 +38,11 @@ console.log(new Intl.DateTimeFormat('en-GB', { timeZone: 'America/New_York' }).f
## Fallback Strategy
+### Fallbacks & browser support for Temporal
+
Temporal has limited availability.
-For browsers that do not yet support the native `Temporal` API, you should use feature detection and load a polyfill. The standard reference polyfill is `@js-temporal/polyfill`.
+For browsers that do not yet support the native `Temporal` API, use feature detection and a polyfill. The standard reference polyfill is `@js-temporal/polyfill`.
Note that the polyfill does not automatically assign the `Temporal` object to the global scope to avoid conflicts. You must manually assign it if your code relies on the global `Temporal` object.
@@ -56,9 +58,4 @@ Note that the polyfill does not automatically assign the `Temporal` object to th
initializeApp();
}
})();
-
-function initializeApp() {
- const plainDate = Temporal.PlainDate.from("1990-01-01");
- console.log("App initialized with PlainDate:", plainDate.toString());
-}
```
\ No newline at end of file
diff --git a/skills/modern-web/guides/user-experience/customize-scrollbar-color-and-thickness.md b/skills/modern-web/guides/user-experience/customize-scrollbar-color-and-thickness.md
index 44fd7e4..e5f23c7 100644
--- a/skills/modern-web/guides/user-experience/customize-scrollbar-color-and-thickness.md
+++ b/skills/modern-web/guides/user-experience/customize-scrollbar-color-and-thickness.md
@@ -9,47 +9,34 @@ You can customize the appearance of scrollbars using the standard CSS properties
MANDATORY: Use `scrollbar-color` and `scrollbar-width` on the scrollable container.
+When using `scrollbar-color`, use CSS variables to keep thumb and track colors separate, for readability and maintainability (especially when using fallbacks).
+
```css
.scroller {
- /* Specify thumb color first, then track color for modern browsers */
- scrollbar-color: hotpink blue;
- /* Apply standard width property natively */
- scrollbar-width: thin;
- /* Force the track background to be visible on macOS */
- scrollbar-gutter: stable;
-}
+ --scrollbar-thumb: var(--color-neutral-70);
+ --scrollbar-track: var(--color-neutral-90);
-.scroller-hidden {
- /* Use none to hide scrollbar but keep scrollability */
- scrollbar-width: none;
+ scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
```
-IMPORTANT: On macOS, the `scrollbar-color` (standard) and `::-webkit-scrollbar` (legacy) properties are ignored by default because macOS uses native "overlay" scrollbars. Therefore, you MUST apply `scrollbar-width` (e.g., `thin` or `auto`) to force macOS to render custom colors.
+## Fallback strategies
-IMPORTANT: Do NOT animate or transition `scrollbar-color`. A [WebKit bug](https://bugs.webkit.org/show_bug.cgi?id=311752) causes the scrollbar to flicker every time `scrollbar-color` changes.
+Baseline status for scrollbar-width: Newly available. It's been Baseline since 2024-12-11.
-## Fallback strategies
+### Fallbacks & browser support for scrollbar-color
Baseline status for scrollbar-color: Newly available. It's been Baseline since 2025-12-12.
-Baseline status for scrollbar-width: Newly available. It's been Baseline since 2024-12-11.
+This feature is progressive enhancement and does not always require fallbacks.
-If the user's Baseline target (or Widely available, if unavailable) does not support any of the required features, the following fallback strategies MUST be used.
+If the styling is important and the user's Baseline target is "Baseline Widely Available" or earlier, you SHOULD include the non-standard `::-webkit-scrollbar` pseudo-elements as fallbacks.
-Include the non-standard `::-webkit-scrollbar` pseudo-elements as fallbacks.
+Wrap legacy fallbacks in an `@supports not (scrollbar-color: auto)` block to prevent conflicts between standard properties and legacy WebKit selectors in browsers that support both natively.
-To prevent conflicts between standard properties and legacy WebKit selectors in browsers that support both natively (like modern Chrome), you MUST wrap legacy WebKit fallbacks in an `@supports not (scrollbar-color: auto)` block.
+If you are using custom properties to define colors, these will cascade to the legacy WebKit selectors automatically. You do NOT need to duplicate them.
```css
-.scroller {
- /* Apply standard properties natively */
- scrollbar-color: hotpink blue;
- scrollbar-width: thin;
- /* Force the track background to be visible on macOS */
- scrollbar-gutter: stable;
-}
-
/* Legacy fallback for WebKit/Blink browsers */
@supports not (scrollbar-color: auto) {
.scroller::-webkit-scrollbar {
@@ -57,19 +44,14 @@ To prevent conflicts between standard properties and legacy WebKit selectors in
width: 12px;
height: 12px;
}
+
.scroller::-webkit-scrollbar-thumb {
- /* Use background to color the thumb */
- background: hotpink;
- border-radius: 6px;
- }
- .scroller::-webkit-scrollbar-track {
- /* Use background to color the track */
- background: blue;
+ background: var(--scrollbar-thumb);
}
- .scroller-hidden::-webkit-scrollbar {
- display: none;
- width: 0;
+ .scroller::-webkit-scrollbar-track {
+ background: var(--scrollbar-track);
}
}
```
+
diff --git a/skills/modern-web/guides/user-experience/format-human-readable-durations.md b/skills/modern-web/guides/user-experience/format-human-readable-durations.md
index 39b7369..9dc691d 100644
--- a/skills/modern-web/guides/user-experience/format-human-readable-durations.md
+++ b/skills/modern-web/guides/user-experience/format-human-readable-durations.md
@@ -34,11 +34,13 @@ console.log(formatter.format(balanced));
## Fallback strategies
-### Temporal
+### Fallbacks & browser support for Temporal
Temporal has limited availability.
-For environments without native `Temporal` support, you must conditionally load the `@js-temporal/polyfill`.
+For browsers that do not yet support the native `Temporal` API, use feature detection and a polyfill. The standard reference polyfill is `@js-temporal/polyfill`.
+
+Note that the polyfill does not automatically assign the `Temporal` object to the global scope to avoid conflicts. You must manually assign it if your code relies on the global `Temporal` object.
```javascript
// Check if Temporal is supported natively
@@ -52,10 +54,6 @@ For environments without native `Temporal` support, you must conditionally load
initializeApp();
}
})();
-
-function initializeApp() {
- // App logic here
-}
```
### Intl.DurationFormat
diff --git a/skills/modern-web/guides/user-experience/model-partial-time-concepts.md b/skills/modern-web/guides/user-experience/model-partial-time-concepts.md
index 8294c38..a429676 100644
--- a/skills/modern-web/guides/user-experience/model-partial-time-concepts.md
+++ b/skills/modern-web/guides/user-experience/model-partial-time-concepts.md
@@ -71,9 +71,13 @@ console.log(`Snoozed alarm: ${snoozedTime.toString()}`);
## Fallback Strategy
+### Fallbacks & browser support for Temporal
+
Temporal has limited availability.
-For environments without native `Temporal` support, use feature detection and load the `@js-temporal/polyfill`.
+For browsers that do not yet support the native `Temporal` API, use feature detection and a polyfill. The standard reference polyfill is `@js-temporal/polyfill`.
+
+Note that the polyfill does not automatically assign the `Temporal` object to the global scope to avoid conflicts. You must manually assign it if your code relies on the global `Temporal` object.
```javascript
// Check if Temporal is supported natively
@@ -87,10 +91,4 @@ For environments without native `Temporal` support, use feature detection and lo
initializeApp();
}
})();
-
-function initializeApp() {
- // Application logic using Temporal
- const time = Temporal.PlainTime.from("12:00:00");
- console.log(`Initialized at ${time.toString()}`);
-}
-```
\ No newline at end of file
+```
diff --git a/skills/modern-web/guides/user-experience/style-parent-with-has.md b/skills/modern-web/guides/user-experience/style-parent-with-has.md
index 025a2fe..93a20a8 100644
--- a/skills/modern-web/guides/user-experience/style-parent-with-has.md
+++ b/skills/modern-web/guides/user-experience/style-parent-with-has.md
@@ -75,7 +75,7 @@ We use a class `.has-error` on the parent to mimic the `:has()` behavior.
### JavaScript Fallback
-DO: Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
+Use a reusable utility that tracks interaction state using a `WeakMap`. This avoids polluting the DOM with "dirty" classes or data attributes.
```javascript
const UserInvalidFallback = (() => {
@@ -140,6 +140,12 @@ const UserInvalidFallback = (() => {
return { init };
})();
+// Initialize for a specific form
+const form = document.querySelector('#demo-form');
+UserInvalidFallback.init(form);
+```
+
+```js
// 1. Initialize the generic fallback
const form = document.querySelector('#demo-form');
UserInvalidFallback.init(form);