Modern Web Guidance(源码)
本仓库是 GoogleChrome/modern-web-guidance 的源码仓库,包含用于编写、校准和评估其内容的代码与文档。
Modern Web Guidance 是一组技能,将 Web 平台专业知识、最佳实践和浏览器兼容性数据直接嵌入到你的编码代理中。它帮助引导你的编码代理远离遗留模式,转而采用能够充分利用现代 Web 平台能力和特性的解决方案。
参见 CONTRIBUTING.md 和 GOVERNANCE.md 了解我们如何开展项目工作以及代码库的定位。
由 Google Chrome、Microsoft Edge、Mozilla Firefox 和 MDN 团队以及 Web 开发社区共同维护。
文档 · 评估仪表盘 · 源代码 · 报告问题
快速开始
npx modern-web-guidance@latest install
此命令运行一个交互式向导来安装 Modern Web Guidance。参见下方的替代安装方法。
试用(无需安装)
# 搜索相关指南
npx modern-web-guidance@latest search "animate a dialog modal backdrop"
# 通过 ID 获取指南
npx modern-web-guidance@latest retrieve "animate-to-from-top-layer"
# 扫描代码库中的遗留模式以进行现代化改造
npx modern-web-guidance@latest legacy-scan .
为什么?
编码代理通常默认使用较旧的模式,因为 LLM 训练数据中包含大量遗留代码。这往往导致它们为那些现在已有原生、高性能 Web 平台解决方案的任务生成臃肿的 JavaScript。即使模型知道某个 API 存在,它通常也缺乏生产级代码所需的密集的真实世界现代实现模式。
Modern Web Guidance 弥合了这一差距。我们技能的 CLI 将有针对性的、专家策划的指南直接返回到你的代理的上下文窗口中,重点关注:
- 现代浏览器 API:帮助模型正确构建它们经常误用的 API。
- 性能与无障碍:优先使用可被浏览器优化且包含内置无障碍功能的平台级 API。
- 负责任的回退方案:引导模型使用合理的轻量级回退方案,而非重型 polyfill 或遗留库。
包含什么?
我们涵盖了 Web 平台过去几年的新特性,一直到最前沿。这些指南设计为 token 高效;我们运行评估,以修剪模型已经知道的最低共同标准内容。
核心领域
🎨 用户体验 流畅的视觉状态(View Transitions、进入/退出动画、视差滚动、CSS scrollbar-color)。
📐 CSS 布局 现代布局系统(容器查询、subgrid、现代色彩空间如 oklch、text-wrap 调优和 line-height 修剪)。
⚡ 性能 速度优化(即时预加载、Interaction to Next Paint (INP) 诊断、通过 scheduler.yield 调度任务)。
📝 表单与 UI 原生组件(用于工具提示的 Anchor Positioning、Popover API、对话框、:user-invalid 验证和自动调整大小的字段)。
♿ 无障碍 重要考量(屏幕阅读器和键盘可操作性、内容导航和可发现性)。
🤖 内置 AI 本地客户端模型(原生翻译、摘要和语言检测 API)。
查看示例:navigation-drawer 指南。
完整列表:250 项现代 Web 特性
CSS 与布局(140 项特性)
- ::backdrop
- content-visibility
- progress()
- ::details-content
- contrast-color()
- reading-flow
- ::file-selector-button
- 跨文档视图过渡
- 相对颜色
- ::placeholder
- currentColor
- rem
- ::selection
- 自定义高亮
- resize(CSS 属性)
- :dir()
- 自定义属性
- revert
- :focus-visible
- display 动画
- revert-rule
- :focus-within
- 元素作用域视图过渡
- 安全区域 inset 环境变量
- :has()
- em 单位
- 滚动标记
- target 伪类
- :host-context()
- field-sizing
- 滚动方法 Promise
- :is()
- filter
- 滚动捕捉
- :modal
- flex-wrap: balance
- 滚动捕捉事件
- :not()
- Flexbox
- scroll-axis-lock
- :nth-child() of
- font-size
- scroll-behavior
- :placeholder-shown
- font-size-adjust
- 滚动驱动动画
- :user-valid 和 :user-invalid
- 强制颜色
- scroll-initial-target
- :where()
- 渐变插值
- scroll-target-group
- @function
- 渐变
- scrollbar-color
- @scope
- Grid
- scrollbar-gutter
- @starting-style
- Grid lanes
- scrollbar-width
- @supports
- 断词
- scrollend
- abs() 和 sign()
- image-set()
- scrollIntoView()
- accent-color
- 独立变换属性
- Shadow parts
- 活动视图过渡
- inherit
- sibling-count() 和 sibling-index()
- 生成内容的替代文本
- initial
- 粘性定位
- 锚点定位容器查询
- 交互媒体查询
- Subgrid
- 锚点定位
- interpolate-size
- 系统颜色
- 动画(CSS)
- isolation
- 文本溢出
- appearance
- Lab 和 LCH
- 文本描边和填充(兼容性前缀)
- aspect-ratio
- light-dark()
- text-box
- at-rule()
- line-clamp
- text-decoration
- attr()
- line-height
- text-decoration-skip-ink
- background-blend-mode
- linear() 缓动
- text-decoration-skip-ink: all
- background-clip: border-area
- 逻辑属性
- text-decoration-skip-spaces
- border-radius
- 遮罩
- text-wrap
- box-shadow
- min()、max() 和 clamp()
- text-wrap: balance
- calc-size()
- mix-blend-mode
- text-wrap: pretty
- 级联层
- 嵌套
- transition-behavior
- ch 单位
- Oklab 和 OkLCh
- 过渡(CSS)
- clip-path
- overflow-clip-margin
- 三角函数(CSS)
- color-mix()
- overflow-wrap
- unset
- color-scheme
- overflow: clip
- user-select
- 锥形渐变
- overlay
- 视图过渡
- 容器查询(尺寸)
- overscroll-behavior
- view-transition-class
- 容器滚动状态查询
- prefers-color-scheme 媒体查询
- 视口单位
- 容器样式查询
- prefers-contrast 媒体查询
- Web 动画
- 内容
- prefers-reduced-motion 媒体查询
HTML 与 DOM(36 项特性)
- :autofill
- HTML 流式
- setter
- :indeterminate
- HTML-in-canvas
- 自主自定义元素
- inert
- blocking="render"
- Interest invokers
- 可自定义
- Invoker 命令
- 声明式 Shadow DOM
- 媒体懒加载