@capagents/forgeqe 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_USE.md +435 -78
- package/README.md +21 -6
- package/THIRD_PARTY_NOTICES.md +210 -1
- package/dist/docs-site/CREDITS.md +6 -0
- package/dist/docs-site/architecture-map/index.html +1 -1
- package/dist/docs-site/docs/app-theme.css +100 -8
- package/dist/docs-site/docs/architecture/index.html +210 -214
- package/dist/docs-site/docs/area-api/index.html +350 -0
- package/dist/docs-site/docs/area-automated-tests/index.html +967 -0
- package/dist/docs-site/docs/area-browser/index.html +430 -0
- package/dist/docs-site/docs/area-data/index.html +605 -0
- package/dist/docs-site/docs/area-desktop/index.html +755 -0
- package/dist/docs-site/docs/area-mobile/index.html +631 -0
- package/dist/docs-site/docs/area-operations/index.html +1069 -0
- package/dist/docs-site/docs/area-pull-requests/index.html +208 -0
- package/dist/docs-site/docs/area-quality/index.html +365 -0
- package/dist/docs-site/docs/area-release/index.html +320 -0
- package/dist/docs-site/docs/area-setup/index.html +1192 -0
- package/dist/docs-site/docs/area-systems/index.html +207 -0
- package/dist/docs-site/docs/area-test-cases/index.html +694 -0
- package/dist/docs-site/docs/containers/index.html +97 -104
- package/dist/docs-site/docs/cost-architecture/index.html +108 -112
- package/dist/docs-site/docs/custom-agents-first-run/index.html +19 -23
- package/dist/docs-site/docs/desktop/index.html +172 -162
- package/dist/docs-site/docs/desktop-ci/index.html +26 -33
- package/dist/docs-site/docs/evidence/index.html +253 -257
- package/dist/docs-site/docs/feature-test-prompts/index.html +66 -70
- package/dist/docs-site/docs/get-started/index.html +495 -0
- package/dist/docs-site/docs/graphify/index.html +42 -46
- package/dist/docs-site/docs/guardrails/index.html +17 -21
- package/dist/docs-site/docs/index.html +17 -6729
- package/dist/docs-site/docs/mobile/index.html +155 -162
- package/dist/docs-site/docs/model-routing/index.html +44 -51
- package/dist/docs-site/docs/overview/index.html +176 -0
- package/dist/docs-site/docs/product-graph/index.html +52 -55
- package/dist/docs-site/docs/product-knowledge/index.html +11 -15
- package/dist/docs-site/docs/product-views/index.html +53 -57
- package/dist/docs-site/docs/reference/index.html +379 -0
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/using/index.html +480 -0
- package/dist/docs-site/docs/web-app/index.html +147 -93
- package/dist/docs-site/security/index.html +930 -0
- package/dist/docs-site/security/security-theme.css +161 -0
- package/dist/docs-site/security/security.js +1465 -0
- package/dist/docs-site/vendor/react-18.3.1.production.min.js +31 -0
- package/dist/docs-site/vendor/react-dom-18.3.1.production.min.js +267 -0
- package/dist/docs-site/vendor/reactflow-11.11.4.umd.js +10 -0
- package/dist/forgeqe.js +1902 -1895
- package/dist/web/THIRD_PARTY_NOTICES.md +0 -136
- package/dist/web/assets/Agent-CPhmZdFX.js +8 -0
- package/dist/web/assets/AgentWork-BXdN9xgi.js +2 -0
- package/dist/web/assets/ApiTests-Do3xLjfB.js +10 -0
- package/dist/web/assets/Browse-WVkJT6Bs.js +2 -0
- package/dist/web/assets/Chat-CDc9UcQX.js +3 -0
- package/dist/web/assets/CommandPalette-BAZm62lV.js +1 -0
- package/dist/web/assets/Compare-Br6n9T9L.js +1 -0
- package/dist/web/assets/Cost-BBUyBu3Y.js +1 -0
- package/dist/web/assets/Data-Ch2DPEWp.js +6 -0
- package/dist/web/assets/Desktop-Qzoq-cQv.js +1 -0
- package/dist/web/assets/DesktopReview-CF_jQYAM.js +1 -0
- package/dist/web/assets/Evidence-C72Lj5_Q.js +1 -0
- package/dist/web/assets/Explore-ObkEpUyS.js +2 -0
- package/dist/web/assets/Features-CQzNo_WP.js +1 -0
- package/dist/web/assets/Flags-0-RniPJm.js +2 -0
- package/dist/web/assets/Flaky-BPJvNLCA.js +1 -0
- package/dist/web/assets/Impact-CfccsL_k.js +3 -0
- package/dist/web/assets/Jobs-T6m4zhDy.js +5 -0
- package/dist/web/assets/KindPage-BDUvWe2p.js +6 -0
- package/dist/web/assets/Migration-Dqeh4x5u.js +2 -0
- package/dist/web/assets/PageAgent-DNjzIgeY.js +1 -0
- package/dist/web/assets/Product-nYV_scOV.js +7 -0
- package/dist/web/assets/Production-CGSbEWVa.js +1 -0
- package/dist/web/assets/Quality-BIypojZm.js +1 -0
- package/dist/web/assets/Readiness-BlRjwJRg.js +1 -0
- package/dist/web/assets/Record-v2KLI-_Z.js +1 -0
- package/dist/web/assets/Regression-B-jSt4Jz.js +5 -0
- package/dist/web/assets/RelationGraph-8J98lOVG.js +1 -0
- package/dist/web/assets/Reports-GI4u6SyW.js +2 -0
- package/dist/web/assets/Response-mhBThq2b.js +9 -0
- package/dist/web/assets/Responsive-DXu7Ra7K.js +3 -0
- package/dist/web/assets/RunDiff-D0SHDNp0.js +1 -0
- package/dist/web/assets/Runs-C1Gjdi9M.js +2 -0
- package/dist/web/assets/Settings-BGGeuvyF.js +21 -0
- package/dist/web/assets/Steps-D-YG0eJy.js +2 -0
- package/dist/web/assets/TestCases-DC4w77eQ.js +1 -0
- package/dist/web/assets/TestData-CvKWRVVV.js +2 -0
- package/dist/web/assets/TestDebt-D8YzN29_.js +1 -0
- package/dist/web/assets/TestManagement-C5cDCqrD.js +1 -0
- package/dist/web/assets/Tosca-BGUv3RiJ.js +3 -0
- package/dist/web/assets/WhatsNew-B_Gyuv8O.js +1 -0
- package/dist/web/assets/agents-C0Jg2pN8.js +1 -0
- package/dist/web/assets/coverage-BMP6ELFJ.js +5 -0
- package/dist/web/assets/dataParts-DbeCj9ga.js +3 -0
- package/dist/web/assets/diff-BStuTmsN.js +2 -0
- package/dist/web/assets/families-BBFFrUlo.js +1 -0
- package/dist/web/assets/filters-CnAMr286.js +1 -0
- package/dist/web/assets/fold-D_O_VZui.js +1 -0
- package/dist/web/assets/head-CRo48rPt.js +1 -0
- package/dist/web/assets/highlight-BcFZIf59.js +4 -0
- package/dist/web/assets/index-B3JsM7tv.js +64 -0
- package/dist/web/assets/index-CafApcbZ.css +2 -0
- package/dist/web/assets/input-CtzK50ZF.js +1 -0
- package/dist/web/assets/jsx-runtime-LKYXHABd.js +1 -0
- package/dist/web/assets/line-icons-rdF8DYDJ.js +1 -0
- package/dist/web/assets/logos-D4oVWzqa.js +1 -0
- package/dist/web/assets/palette-DAaGSao7.js +1 -0
- package/dist/web/assets/paletteCommands-Co-RlQ8q.js +1 -0
- package/dist/web/assets/parts-D357Wolo.js +1 -0
- package/dist/web/assets/productParts-B8oHRCJF.js +1 -0
- package/dist/web/assets/qualityParts-BLkmIfDY.js +1 -0
- package/dist/web/assets/recordTest-Cez2sDJO.js +1 -0
- package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/web/assets/route-BloYJWgw.js +1 -0
- package/dist/web/index.html +12 -6
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/BASAL.md +1 -1
- package/docs/DESKTOP.md +20 -1
- package/docs/EVIDENCE.md +1 -1
- package/docs/MOBILE.md +4 -4
- package/docs/PRODUCT_KNOWLEDGE.md +2 -0
- package/docs/WEB_APP.md +114 -51
- package/docs/user-guide.html +404 -81
- package/forgeqe.example.yaml +3 -3
- package/package.json +1 -1
- package/prompts/page-differs.md +1 -1
- package/prompts/requests-rule.md +1 -1
- package/prompts/test-reviewer.md +1 -1
- package/prompts/test-rules.md +3 -4
- package/skills/web-guidance/LICENSE +202 -0
- package/skills/web-guidance/SKILL.md +76 -0
- package/skills/web-guidance/UPSTREAM +67 -0
- package/skills/web-guidance/references/accessibility/accessibility.md +585 -0
- package/skills/web-guidance/references/accessibility/accessible-error-announcement.md +302 -0
- package/skills/web-guidance/references/accessibility/accessible-generated-content.md +41 -0
- package/skills/web-guidance/references/accessibility/respect-os-text-scale.md +127 -0
- package/skills/web-guidance/references/css/responsive-design.md +16 -0
- package/skills/web-guidance/references/forms/autofill-address-form.md +86 -0
- package/skills/web-guidance/references/forms/autofill-payment-form.md +142 -0
- package/skills/web-guidance/references/forms/autofill-sign-in-form.md +145 -0
- package/skills/web-guidance/references/forms/autofill-sign-up-form.md +155 -0
- package/skills/web-guidance/references/forms/forms.md +415 -0
- package/skills/web-guidance/references/forms/ime-safe-enter-submit.md +115 -0
- package/skills/web-guidance/references/forms/required-field-feedback.md +317 -0
- package/skills/web-guidance/references/forms/select-menu-interaction.md +310 -0
- package/skills/web-guidance/references/forms/slider.md +184 -0
- package/skills/web-guidance/references/forms/sms-otp-form.md +208 -0
- package/skills/web-guidance/references/forms/switch.md +60 -0
- package/skills/web-guidance/references/forms/validate-input-after-interaction.md +406 -0
- package/skills/web-guidance/references/performance/break-up-long-tasks.md +64 -0
- package/skills/web-guidance/references/performance/identify-heavy-scripts.md +69 -0
- package/skills/web-guidance/references/performance/identify-inp-causes.md +105 -0
- package/skills/web-guidance/references/performance/interaction-paint-timing.md +200 -0
- package/skills/web-guidance/references/performance/optimize-image-priority.md +73 -0
- package/skills/web-guidance/references/performance/performance.md +384 -0
- package/skills/web-guidance/references/privacy/privacy.md +247 -0
- package/skills/web-guidance/references/security/passkey-authentication.md +218 -0
- package/skills/web-guidance/references/security/passkey-management.md +310 -0
- package/skills/web-guidance/references/security/passkey-reauthentication.md +142 -0
- package/skills/web-guidance/references/security/passkey-registration.md +186 -0
- package/skills/web-guidance/references/security/passkeys.md +39 -0
- package/skills/web-guidance/references/security/sanitize-untrusted-html.md +105 -0
- package/skills/web-guidance/references/security/secure-external-subresources.md +202 -0
- package/skills/web-guidance/references/security/security.md +390 -0
- package/skills/web-guidance/references/security/trusted-types.md +141 -0
- package/skills/web-guidance/references/security/validate-origins.md +197 -0
- package/skills/web-guidance/references/security/verify-email-ownership.md +235 -0
- package/skills/web-guidance/references/ui-atoms/position-aware-tooltips.md +173 -0
- package/skills/web-guidance/references/ui-atoms/responsive-table.md +122 -0
- package/skills/web-guidance/references/ui-atoms/viewport-aware-dropdowns.md +178 -0
- package/skills/web-guidance/references/ui-behaviors/drag-and-drop.md +108 -0
- package/skills/web-guidance/references/ui-behaviors/light-dismiss-a-dialog.md +89 -0
- package/skills/web-guidance/references/ui-behaviors/motion.md +97 -0
- package/skills/web-guidance/references/ui-behaviors/platform-controls-dismiss-dialog.md +40 -0
- package/skills/web-guidance/references/ui-behaviors/prevent-page-scroll-under-modal-dialog.md +59 -0
- package/skills/web-guidance/references/ui-behaviors/search-hidden-content.md +141 -0
- package/skills/web-guidance/references/ui-behaviors/sortable-table.md +140 -0
- package/skills/web-guidance/references/ui-components/accordion.md +343 -0
- package/skills/web-guidance/references/ui-components/breadcrumbs.md +168 -0
- package/skills/web-guidance/references/ui-components/carousel.md +206 -0
- package/skills/web-guidance/references/ui-components/checkbox.md +144 -0
- package/skills/web-guidance/references/ui-components/dialog.md +218 -0
- package/skills/web-guidance/references/ui-components/hovercard.md +391 -0
- package/skills/web-guidance/references/ui-components/menu.md +415 -0
- package/skills/web-guidance/references/ui-components/navbar.md +281 -0
- package/skills/web-guidance/references/ui-components/navigation-drawer.md +429 -0
- package/skills/web-guidance/references/ui-components/persistent-toast-notifications.md +185 -0
- package/skills/web-guidance/references/ui-components/progress.md +181 -0
- package/skills/web-guidance/references/ui-components/spinner.md +179 -0
- package/skills/web-guidance/references/ui-components/tabs.md +371 -0
- package/skills/web-guidance/references/ui-components/toolbar.md +277 -0
- package/skills/web-guidance/references/user-experience/form-factor-adaptation.md +120 -0
- package/skills/web-guidance/references/user-experience/natural-interactions.md +155 -0
- package/skills/web-guidance/references/visual-design/color.md +43 -0
- package/skills/web-guidance/references/visual-design/dark-mode.md +350 -0
- package/dist/web/assets/AgentWork-DwAI0_Of.js +0 -2
- package/dist/web/assets/ApiTests-C0vFSHmM.js +0 -10
- package/dist/web/assets/Browse-5jfdtRc5.js +0 -2
- package/dist/web/assets/Chat-B3uhI94O.js +0 -3
- package/dist/web/assets/CommandPalette-D2J4nf5y.js +0 -1
- package/dist/web/assets/Compare-CN75w1p9.js +0 -1
- package/dist/web/assets/Cost-QoxyjR95.js +0 -1
- package/dist/web/assets/Data-BAvkcBVt.js +0 -6
- package/dist/web/assets/Desktop-BXdOIalN.js +0 -1
- package/dist/web/assets/DesktopReview-Bl2SrPP0.js +0 -1
- package/dist/web/assets/Evidence-BJ_I52CD.js +0 -1
- package/dist/web/assets/Explore-D9AuyTip.js +0 -2
- package/dist/web/assets/Features-CusGMDR9.js +0 -1
- package/dist/web/assets/Flags-CycGFuUP.js +0 -2
- package/dist/web/assets/Flaky-BcSzJogN.js +0 -1
- package/dist/web/assets/Impact-CJHnyZ21.js +0 -3
- package/dist/web/assets/Jobs-4xcFzEFo.js +0 -5
- package/dist/web/assets/KindPage-BielEIej.js +0 -6
- package/dist/web/assets/Migration-NwanKpJg.js +0 -2
- package/dist/web/assets/PageAgent-CNw4NXva.js +0 -1
- package/dist/web/assets/Product-DS3LJZ4P.js +0 -7
- package/dist/web/assets/Production-D3zsyNIS.js +0 -1
- package/dist/web/assets/Quality-Ctj2YpC4.js +0 -1
- package/dist/web/assets/Readiness-DGcRr_co.js +0 -1
- package/dist/web/assets/Record-Cc-wGe_Y.js +0 -1
- package/dist/web/assets/Regression-DcsbrRa1.js +0 -5
- package/dist/web/assets/Reports-BkCn0-Sf.js +0 -2
- package/dist/web/assets/Response-BP0UwQcW.js +0 -9
- package/dist/web/assets/Responsive-C8U7dumd.js +0 -3
- package/dist/web/assets/RunDiff-BhABuhF_.js +0 -1
- package/dist/web/assets/Runs-OwdWEYBv.js +0 -2
- package/dist/web/assets/Steps-BvzbQyoD.js +0 -2
- package/dist/web/assets/TestCases-CLq_6JA5.js +0 -1
- package/dist/web/assets/TestData-B0oKAhp6.js +0 -2
- package/dist/web/assets/TestDebt-8NLQ5YV_.js +0 -1
- package/dist/web/assets/TestManagement-2LYQ7vsN.js +0 -1
- package/dist/web/assets/Tosca-DfvMpPTG.js +0 -3
- package/dist/web/assets/WhatsNew-BGFNGwqN.js +0 -1
- package/dist/web/assets/families-DYlN5v0i.js +0 -1
- package/dist/web/assets/filters-faaSnoIq.js +0 -1
- package/dist/web/assets/fold-CUjwWAK3.js +0 -1
- package/dist/web/assets/frame-BLPdAXUq.js +0 -13
- package/dist/web/assets/head-CsTxBsO0.js +0 -1
- package/dist/web/assets/index-CxiCvGZq.js +0 -78
- package/dist/web/assets/index-dOIsrzhD.css +0 -2
- package/dist/web/assets/line-icons-CwZWt93L.js +0 -1
- package/dist/web/assets/logos-dGuc1jIM.js +0 -1
- package/dist/web/assets/markdown-BI3F-SJ1.js +0 -10
- package/dist/web/assets/paletteCommands-QJiCuUEr.js +0 -1
- package/dist/web/assets/parts-CdF1f7yS.js +0 -1
- package/dist/web/assets/productParts-hNLD9fN0.js +0 -1
- package/dist/web/assets/qualityParts-CT25lBWU.js +0 -1
- package/dist/web/assets/recordTest-P792aBUt.js +0 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Build a carousel
|
|
2
|
+
|
|
3
|
+
Build a carousel for a finite set of related items. Use native scrolling and CSS scroll snap as the foundation; add HTML previous/next and marker controls, with a small script for wiring them and for status updates. This keeps content and basic scrolling usable without JavaScript.
|
|
4
|
+
|
|
5
|
+
## Structure and accessibility
|
|
6
|
+
|
|
7
|
+
- Use a named `region` with `aria-roledescription="carousel"` when the carousel is a meaningful page section. Give each slide `role="group"`, `aria-roledescription="slide"`, and an `aria-label` that includes its position (for example, `aria-label="2 of 4"`). Write the labels in the markup, localized with the rest of the page; if slides change at runtime, regenerate them from the same localized strings. The position is the slide's place in the original sequence, not its current visual position. Keep slide content available to assistive technology.
|
|
8
|
+
- Give every control a clear accessible name: use a native `<button>` with a text or `aria-label` name, not an unlabeled chevron.
|
|
9
|
+
- Announce the current slide in a visually hidden polite status region after scrolling settles. Update it whenever the visible slide changes, whether through the buttons, the markers, or direct scrolling, so assistive technology receives feedback.
|
|
10
|
+
- Ensure that where possible all interactive elements have a target size of at least 24 by 24 CSS pixels, as these provide a way to quickly navigate to each individual slide. This can be achieved by providing undersized elements with enough spacing so that a 24px circle centered on it does not overlap neighboring targets. To do this, make the target itself a little larger than the visible shape with padding, a pseudo-element, or a thin transparent border (with `background-clip: padding-box` so the fill stays on the visible shape), and leave the rest of the spacing to a gap. Do not rely on wide gaps alone, and do not make the invisible area so large that clicks well away from a control activate it. This adheres to the requirements in WCAG 2.5.8 Target Size.
|
|
11
|
+
- Ensure that all controls have sufficient contrast, with non-text elements requiring a contrast ratio of at least 3:1 between the non-text content and adjacent colors, in order to adhere to WCAG 1.4.11 Non-text Contrast.
|
|
12
|
+
- Ensure that when a previous/next control becomes disabled, causing focus to be lost, that focus is redirected elsewhere, such as the opposite control (e.g. move focus to "Next" if previous becomes disabled and has focus, or move focus to "Previous" if next becomes disabled and has focus).
|
|
13
|
+
- The active slide's control must not communicate that it is active through color alone, in order to adhere to WCAG 1.4.1 Use of Color. There must be another visual affordance, such as an outline, or use of a larger height/width, to convey that the control is active.
|
|
14
|
+
|
|
15
|
+
## Scrolling and controls
|
|
16
|
+
|
|
17
|
+
- Make the track natively scrollable and snap slides on its scrolling axis. For horizontal carousels, arrange slides in a row and use the inline axis; for vertical carousels, use a column and the block axis.
|
|
18
|
+
- Set `overscroll-behavior` to `contain` on the track's scrolling axis (`overscroll-behavior-x` for horizontal, `overscroll-behavior-y` for vertical). A scroll that reaches an end of the track then stays on the carousel instead of scrolling the page or starting a back or forward swipe, which makes repeated swipes at the ends smoother. Do not use the `overscroll-behavior` shorthand: it also contains the other axis, which can stop the page from scrolling while the pointer is over the carousel.
|
|
19
|
+
- Use HTML `<button>` elements for previous/next controls and one marker button per slide for direct navigation, in every browser. Do not use `::scroll-button()` or `::scroll-marker` for now.
|
|
20
|
+
|
|
21
|
+
- Keep controls visible, operable, and clearly focused with `:focus-visible`. Loop previous/next controls continuously from the last slide to the first and back by default when there are at least three slides (see Looping); disable them at the ends only when finite navigation is requested. Preserve native keyboard behavior; do not intercept keys from links, form fields, or buttons. Add custom key handling only for a defined interaction need, and avoid overriding nested controls.
|
|
22
|
+
|
|
23
|
+
## Related patterns
|
|
24
|
+
|
|
25
|
+
- For styling the active slide itself, see `carousel-snap-highlights`.
|
|
26
|
+
- For a continuous progress indicator instead of discrete markers, see `scroll-progress-indicator`.
|
|
27
|
+
- For scroll-driven slide effects, see `carousel-slide-effects`.
|
|
28
|
+
- For synchronizing other UI with snap events, see `scroll-snap-state-sync`.
|
|
29
|
+
|
|
30
|
+
## Example: horizontal carousel
|
|
31
|
+
|
|
32
|
+
This example uses full-width horizontal slides. Adapt the slide sizing for a peek layout or use the block axis for a vertical carousel. Give each marker a name that identifies its destination. The CSS below is split by concern, and only the parts that are easy to get wrong are shown; everything else is described in prose. Adapt dimensions, spacing, and colors to the design.
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<section class="carousel" aria-roledescription="carousel" aria-label="Featured products">
|
|
36
|
+
<div class="carousel-controls">
|
|
37
|
+
<button type="button" data-direction="previous">Previous slide</button>
|
|
38
|
+
<button type="button" data-direction="next">Next slide</button>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="carousel-track" tabindex="0" role="group" aria-label="Slides">
|
|
42
|
+
<div role="group" aria-roledescription="slide" aria-label="1 of 3"
|
|
43
|
+
data-marker-name="Go to slide 1">
|
|
44
|
+
<h3>Product one</h3>
|
|
45
|
+
</div>
|
|
46
|
+
<div role="group" aria-roledescription="slide" aria-label="2 of 3"
|
|
47
|
+
data-marker-name="Go to slide 2">
|
|
48
|
+
<h3>Product two</h3>
|
|
49
|
+
</div>
|
|
50
|
+
<div role="group" aria-roledescription="slide" aria-label="3 of 3"
|
|
51
|
+
data-marker-name="Go to slide 3">
|
|
52
|
+
<h3>Product three</h3>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<p class="visually-hidden" role="status" aria-live="polite"></p>
|
|
57
|
+
|
|
58
|
+
<nav class="carousel-markers" aria-label="Choose a slide"></nav>
|
|
59
|
+
</section>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Track and snapping
|
|
63
|
+
|
|
64
|
+
The track is a flex row that scrolls on the inline axis and snaps to slides. Each slide fills the track and snaps to center.
|
|
65
|
+
|
|
66
|
+
```css
|
|
67
|
+
.carousel-track {
|
|
68
|
+
display: flex;
|
|
69
|
+
gap: 1rem; /* example value */
|
|
70
|
+
overflow-x: auto;
|
|
71
|
+
/* mandatory so the track always rests on a slide, which the settled-scroll status relies on */
|
|
72
|
+
scroll-snap-type: x mandatory;
|
|
73
|
+
/* keep a scroll that reaches either end on the carousel; only the scrolling axis, so the page still scrolls the other way */
|
|
74
|
+
overscroll-behavior-x: contain;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.carousel-track > * {
|
|
78
|
+
flex: 0 0 100%; /* one slide per view; use a smaller basis for a peek layout */
|
|
79
|
+
scroll-snap-align: center;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Controls
|
|
84
|
+
|
|
85
|
+
Position the Previous and Next buttons over the track's start and end edges (a `position: absolute` container with a `z-index` so slides don't cover them, and `pointer-events: none` on the container with `pointer-events: auto` on the buttons so the track stays scrollable between them). Build the marker buttons from the slides' `data-marker-name` values, and style the active one with `[aria-current="true"]`.
|
|
86
|
+
|
|
87
|
+
```css
|
|
88
|
+
.carousel-markers button[aria-current="true"] {
|
|
89
|
+
background: #0a5; /* example color; any clear contrast with the other markers works */
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Supporting styles
|
|
94
|
+
|
|
95
|
+
Write these to fit the design:
|
|
96
|
+
|
|
97
|
+
- Style the markers as dots in a centered flex row with a gap, using the pointer cursor.
|
|
98
|
+
- Show a clear `:focus-visible` outline on the control and marker buttons.
|
|
99
|
+
- Set `touch-action: manipulation` on the track and the control buttons, so quick taps on them do not trigger double-tap zoom on touch devices.
|
|
100
|
+
- Keep the status region visually hidden without removing it from the accessibility tree.
|
|
101
|
+
- Enable `scroll-behavior: smooth` on the track only inside `@media (prefers-reduced-motion: no-preference)`.
|
|
102
|
+
|
|
103
|
+
## Fallback strategies
|
|
104
|
+
|
|
105
|
+
The controls are plain HTML, so the fallbacks below only cover the platform features that the script and CSS rely on. Scrolling and snap behavior remain native, and small amounts of script add the controls' behavior and status updates.
|
|
106
|
+
|
|
107
|
+
### Scrolling and completion
|
|
108
|
+
|
|
109
|
+
Baseline status for scroll-behavior: Widely available. It's been Baseline since 2022-03-14.
|
|
110
|
+
Supported by: Chrome 61 (Sep 2017), Edge 79 (Jan 2020), Firefox 36 (Feb 2015), and Safari 15.4 (Mar 2022).
|
|
111
|
+
|
|
112
|
+
Smooth scrolling is optional. The example enables it only when reduced motion is not requested.
|
|
113
|
+
|
|
114
|
+
Browser support for overscroll-behavior: Limited availability.
|
|
115
|
+
Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 150 (Apr 2026).
|
|
116
|
+
Unsupported in: Safari.
|
|
117
|
+
|
|
118
|
+
Containing overscroll is a progressive enhancement and needs no fallback. Without support, a scroll that reaches an end of the track can scroll the page or start a swipe navigation, and the carousel still works.
|
|
119
|
+
|
|
120
|
+
Baseline status for scrollend: Newly available. It's been Baseline since 2025-12-12.
|
|
121
|
+
Supported by: Chrome 114 (May 2023), Edge 114 (Jun 2023), Firefox 109 (Jan 2023), and Safari 26.2 (Dec 2025).
|
|
122
|
+
|
|
123
|
+
If `scrollend` is unavailable, use a debounced `scroll` listener to run the settled-scroll handler. Run the initial marker, button, and parking sync once on load, leaving the polite status region empty until user-initiated scrolling settles so page load is not interrupted.
|
|
124
|
+
|
|
125
|
+
Browser support for Scroll snap events: Limited availability.
|
|
126
|
+
Supported by: Chrome 129 (Sep 2024) and Edge 129 (Sep 2024).
|
|
127
|
+
Unsupported in: Firefox and Safari.
|
|
128
|
+
|
|
129
|
+
The carousel does not depend on snap events. If they are unavailable, use settled-scroll tracking for status; use `scrollsnapchange` only when other UI must follow the browser-selected snap target.
|
|
130
|
+
|
|
131
|
+
### Scroll snap
|
|
132
|
+
|
|
133
|
+
Baseline status for Scroll snap: Widely available. It's been Baseline since 2020-01-15.
|
|
134
|
+
Supported by: Chrome 69 (Sep 2018), Edge 79 (Jan 2020), Firefox 68 (Jul 2019), and Safari 11 (Sep 2017).
|
|
135
|
+
|
|
136
|
+
The track remains natively scrollable with touch, pointer, and keyboard input. JavaScript adds the controls' behavior and announcements without replacing basic scrolling. Place the script in a `<script type="module">` element so it runs after the document has been parsed.
|
|
137
|
+
|
|
138
|
+
### Looping
|
|
139
|
+
|
|
140
|
+
Baseline status for sibling-count() and sibling-index(): Newly available. It's been Baseline since 2026-08-18.
|
|
141
|
+
Supported by: Chrome 138 (Jun 2025), Edge 138 (Jun 2025), Firefox 154 (Aug 2026), and Safari 26.2 (Dec 2025).
|
|
142
|
+
|
|
143
|
+
If `sibling-count()` is unsupported, the script supplies the number of slides instead, so the carousel still loops. Set a `--children-count` custom property on the track only when `CSS.supports("order: sibling-count()")` is false, and read the count in CSS as `var(--children-count, sibling-count())` instead of `sibling-count()`.
|
|
144
|
+
Browsers with support never get the property, so they keep counting natively.
|
|
145
|
+
Do not wrap the parking rules in `@supports`.
|
|
146
|
+
|
|
147
|
+
```css
|
|
148
|
+
.carousel-track > :first-child {
|
|
149
|
+
/* --children-count is only set where sibling-count() is unsupported */
|
|
150
|
+
order: clamp(0, var(--current) - (var(--children-count, sibling-count()) - 3), 1);
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
if (!CSS.supports("order: sibling-count()")) {
|
|
156
|
+
track.style.setProperty("--children-count", track.children.length);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
If content is not static, update the property when slides are added or removed (e.g. via a `MutationObserver`).
|
|
161
|
+
|
|
162
|
+
### Scroll-driven effects
|
|
163
|
+
|
|
164
|
+
Baseline status for Scroll-driven animations: Newly available. It's been Baseline since 2026-10-27.
|
|
165
|
+
Supported by: Chrome 115 (Jul 2023), Edge 115 (Jul 2023), Firefox 159 (Oct 2026), and Safari 26 (Sep 2025).
|
|
166
|
+
|
|
167
|
+
Treat slide effects as optional enhancements and keep them inside `@media (prefers-reduced-motion: no-preference)`. The carousel's navigation and current-slide feedback must not depend on them.
|
|
168
|
+
|
|
169
|
+
## Controls and status updates
|
|
170
|
+
|
|
171
|
+
Update the active marker as the track scrolls (throttled to one update per animation frame) so the dots keep pace with the visible slide, and run announcements and button state after scrolling settles. Measure only the carousel's scrolling axis.
|
|
172
|
+
|
|
173
|
+
Write a small script that adapts to your markup and covers these requirements:
|
|
174
|
+
|
|
175
|
+
- **Wire the HTML controls.** On a Previous or Next click, find the current slide from the track's scroll position along its scrolling axis, then scroll the track to the adjacent slide's snap position in visual order (which differs from DOM order when looping), for example with `track.scrollBy()` using that slide's offset from the track's center. Do not scroll by a fixed viewport width, keep a separate index that can drift from the real scroll position, or use `scrollIntoView()` without limiting it to the track, which can scroll the page. Create one named marker button per slide that scrolls the track to that slide. Keep the Previous and Next buttons before the track in DOM order.
|
|
176
|
+
- **Track the current slide** along the carousel's scrolling axis, for horizontal or vertical layouts.
|
|
177
|
+
- **Update the active marker live.** From a `scroll` listener throttled with `requestAnimationFrame`, compute the nearest slide and set the active marker's `aria-current="true"` immediately, and also set it from the pending target the moment a marker or Previous/Next button is clicked, so the dots change when the user decides instead of after the slide moves. Skip the write when the current slide is unchanged, and skip the listener entirely while a click or key press has a pending target, because recomputing every frame during a scripted smooth scroll makes Safari stutter.
|
|
178
|
+
- **Update the rest after scrolling settles**, from a single handler driven by the settled scroll position: update the buttons' disabled state (and slide parking when looping), and announce "Slide N of M" in the status region only when the settled slide changes from the previously settled slide (keeping initial load and compensating park scrolls silent). Controls only initiate scrolling; they never update state directly.
|
|
179
|
+
- **Settle on `scrollend`**, with a debounced `scroll` listener only where `scrollend` is unsupported. Do not run two settle handlers, and do not reorder or re-scroll the track (such as when parking a slide) while a scroll is still in flight, because that cancels it. The one exception is a marker click when looping, whose own scroll replaces the one in flight (see Looping).
|
|
180
|
+
- **Resolve clicks from a pending target.** Make rapid previous/next clicks build on the slide already being scrolled to, not on the nearest slide, and clear the target when scrolling settles. Ignore a `scrollend` that arrives after the next scroll has started, because acting on it (such as parking) cancels that scroll. Also ignore a settle at the exact scroll position where a scroll to another slide was just requested: it belongs to an earlier scroll (such as a compensating one), and the requested scroll has yet to move.
|
|
181
|
+
- **Respect reduced motion** for any smooth scrolling.
|
|
182
|
+
|
|
183
|
+
## Looping (continuous navigation)
|
|
184
|
+
|
|
185
|
+
Loop previous and next navigation from the last slide to the first and back by keeping the track endless instead of disabling controls at the ends (unless the carousel has fewer than three slides or finite navigation is requested). Do not clone slides or move them in the DOM, which conflicts with frameworks and duplicates content for assistive technology. Instead, park an end slide beside the current one with CSS `order`, and only when the carousel is at or one step from that end. Parking one step early puts the neighbor in place before scrolling reaches an end, so the previous and next buttons never disable mid-scroll. The track then always has a neighbor on both sides, and keyboard scrolling, touch, and snapping all keep working. Only the first and last slides ever get `order`. Because parking starts one step before an end, a short carousel can have an end slide parked at every position (with 4 slides, always; with 3, both ends at the middle slide). DOM order applies unchanged only at positions that are more than one step from both ends, which needs 5 or more slides.
|
|
186
|
+
|
|
187
|
+
- Keep a `--current` custom property on the track: the zero-based index of the current slide. Do not give it a default in CSS: while it is undefined, `order` falls back to 0, so no slide is parked and the carousel starts on the first slide without JavaScript. The script sets it on load. Park the last slide before the first (`order: -1`) when `--current` is `0` or `1`, and park the first slide after the last (`order: 1`) when `--current` is the last or second-to-last index. Set `order` only on the first and last slides (`:first-child` and `:last-child`), not on every slide. `sibling-count()` is needed to find the last indexes. The formulas below are the part that is easy to get wrong.
|
|
188
|
+
- When scrolling settles, update `--current` from the scroll position. If the parking changes, measure the current slide's offset along the scrolling axis before and after, then instantly scroll by the difference in the same task so the change is invisible. Turn scroll snapping off (`scroll-snap-type: none`) around the reorder and the compensating scroll and restore it afterward, because some browsers otherwise re-snap to another slide and keep scrolling. Also lock overflow on the scrolling axis (`overflow-x: hidden`, or `overflow-y: hidden` for vertical) for the same step and restore it two animation frames later: Safari on iOS otherwise paints the reordered layout for a frame before the compensating scroll lands, which flickers. Restoring it immediately breaks looping, so keep the delay. This also applies when a parked slide is released after the user leaves an end slide.
|
|
189
|
+
- Markers must scroll in sequence order. A parked end slide sits on the opposite side of the track from its place in the sequence, so a direct scroll to it goes the short way round (from the first slide, the last slide's marker would scroll backward one step). On a marker click for any slide other than the current one, set `--current` to `initial` on the track before scrolling, so every slide is back in DOM order for the trip. Do it in the same measured, compensated step as parking, but without the overflow lock: Safari does not start the scroll that follows on a locked track. The settle handler then sets `--current` again, which re-parks. Do not do this for previous/next navigation, which must reach the parked slide to wrap. While the slides are in DOM order, an end slide has no neighbor to wrap to, so a Previous or Next click made during the trip cannot be followed yet. Hold it and replay it when scrolling settles and the slides are parked again, and skip the overflow lock for that parking step too, for the same reason.
|
|
190
|
+
- Looping needs at least three slides. Because the compensation is measured, slides may differ in size.
|
|
191
|
+
- The previous/next controls and the status calculation must work from visual order, not DOM sibling order. Per-slide labels ("2 of 4") and the status region use each slide's original index, which does not change when slides are parked. Do not renumber slides when `--current` changes.
|
|
192
|
+
- Keep `scroll-behavior: smooth` inside `prefers-reduced-motion: no-preference` for user navigation; only the compensating scroll is instant.
|
|
193
|
+
|
|
194
|
+
```css
|
|
195
|
+
/* The first slide parks after the last while --current is the last or second-to-last index. */
|
|
196
|
+
.carousel-track > :first-child {
|
|
197
|
+
order: clamp(0, var(--current) - (sibling-count() - 3), 1);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* The last slide parks before the first while --current is 0 or 1. */
|
|
201
|
+
.carousel-track > :last-child {
|
|
202
|
+
order: calc(-1 * clamp(0, 2 - var(--current), 1));
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Parking only changes visual order, so the DOM order stays as the reading and focus order, and no slide is inert or aria-hidden.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Styling Checkboxes
|
|
2
|
+
|
|
3
|
+
Use semantic, accessible HTML with each checkbox associated with its label, either by nesting the `<input>` inside the `<label>` or by matching the label’s `for` attribute to the input’s `id`.
|
|
4
|
+
|
|
5
|
+
Modern CSS provides two approaches to styling checkboxes: customize the native appearance with `accent-color`, or override the default presentation with `appearance: none` on the `<input type="checkbox">` element.
|
|
6
|
+
|
|
7
|
+
## Native customization with `accent-color`
|
|
8
|
+
|
|
9
|
+
For simple, brand-consistent styling that retains native rendering, keyboard behavior, validation, and operating-system focus indicators, use `accent-color`.
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
.checkbox-native {
|
|
13
|
+
accent-color: #1a73e8;
|
|
14
|
+
|
|
15
|
+
/* Sizing is controlled via relative units */
|
|
16
|
+
inline-size: 1.25em;
|
|
17
|
+
aspect-ratio: 1;
|
|
18
|
+
margin: 0;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Fully custom styling with `appearance: none`
|
|
24
|
+
|
|
25
|
+
Use `appearance: none` when the design requires control over the checkbox’s
|
|
26
|
+
shape, size, states, or indicators. This removes the native visual styling while
|
|
27
|
+
leaving the `<input>` as the interactive target.
|
|
28
|
+
|
|
29
|
+
Set explicit relative sizes for `--checkbox-size` and `--checkbox-icon-size` because `appearance: none` removes the browser’s default dimensions. Keep the icon smaller than the checkbox to provide space for its border and visual padding.
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
/* Reusable SVG assets */
|
|
33
|
+
:root {
|
|
34
|
+
--icon-check: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'></polyline></svg>");
|
|
35
|
+
--icon-dash: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4.5' stroke-linecap='round' stroke-linejoin='round'><line x1='5' y1='12' x2='19' y2='12'></line></svg>");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Custom checkbox */
|
|
39
|
+
.checkbox-custom {
|
|
40
|
+
--checkbox-size: 1.25em;
|
|
41
|
+
--checkbox-icon-size: 0.7em;
|
|
42
|
+
|
|
43
|
+
appearance: none;
|
|
44
|
+
display: inline-grid;
|
|
45
|
+
place-content: center;
|
|
46
|
+
inline-size: var(--checkbox-size);
|
|
47
|
+
aspect-ratio: 1;
|
|
48
|
+
margin: 0;
|
|
49
|
+
border: 2px solid currentColor;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
|
|
52
|
+
&::before {
|
|
53
|
+
content: "";
|
|
54
|
+
inline-size: var(--checkbox-icon-size);
|
|
55
|
+
aspect-ratio: 1;
|
|
56
|
+
background-color: currentColor;
|
|
57
|
+
mask: var(--checkbox-icon) no-repeat center / contain;
|
|
58
|
+
scale: 0;
|
|
59
|
+
|
|
60
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
61
|
+
transition: scale 150ms ease;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media (forced-colors: active) {
|
|
65
|
+
background-color: CanvasText;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&:checked {
|
|
70
|
+
--checkbox-icon: var(--icon-check);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:indeterminate {
|
|
74
|
+
--checkbox-icon: var(--icon-dash);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:is(:checked, :indeterminate)::before {
|
|
78
|
+
scale: 1;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:focus-visible {
|
|
82
|
+
outline: 2px solid currentColor;
|
|
83
|
+
outline-offset: 2px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:disabled {
|
|
87
|
+
cursor: not-allowed;
|
|
88
|
+
opacity: 0.5;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## The indeterminate state
|
|
95
|
+
|
|
96
|
+
The indeterminate state cannot be set via an HTML attribute; set the `indeterminate` DOM property in JavaScript (`checkbox.indeterminate = true`) and ensure the `:indeterminate` pseudo-class is visually distinct from both `:checked` and unchecked states:
|
|
97
|
+
|
|
98
|
+
* **Native (`accent-color`):** Automatically styled by the browser using the element's `accent-color` (no extra `:indeterminate` CSS rule needed).
|
|
99
|
+
* **Custom (`appearance: none`):** Swap `--checkbox-icon` to `var(--icon-dash)` on `.checkbox-custom:indeterminate` as shown above.
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
const selectAll = document.querySelector("#select-all");
|
|
103
|
+
selectAll.indeterminate = true;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Accessibility and interaction
|
|
107
|
+
|
|
108
|
+
- **DO** use `:focus-visible` rather than `:focus` to style focus indicators on custom checkboxes so a distinct outline appears for keyboard navigation without showing on pointer clicks.
|
|
109
|
+
- **DO NOT** use `outline: none` or hide focus indicators on checkboxes.
|
|
110
|
+
- **DO** ensure the contrast of focus indicators has a contrast of at least `3:1` with the background color
|
|
111
|
+
- **DO** ensure the color for the checked and indeterminate state has a contrast of at least `3:1` with the background color
|
|
112
|
+
- **DO** ensure the checkbox or its wrapping `<label>` provides an interactive hit target of at least `44px x 44px` while keeping the visual checkbox box sized in relative units:
|
|
113
|
+
```css
|
|
114
|
+
label {
|
|
115
|
+
display: inline-flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: 0.65rem;
|
|
118
|
+
min-block-size: 44px;
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
- **DO** provide a `:disabled` style variant that lowers opacity and sets `cursor: not-allowed` to convey inactive states clearly.
|
|
123
|
+
|
|
124
|
+
### Issues to be aware of when using accent-color
|
|
125
|
+
|
|
126
|
+
Browser rendering of `accent-color` varies.
|
|
127
|
+
For indicators generally painted over an accent color background, such as checkbox marks and radio-button dots, browsers may apply different treatments:
|
|
128
|
+
- **Chromium** and **Firefox** generally select a contrasting indicator color.
|
|
129
|
+
- **Safari** may instead preserve a white indicator in light mode or a black indicator in dark mode, while modifying the accent color behind it. This adjustment does not always provide sufficient contrast for every supplied color, so test important combinations in Safari, including both light and dark color schemes. Do not assume that Safari will automatically choose whichever indicator color provides the best contrast.
|
|
130
|
+
|
|
131
|
+
## Fallback strategies
|
|
132
|
+
|
|
133
|
+
### Fallbacks & browser support for accent-color
|
|
134
|
+
|
|
135
|
+
Browser support for accent-color: Limited availability.
|
|
136
|
+
Supported by: Chrome 93 (Aug 2021), Edge 93 (Sep 2021), Firefox 92 (Sep 2021), and Safari 26.2 (Dec 2025).
|
|
137
|
+
|
|
138
|
+
The `accent-color` property is progressive enhancement.
|
|
139
|
+
Browsers that do not support this property will ignore it and use their default UI colors.
|
|
140
|
+
|
|
141
|
+
### CSS Masks
|
|
142
|
+
|
|
143
|
+
Baseline status for Masks: Widely available. It's been Baseline since 2023-12-07.
|
|
144
|
+
Supported by: Chrome 120 (Dec 2023), Edge 120 (Dec 2023), Firefox 53 (Apr 2017), and Safari 15.4 (Mar 2022).
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Dialog
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Use the native `<dialog>` element for modal and non-modal dialogs. It provides the accessibility semantics, focus handling, top-layer rendering and `Esc` handling that custom overlays have to rebuild by hand.
|
|
6
|
+
|
|
7
|
+
## Choose the overlay type
|
|
8
|
+
|
|
9
|
+
Pick the first rule that matches. If unsure, use Rule 1.
|
|
10
|
+
|
|
11
|
+
### Rule 1: The overlay interrupts the user and blocks the page (default)
|
|
12
|
+
|
|
13
|
+
Use for confirmations, forms, sign-in, destructive actions, and any "modal", "dialog", "lightbox" or "popup" request that does not say otherwise.
|
|
14
|
+
|
|
15
|
+
Use `<dialog>` opened as a modal, declaratively with `command="show-modal"` (see `declarative-dialog-popover-control`) or from script with `showModal()`.
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<button type="button" command="show-modal" commandfor="confirm">Delete</button>
|
|
19
|
+
|
|
20
|
+
<!-- MANDATORY: no role="dialog" or aria-modal; the native modal already provides them -->
|
|
21
|
+
<dialog id="confirm" aria-labelledby="confirm-title">
|
|
22
|
+
<h2 id="confirm-title">Delete this item?</h2>
|
|
23
|
+
<form method="dialog">
|
|
24
|
+
<button value="cancel" autofocus>Cancel</button>
|
|
25
|
+
<button value="delete">Delete</button>
|
|
26
|
+
</form>
|
|
27
|
+
</dialog>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The browser provides: inert page, focus containment, top layer, `::backdrop`, `Esc` and back-gesture dismissal, and focus return to the invoker.
|
|
31
|
+
|
|
32
|
+
- **DON'T** add `role="dialog"`, `aria-modal`, a focus trap, `inert` toggling or an `Esc` handler.
|
|
33
|
+
- **DON'T** open it with `show()` or the `open` attribute.
|
|
34
|
+
- **DO** stop the page scrolling behind it with the CSS below. See `prevent-page-scroll-under-modal-dialog` (references/ui-behaviors/prevent-page-scroll-under-modal-dialog.md) for the details.
|
|
35
|
+
- **DON'T** lock scrolling with `overflow: hidden` or `position: fixed` on `html` or `body`.
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
/* MANDATORY (both rules): without them, scrolling over the backdrop or inside the dialog scrolls the page behind it */
|
|
39
|
+
dialog:modal {
|
|
40
|
+
overscroll-behavior: contain; /* stops scroll gestures in the dialog chaining to the page */
|
|
41
|
+
}
|
|
42
|
+
dialog::backdrop {
|
|
43
|
+
overflow: hidden; /* ::backdrop is not a scroll container by default, so it would ignore overscroll-behavior */
|
|
44
|
+
overscroll-behavior: contain;
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Not for menus or tooltips: see Rule 3.
|
|
49
|
+
|
|
50
|
+
### Rule 2: The user keeps working in the page while the panel is open
|
|
51
|
+
|
|
52
|
+
Use for find bars, inspectors, palettes and compose panes that are still dialogs semantically.
|
|
53
|
+
|
|
54
|
+
Use `<dialog popover>` for a top-layer panel with popover dismissal (`auto` light-dismisses, `manual` does not). Use `dialog.show()` only when the panel must not be in the top layer.
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<button type="button" popovertarget="find">Find</button>
|
|
58
|
+
<dialog id="find" popover="manual" aria-labelledby="find-title">
|
|
59
|
+
<h2 id="find-title">Find</h2>
|
|
60
|
+
<input type="search" aria-label="Search">
|
|
61
|
+
<button type="button" popovertarget="find" popovertargetaction="hide">Close</button>
|
|
62
|
+
</dialog>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The page stays interactive and is not made inert.
|
|
66
|
+
|
|
67
|
+
- **DO** include a visible close button.
|
|
68
|
+
- **DON'T** use `showModal()`, which blocks the page.
|
|
69
|
+
|
|
70
|
+
Not for blocking confirmations: see Rule 1.
|
|
71
|
+
|
|
72
|
+
### Rule 3: The overlay is not a dialog
|
|
73
|
+
|
|
74
|
+
Use for menus, dropdowns, tooltips, hovercards and toasts.
|
|
75
|
+
|
|
76
|
+
Use a semantic element with the `popover` attribute, not `<dialog>`.
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<button type="button" popovertarget="menu">Actions</button>
|
|
80
|
+
<ul id="menu" popover>
|
|
81
|
+
<li><a href="/rename">Rename</a></li>
|
|
82
|
+
</ul>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Choose how it can be dismissed
|
|
86
|
+
|
|
87
|
+
The default depends on how the dialog is opened. If `closedby` is absent or invalid, `showModal()` behaves as `closerequest` and any other way of opening behaves as `none`.
|
|
88
|
+
|
|
89
|
+
- **Esc and back gesture only (modal default):** set nothing, or `closedby="closerequest"`.
|
|
90
|
+
- **Also click outside to close:** use `closedby="any"`.
|
|
91
|
+
- **Only the developer closes it (for example a form with unsaved changes):** use `closedby="none"` and add a confirmation path. See Closing below.
|
|
92
|
+
|
|
93
|
+
## Guidelines
|
|
94
|
+
|
|
95
|
+
### Accessible name and initial focus
|
|
96
|
+
|
|
97
|
+
- **DO** name every dialog with `aria-labelledby` pointing at its heading, or `aria-label` when there is no visible title.
|
|
98
|
+
- **DO** put `autofocus` on the primary control or first field.
|
|
99
|
+
- **DO** put `autofocus` on the safe action (such as Cancel or Keep) in a destructive confirmation.
|
|
100
|
+
- **DON'T** write code to return focus on close. The browser returns it to the invoker.
|
|
101
|
+
|
|
102
|
+
### Opening
|
|
103
|
+
|
|
104
|
+
- **DO** open declaratively with `command="show-modal"` and `commandfor` on a `<button>`. See `declarative-dialog-popover-control`.
|
|
105
|
+
- **DO** use `dialog.showModal()` when opening from script.
|
|
106
|
+
|
|
107
|
+
### Closing
|
|
108
|
+
|
|
109
|
+
- **DO** close with `<form method="dialog">` buttons or `command="close"`.
|
|
110
|
+
- **DO** choose `closedby` deliberately: `any` (light dismiss and `Esc`), `closerequest` (`Esc` only, the modal default) or `none` (developer-controlled close only).
|
|
111
|
+
- **DO** use `command="request-close"` or `requestClose()` for Cancel buttons that must honor unsaved-changes logic. They fire `cancel` first and ignore `closedby`.
|
|
112
|
+
- **DO** treat `closedby` as progressive enhancement. `Esc` and the mobile back gesture already close modals without it.
|
|
113
|
+
|
|
114
|
+
### Hooking into close
|
|
115
|
+
|
|
116
|
+
- **DO** read `dialog.returnValue` in a `close` listener to learn which button was used, then reset it with `dialog.returnValue = ''`. `Esc` and other close requests set no value, and browsers differ on whether they clear the previous one, so without the reset a stale value can leak. Treat `''` as "dismissed without choosing".
|
|
117
|
+
- **DO** use `cancel` to intercept `Esc` and `request-close`, but do not rely on `preventDefault()` for repeated `Esc` presses without user activation.
|
|
118
|
+
- **DO** use `closedby="none"` with an explicit confirmation step for dirty forms.
|
|
119
|
+
- **DO** tell the user why the dialog stayed open when `cancel` is prevented: show a visible message and reference it with `aria-describedby` from the control that receives focus (such as Discard), so a screen reader reads it when focus moves. Without it, focus moving to a new button announces only that button's name.
|
|
120
|
+
- **DON'T** let the confirmation move controls under the pointer. Reserve the message's space (hide it with `visibility`, not `display` or `hidden`) and add the destructive button where existing buttons do not move (for example first in a right-aligned row), so a second click at the same spot cannot discard the user's changes.
|
|
121
|
+
|
|
122
|
+
### Non-modal dialogs
|
|
123
|
+
|
|
124
|
+
- **DO** use `<dialog popover>` (`auto` or `manual`) for a top-layer panel, and `dialog.show()` when you do not want the top layer.
|
|
125
|
+
- **DO** include a visible close button in every non-modal dialog.
|
|
126
|
+
|
|
127
|
+
### Backdrop and styling
|
|
128
|
+
|
|
129
|
+
- **DO** style `::backdrop` and use `dialog:modal` to target modal-only styles.
|
|
130
|
+
- **DO** leave animation to `animate-to-from-top-layer`, dragging to `drag`, and reparenting to `persistent-top-layer-ui`.
|
|
131
|
+
- **DON'T** set `display` on `dialog` unconditionally. It overrides the closed state. Scope it with `dialog[open]`.
|
|
132
|
+
|
|
133
|
+
### Accessibility
|
|
134
|
+
|
|
135
|
+
- **DON'T** add `role="dialog"`, `aria-modal`, a manual focus trap or `inert` toggling to a native modal.
|
|
136
|
+
- **DO** use a native `<button>` with an accessible name for close controls.
|
|
137
|
+
- **DO** use one consistent heading level for dialog titles.
|
|
138
|
+
|
|
139
|
+
## Fallback strategies
|
|
140
|
+
|
|
141
|
+
### `closedby` (`dialog-closedby`)
|
|
142
|
+
|
|
143
|
+
Browser support for <dialog closedby>: Limited availability.
|
|
144
|
+
Supported by: Chrome 134 (Mar 2025), Edge 134 (Mar 2025), and Firefox 141 (Jul 2025).
|
|
145
|
+
Unsupported in: Safari.
|
|
146
|
+
|
|
147
|
+
Without `closedby`, a modal still closes with `Esc` and the back gesture; only click-outside is lost, so this is graceful degradation. `closedby="none"` is ignored the same way: `Esc` fires `cancel` and then closes the dialog. Keep the unsaved-changes guard in a `cancel` handler, not in `closedby="none"` alone, so it also protects where `closedby` is missing. If your Baseline target requires light dismiss, add this where `closedby` is missing:
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
if (!('closedBy' in HTMLDialogElement.prototype)) {
|
|
151
|
+
// Test the pointer position, not event.target: the <dialog> is also the target for its own
|
|
152
|
+
// padding and the gaps between its children, so a target check would close on those clicks
|
|
153
|
+
const outside = (e, dialog) => {
|
|
154
|
+
const r = dialog.getBoundingClientRect();
|
|
155
|
+
return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;
|
|
156
|
+
};
|
|
157
|
+
for (const dialog of document.querySelectorAll('dialog[closedby="any"]')) {
|
|
158
|
+
let pressedOutside = false;
|
|
159
|
+
dialog.addEventListener('pointerdown', (e) => { pressedOutside = outside(e, dialog); });
|
|
160
|
+
// Require the press and the release outside, so a text-selection drag that ends on the backdrop does not dismiss
|
|
161
|
+
dialog.addEventListener('pointerup', (e) => { if (pressedOutside && outside(e, dialog)) dialog.close(); });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### `overscroll-behavior`
|
|
167
|
+
|
|
168
|
+
Browser support for overscroll-behavior: Limited availability.
|
|
169
|
+
Supported by: Chrome 144 (Jan 2026), Edge 144 (Jan 2026), and Firefox 150 (Apr 2026).
|
|
170
|
+
Unsupported in: Safari.
|
|
171
|
+
|
|
172
|
+
Treat scroll containment as progressive enhancement. Do not feature-detect it: `@supports` reports the property as supported even where non-scrollable containers ignore it. Where it is not enforced, the dialog still contains scroll whenever its own content overflows, and `showModal()` still makes the page inert. Do not fall back to `overflow: hidden` or `position: fixed` on `html` or `body`, which removes the root scrollbar and shifts the layout.
|
|
173
|
+
|
|
174
|
+
### Invoker Commands (`command` / `commandfor`)
|
|
175
|
+
|
|
176
|
+
Baseline status for Invoker commands: Newly available. It's been Baseline since 2025-12-12.
|
|
177
|
+
Supported by: Chrome 135 (Apr 2025), Edge 135 (Apr 2025), Firefox 144 (Oct 2025), and Safari 26.2 (Dec 2025).
|
|
178
|
+
|
|
179
|
+
If your Baseline target does not include Invoker Commands, keep the same markup and conditionally load the polyfill (the same experience, as progressive enhancement). Detect on the interface and never load it unconditionally:
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
// MANDATORY: feature detect on HTMLButtonElement.prototype and load only when native support is missing
|
|
183
|
+
if (!('commandForElement' in HTMLButtonElement.prototype)) {
|
|
184
|
+
import('invokers-polyfill'); // npm install invokers-polyfill
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Only Rules 2 and 3 use Popover.
|
|
189
|
+
|
|
190
|
+
### Fallbacks & browser support for Popover
|
|
191
|
+
|
|
192
|
+
Baseline status for Popover: Newly available. It's been Baseline since 2025-01-27.
|
|
193
|
+
Supported by: Chrome 116 (Aug 2023), Edge 116 (Aug 2023), Firefox 125 (Apr 2024), Safari 17 (Sep 2023), and Safari iOS 18.3 (Jan 2025).
|
|
194
|
+
|
|
195
|
+
The Popover API is mostly **progressive enhancement**, but its defining behaviors — top-layer promotion, light-dismiss, and `popovertarget` invocation — have no CSS-only equivalent. Older browsers need a polyfill, or a manual fallback if you would rather not ship one.
|
|
196
|
+
|
|
197
|
+
**Polyfill:** To support the `popover` attribute in older browsers, conditionally load [`@oddbird/popover-polyfill`](https://github.com/oddbird/popover-polyfill). **MANDATORY:** Feature detect by checking for the `popover` property on `HTMLElement.prototype`, and load the polyfill **only** when native support is missing — do NOT load it unconditionally.
|
|
198
|
+
|
|
199
|
+
With a bundler or import map:
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
// MANDATORY: Feature detect 'popover' on HTMLElement.prototype.
|
|
203
|
+
if (!Object.hasOwn(HTMLElement.prototype, "popover")) {
|
|
204
|
+
import("@oddbird/popover-polyfill");
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
If not using a package manager, import from a CDN, e.g. `"https://unpkg.com/@oddbird/popover-polyfill@latest/dist/popover.min.js"`.
|
|
209
|
+
|
|
210
|
+
Caveats when using the polyfill:
|
|
211
|
+
- Do NOT use the `popover` IDL attribute for any code that may run before the polyfill is fully loaded. It will not be mirrored as an attribute, the popover will not be picked up by the polyfill, and the property will be shadowing the accessor the polyfill adds forever. Use `setAttribute()`/`removeAttribute()` instead.
|
|
212
|
+
- **Styling caveat:** The polyfill cannot define the real `:popover-open` pseudo-class, so it applies a `.\:popover-open` class instead. **MANDATORY:** Combine the two with `:is()` or `:where()`, otherwise browsers that lack `:popover-open` discard the entire rule:
|
|
213
|
+
|
|
214
|
+
```css
|
|
215
|
+
[popover]:is(:popover-open, .\:popover-open) {
|
|
216
|
+
display: block;
|
|
217
|
+
}
|
|
218
|
+
```
|