material-3
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMaterial Design 3
Material Design 3
This skill guides implementation of Google's Material Design 3 (MD3) — a personal, adaptive, expressive design system. MD3 uses dynamic color, tonal surfaces, rounded shapes, and spring-based motion to create UIs that feel alive and personal.
本技能指导如何实现谷歌的Material Design 3(MD3)——一套个性化、自适应、富有表现力的设计系统。MD3采用动态色彩、色调化表面、圆角造型以及基于弹簧物理的动效,打造出鲜活且极具个性的UI界面。
Philosophy
设计理念
MD3 is built on three principles:
- Personal: Dynamic color adapts UI to the user's wallpaper or content. Theming is individual, not one-size-fits-all.
- Adaptive: Layouts transform across 5 window size classes. Components resize, reposition, and change form factor responsively.
- Expressive: Shape morphing, spring physics, and emphasized typography create moments of delight without sacrificing usability.
MD3基于三大原则构建:
- 个性化:动态色彩可根据用户壁纸或内容适配UI。主题配置因人而异,而非千篇一律。
- 自适应:布局可在5种窗口尺寸类别间转换。组件会响应式地调整大小、位置及形态。
- 表现力:形状变形、弹簧物理动效及强调式排版,在不牺牲可用性的前提下打造愉悦的交互体验。
Current Updates: Google I/O 2026
最新更新:Google I/O 2026
Material's Google I/O 2026 update reinforces a Compose-first Android path and expands expressive/adaptive guidance:
- Material Android is Compose-first: For new Android work, prefer Jetpack Compose Material3 for the latest components, expressive APIs, adaptive scaffolds, and Styles API integration. Android Views may remain necessary in existing apps, but they should not be treated as the default path for new Material 3 implementations.
- Expressive layout system: Use an expressive layout scaffold to adapt screens across mobile, desktop, foldables, watches, XR, and other spatial form factors. Start from adaptive scaffolds/window size classes instead of fixed phone-first layouts.
- 8dp spacing system: Apply spacing tokens for margins, padding, and gaps so layouts and components can adapt programmatically to device type and density.
- New/updated expressive components: Lists, menus, search, and search app bars have refreshed expressive guidance, with Jetpack Compose as the primary implementation target.
- Watches and XR: Watches emphasize physics-based motion, arc text, and edge-hugging containers. XR emphasizes spatial panels and depth-based elevation.
Key differences from MD2:
- Tonal surfaces replace elevation shadows as the primary depth cue
- Dynamic color generates full schemes from a single seed color
- Fully rounded corners by default (not slightly rounded)
- Spring-based motion physics replace fixed easing curves for components
- 3 levels of user-controlled contrast (standard/medium/high)
Relationship with frontend-design skill:
When both skills are active, MD3 provides the design system (tokens, components, layout rules) and frontend-design provides creative direction within those constraints. MD3 rules take precedence for component structure and token usage. Note: Roboto/Roboto Flex IS the correct default typeface in MD3 — the frontend-design guidance to avoid Roboto does not apply when implementing MD3.
Material的Google I/O 2026 更新强化了Compose优先的Android开发路线,并扩展了表现力/自适应相关指导:
- Material Android 采用Compose优先策略:对于新的Android开发项目,优先使用Jetpack Compose Material3以获取最新组件、表现力API、自适应脚手架及Styles API集成。现有应用中可能仍需使用Android Views,但它不应作为新Material 3实现的默认方案。
- 表现力布局系统:使用表现力布局脚手架,适配移动端、桌面端、折叠屏、手表、XR及其他空间形态设备的界面。从自适应脚手架/窗口尺寸类别入手,而非固定的手机优先布局。
- 8dp间距系统:应用间距令牌设置边距、内边距和间隙,使布局和组件可根据设备类型和密度自动适配。
- 新增/更新的表现力组件:列表、菜单、搜索及搜索应用栏的表现力指导已更新,Jetpack Compose为主要实现目标。
- 手表与XR设备:手表端侧重基于物理的动效、弧形文本及贴边容器;XR端侧重空间面板和基于深度的层级效果。
与MD2的核心差异:
- 色调化表面取代阴影,成为主要的深度提示方式
- 动态色彩可从单一种子色生成完整配色方案
- 默认采用全圆角(而非轻微圆角)
- 组件动效采用基于弹簧的物理特性,替代固定缓动曲线
- 支持3种用户可控的对比度级别(标准/中等/高)
与前端设计技能的关系:
当两项技能同时启用时,MD3提供设计系统(令牌、组件、布局规则),前端设计则在这些约束内提供创意方向。组件结构和令牌使用以MD3规则为准。注意:Roboto/Roboto Flex是MD3的正确默认字体——前端设计中“避免使用Roboto”的指导不适用于MD3实现场景。
Decision Tree
决策树
What are you building?
Full app scaffold → See "Common Patterns: App Shell" + references/layout-and-responsive.md
Single component → See "Component Quick Reference" table → references/component-catalog.md
Custom theme → See references/theming-and-dynamic-color.md
Form / input layout → See references/component-catalog.md § Input Components
Navigation structure → See references/navigation-patterns.md
Data display → See references/component-catalog.md § Data DisplayWhat platform?
Jetpack Compose → Primary: androidx.compose.material3, MaterialTheme, references/*
Flutter → useMaterial3: true in ThemeData, ColorScheme.fromSeed()
Web (vanilla JS) → @material/web (limited; maintenance mode) + CSS custom properties
Web (React/Vue/Svelte) → CSS custom properties + wrapper components (no official React lib)
Web (CSS-only) → MD3 token values as CSS custom properties (no <md-*> elements)你要构建什么?
完整应用脚手架 → 查看「通用模式:应用框架」+ references/layout-and-responsive.md
单个组件 → 查看「组件速查表」→ references/component-catalog.md
自定义主题 → 查看 references/theming-and-dynamic-color.md
表单/输入布局 → 查看 references/component-catalog.md § 输入组件
导航结构 → 查看 references/navigation-patterns.md
数据展示 → 查看 references/component-catalog.md § 数据展示面向什么平台?
Jetpack Compose → 核心依赖:androidx.compose.material3、MaterialTheme、references/*
Flutter → 在ThemeData中设置useMaterial3: true,使用ColorScheme.fromSeed()
Web(原生JS) → @material/web(受限;维护模式) + CSS自定义属性
Web(React/Vue/Svelte) → CSS自定义属性 + 封装组件(无官方React库)
Web(纯CSS) → 将MD3令牌值作为CSS自定义属性使用(无需<md-*>元素)Design Token System
设计令牌系统
All MD3 tokens use the namespace. Jetpack Compose maps roles to , , and (same semantic roles as the spec). On the web, these map to CSS custom properties ():
md.sysMaterialTheme.colorSchemeMaterialTheme.typographyMaterialTheme.shapes--md-sys-*所有MD3令牌使用命名空间。Jetpack Compose将角色映射到、和(与规范中的语义角色一致)。Web端则映射到CSS自定义属性():
md.sysMaterialTheme.colorSchemeMaterialTheme.typographyMaterialTheme.shapes--md-sys-*Color Tokens (--md-sys-color-*
)
--md-sys-color-*色彩令牌(--md-sys-color-*
)
--md-sys-color-*| Token | Purpose |
|---|---|
| High-emphasis fills, text, icons against surface |
| Text/icons on primary |
| Standout fill for key components (FAB, etc.) |
| Text/icons on primary-container |
| Less prominent accents |
| Recessive components (tonal buttons) |
| Contrasting accents |
| Complementary containers |
| Error states (static — doesn't change with dynamic color) |
| Error container fills |
| Default background |
| Text/icons on any surface |
| Lower-emphasis text/icons on surface |
| Lowest-emphasis container |
| Low-emphasis container |
| Default container (nav areas) |
| High-emphasis container |
| Highest-emphasis container |
| Maintain relative brightness across light/dark |
| Contrasting elements (snackbars) |
| Important boundaries (text field borders) |
| Decorative elements (dividers) |
Full details:
references/color-system.md| 令牌 | 用途 |
|---|---|
| 高强调填充色、文本、图标(用于表面之上) |
| 主色之上的文本/图标色 |
| 关键组件(如FAB)的突出填充色 |
| 主容器之上的文本/图标色 |
| 次要强调色 |
| 次要组件(如色调按钮)的填充色 |
| 对比强调色 |
| 互补容器填充色 |
| 错误状态色(静态,不随动态色彩变化) |
| 错误容器填充色 |
| 默认背景色 |
| 任意表面之上的文本/图标色 |
| 表面之上的低强调文本/图标色 |
| 最低强调容器色 |
| 低强调容器色 |
| 默认容器色(导航区域) |
| 高强调容器色 |
| 最高强调容器色 |
| 在亮色/暗色模式下保持相对亮度 |
| 对比元素色(如 Snackbar) |
| 重要边界色(如文本框边框) |
| 装饰元素色(如分割线) |
详细内容:
references/color-system.mdTypography Tokens (--md-sys-typescale-*
)
--md-sys-typescale-*排版令牌(--md-sys-typescale-*
)
--md-sys-typescale-*| Scale | Sizes | Use |
|---|---|---|
| Display | L / M / S | Hero text, large numbers |
| Headline | L / M / S | Section headers |
| Title | L / M / S | Smaller headers, card titles |
| Body | L / M / S | Paragraph text, descriptions |
| Label | L / M / S | Buttons, chips, captions |
Each style has tokens for: , , , ,
Plus 15 emphasized variants (higher weight) via
-font-weight-size-line-height-tracking--md-sys-typescale-emphasized-*Full details:
references/typography-and-shape.md| 层级 | 尺寸 | 用途 |
|---|---|---|
| Display | L / M / S | 英雄文本、大数字 |
| Headline | L / M / S | 章节标题 |
| Title | L / M / S | 小标题、卡片标题 |
| Body | L / M / S | 段落文本、描述内容 |
| Label | L / M / S | 按钮、芯片、说明文字 |
每种样式包含以下令牌:、、、、
另外还有15种强调变体(更粗字重),通过调用
-font-weight-size-line-height-tracking--md-sys-typescale-emphasized-*详细内容:
references/typography-and-shape.mdShape Tokens (--md-sys-shape-corner-*
)
--md-sys-shape-corner-*形状令牌(--md-sys-shape-corner-*
)
--md-sys-shape-corner-*| Token | Value | Example components |
|---|---|---|
| 0dp | — |
| 4dp | Chips, snackbars |
| 8dp | Text fields, menus |
| 12dp | Cards |
| 16dp | FABs, navigation drawer |
| 20dp | (Expressive) |
| 28dp | Dialogs, bottom sheets |
| 32dp | (Expressive) |
| 48dp | (Expressive) |
| 9999px | Buttons, chips, badges |
| 令牌 | 值 | 示例组件 |
|---|---|---|
| 0dp | — |
| 4dp | 芯片、Snackbar |
| 8dp | 文本框、菜单 |
| 12dp | 卡片 |
| 16dp | FAB、导航抽屉 |
| 20dp | (表现力场景) |
| 28dp | 对话框、底部弹窗 |
| 32dp | (表现力场景) |
| 48dp | (表现力场景) |
| 9999px | 按钮、芯片、徽章 |
Elevation Levels
层级级别
| Level | DP | Tonal offset | Use |
|---|---|---|---|
| 0 | 0dp | None | Flat surfaces, most components at rest |
| 1 | 1dp | +5% primary | Elevated cards, modal sheets |
| 2 | 3dp | +8% primary | Menus, nav bar, scrolled app bar |
| 3 | 6dp | +11% primary | FAB, dialogs, search, date/time pickers |
| 4 | 8dp | +12% primary | (hover/focus increase only) |
| 5 | 12dp | +14% primary | (hover/focus increase only) |
Elevation in MD3 is communicated through tonal surface color, not shadows. Shadows are only used when needed for additional protection against busy backgrounds.
| 级别 | DP | 色调偏移 | 用途 |
|---|---|---|---|
| 0 | 0dp | 无 | 平面、静止状态下的大多数组件 |
| 1 | 1dp | +5% 主色 | 悬浮卡片、模态弹窗 |
| 2 | 3dp | +8% 主色 | 菜单、导航栏、滚动应用栏 |
| 3 | 6dp | +11% 主色 | FAB、对话框、搜索、日期/时间选择器 |
| 4 | 8dp | +12% 主色 | (仅用于 hover/focus 状态提升) |
| 5 | 12dp | +14% 主色 | (仅用于 hover/focus 状态提升) |
MD3通过色调化表面颜色传达层级,而非阴影。仅当元素需要与复杂背景额外区分时才使用阴影。
Motion
动效
MD3 Expressive (May 2025) introduced spring-based motion physics for components. The legacy easing/duration system is still used for transitions (enter/exit/shared-axis):
| Easing | Duration | Transition type |
|---|---|---|
| Emphasized | 500ms | Begin and end on screen |
| Emphasized decelerate | 400ms | Enter the screen |
| Emphasized accelerate | 200ms | Exit the screen |
| Standard | 300ms | Begin and end on screen (utility) |
| Standard decelerate | 250ms | Enter screen (utility) |
| Standard accelerate | 200ms | Exit screen (utility) |
CSS easing values:
- Emphasized:
cubic-bezier(0.2, 0, 0, 1) - Emphasized decelerate:
cubic-bezier(0.05, 0.7, 0.1, 1) - Emphasized accelerate:
cubic-bezier(0.3, 0, 0.8, 0.15) - Standard:
cubic-bezier(0.2, 0, 0, 1) - Standard decelerate:
cubic-bezier(0, 0, 0, 1) - Standard accelerate:
cubic-bezier(0.3, 0, 1, 1)
MD3 Expressive(2025年5月)为组件引入了基于弹簧的物理动效。传统的缓动/时长系统仍用于过渡动画(进入/退出/共享轴):
| 缓动类型 | 时长 | 过渡类型 |
|---|---|---|
| Emphasized | 500ms | 元素在屏幕内开始和结束 |
| Emphasized decelerate | 400ms | 元素进入屏幕 |
| Emphasized accelerate | 200ms | 元素退出屏幕 |
| Standard | 300ms | 屏幕内实用型过渡 |
| Standard decelerate | 250ms | 实用型进入过渡 |
| Standard accelerate | 200ms | 实用型退出过渡 |
CSS缓动值:
- Emphasized:
cubic-bezier(0.2, 0, 0, 1) - Emphasized decelerate:
cubic-bezier(0.05, 0.7, 0.1, 1) - Emphasized accelerate:
cubic-bezier(0.3, 0, 0.8, 0.15) - Standard:
cubic-bezier(0.2, 0, 0, 1) - Standard decelerate:
cubic-bezier(0, 0, 0, 1) - Standard accelerate:
cubic-bezier(0.3, 0, 1, 1)
Component Quick Reference
组件速查表
| Component | Web Element | Key Variants | Category |
|---|---|---|---|
| Button | | Filled, Outlined, Text, Elevated, Tonal; 5 sizes (XS–XL); toggle | Actions |
| Button group | | Standard, connected | Actions |
| Extended FAB | | Surface, Primary, Secondary, Tertiary | Actions |
| FAB | | Small, Medium, Large | Actions |
| FAB menu | — | — | Actions |
| Icon button | | Standard, Filled, Filled Tonal, Outlined | Actions |
| Segmented button | — | Single-select, Multi-select | Actions |
| Split button | — | — | Actions |
| Badge | — | Small (dot), Large (count) | Communication |
| Loading indicator | — | Linear, Circular | Communication |
| Progress indicator | | Linear, Circular; determinate/indeterminate | Communication |
| Snackbar | — | Single-line, Two-line, Action | Communication |
| Tooltip | — | Plain, Rich | Communication |
| Card | — | Filled, Outlined, Elevated | Containment |
| Carousel | — | Multi-browse, Uncontained, Hero | Containment |
| Dialog | | Basic, Full-screen | Containment |
| Bottom sheet | — | Standard, Modal | Sheets |
| Side sheet | — | Standard, Modal | Sheets |
| Divider | | Full-width, Inset | Containment |
| Checkbox | | — | Input |
| Chips | | Assist, Filter, Input, Suggestion | Input |
| Date picker | — | Docked, Modal, Range | Input |
| Menu | | — | Input |
| Radio button | | — | Input |
| Slider | | Continuous, Discrete, Range | Input |
| Switch | | With/without icon | Input |
| Text field | | Filled, Outlined | Input |
| Time picker | — | Docked, Modal | Input |
| App bar (top) | — | Center-aligned, Small, Medium, Large | Navigation |
| Navigation bar | | — | Navigation |
| Navigation drawer | | Standard, Modal | Navigation |
| Navigation rail | — | — | Navigation |
| Search | — | Search bar, Search view | Navigation |
| Tabs | | Primary, Secondary | Navigation |
| Toolbar | — | — | Navigation |
| List | | One-line, Two-line, Three-line | Data Display |
Note: Components marked with for web element don't have @material/web implementations yet. Use CSS custom properties with standard HTML for these. Compose mappings and examples live in .
—references/component-catalog.mdFull component details with code examples:
references/component-catalog.md| 组件 | Web元素 | 核心变体 | 分类 |
|---|---|---|---|
| Button | | 填充型、轮廓型、文本型、悬浮型、色调填充型;5种尺寸(XS–XL);切换式 | 操作类 |
| Button group | | 标准型、连接型 | 操作类 |
| Extended FAB | | 表面色、主色、次色、第三色 | 操作类 |
| FAB | | 小、中、大尺寸 | 操作类 |
| FAB menu | — | — | 操作类 |
| Icon button | | 标准型、填充型、色调填充型、轮廓型 | 操作类 |
| Segmented button | — | 单选、多选 | 操作类 |
| Split button | — | — | 操作类 |
| Badge | — | 小型(圆点)、大型(计数) | 通讯类 |
| Loading indicator | — | 线性、圆形 | 通讯类 |
| Progress indicator | | 线性、圆形;确定/不确定状态 | 通讯类 |
| Snackbar | — | 单行、两行、带操作按钮 | 通讯类 |
| Tooltip | — | 普通型、富文本型 | 通讯类 |
| Card | — | 填充型、轮廓型、悬浮型 | 容器类 |
| Carousel | — | 多浏览型、无容器型、英雄型 | 容器类 |
| Dialog | | 基础型、全屏型 | 容器类 |
| Bottom sheet | — | 标准型、模态型 | 弹窗类 |
| Side sheet | — | 标准型、模态型 | 弹窗类 |
| Divider | | 全宽型、缩进型 | 容器类 |
| Checkbox | | — | 输入类 |
| Chips | | 辅助型、筛选型、输入型、建议型 | 输入类 |
| Date picker | — | 停靠型、模态型、范围选择型 | 输入类 |
| Menu | | — | 输入类 |
| Radio button | | — | 输入类 |
| Slider | | 连续型、离散型、范围型 | 输入类 |
| Switch | | 带/不带图标 | 输入类 |
| Text field | | 填充型、轮廓型 | 输入类 |
| Time picker | — | 停靠型、模态型 | 输入类 |
| App bar (top) | — | 居中对齐、小、中、大尺寸 | 导航类 |
| Navigation bar | | — | 导航类 |
| Navigation drawer | | 标准型、模态型 | 导航类 |
| Navigation rail | — | — | 导航类 |
| Search | — | 搜索栏、搜索视图 | 导航类 |
| Tabs | | 主选项卡、次选项卡 | 导航类 |
| Toolbar | — | — | 导航类 |
| List | | 一行、两行、三行 | 数据展示类 |
注意: Web元素列为的组件尚无@material/web实现。可使用CSS自定义属性结合标准HTML实现这些组件。Compose的映射及示例见。
—references/component-catalog.md包含代码示例的完整组件详情:
references/component-catalog.mdJetpack Compose (primary)
Jetpack Compose(核心方案)
Use with and Material 3 composables (, , , top app bars, etc.).
androidx.compose.material3MaterialThemeScaffoldButtonNavigationBar- Theming: . Prefer
MaterialTheme(colorScheme = …, typography = …, shapes = …)/dynamicLightColorSchemeon Android 12+ (API 31+) when dynamic color is desired; otherwisedynamicDarkColorScheme/lightColorSchemeor generated theme code from Material Theme Builder.darkColorScheme - Adaptive UI: Window size classes, list-detail and supporting-pane layouts, foldables — see and
references/layout-and-responsive.md.references/navigation-patterns.md - Edge-to-edge & insets: Lay out content with / scaffold padding so bars and IME behave correctly — see
WindowInsets.references/layout-and-responsive.md - Experimental APIs: Some Material 3 APIs require or expressive opt-ins; match your BOM and compiler.
@OptIn(ExperimentalMaterial3Api::class)
kotlin
MaterialTheme(
colorScheme = colorScheme, // from dynamicLightColorScheme / lightColorScheme / etc.
typography = Typography(),
shapes = Shapes(),
) {
// M3 content — prefer references for Scaffold, navigation, text fields
}使用****结合和Material 3可组合组件(、、、顶部应用栏等)。
androidx.compose.material3MaterialThemeScaffoldButtonNavigationBar- 主题配置:。若需动态色彩,在**Android 12+(API 31+)**上优先使用
MaterialTheme(colorScheme = …, typography = …, shapes = …)/dynamicLightColorScheme;否则使用dynamicDarkColorScheme/lightColorScheme或Material Theme Builder生成的主题代码。darkColorScheme - 自适应UI:窗口尺寸类别、列表-详情布局、辅助面板布局、折叠屏适配——详见和
references/layout-and-responsive.md。references/navigation-patterns.md - 全屏布局与内边距:使用/ 脚手架内边距布局内容,确保状态栏、导航栏及输入法行为正确——详见
WindowInsets。references/layout-and-responsive.md - 实验性API:部分Material 3 API需要添加或表现力相关注解;请匹配对应的BOM和编译器版本。
@OptIn(ExperimentalMaterial3Api::class)
kotlin
MaterialTheme(
colorScheme = colorScheme, // 来自dynamicLightColorScheme / lightColorScheme 等
typography = Typography(),
shapes = Shapes(),
) {
// M3 内容——脚手架、导航、文本框等优先参考官方文档
}Web (limited): @material/web
Web端(受限):@material/web
Important: Per Material Design 3 for Web, Material Web Components are in maintenance mode and M3 Expressive is not implemented on Web. Use for token-backed web UIs when appropriate, but do not treat it as equivalent to Compose for current Expressive features.
@material/web重要提示: 根据Material Design 3 for Web文档,Material Web Components处于维护模式,且M3 Expressive未在Web端实现。在合适场景下可使用构建基于令牌的Web UI,但请勿将其视为与Compose等效的当前表现力特性实现方案。
@material/webSetup
安装
bash
npm install @material/webbash
npm install @material/webImport Components Individually
单独导入组件
Always import only the components you use — importing the entire package bloats the bundle:
javascript
// Good — individual imports
import '@material/web/button/filled-button.js';
import '@material/web/button/outlined-button.js';
import '@material/web/textfield/outlined-text-field.js';
import '@material/web/icon/icon.js';
// Bad — never do this
import '@material/web'; // imports everything始终仅导入所需组件——导入整个包会导致包体积膨胀:
javascript
// 推荐——单独导入
import '@material/web/button/filled-button.js';
import '@material/web/button/outlined-button.js';
import '@material/web/textfield/outlined-text-field.js';
import '@material/web/icon/icon.js';
// 不推荐——绝对不要这样做
import '@material/web'; // 导入所有组件Basic Usage
基础用法
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Symbols+Outlined" rel="stylesheet">
</head>
<body>
<md-filled-button>Get started</md-filled-button>
<md-outlined-text-field label="Email" type="email"></md-outlined-text-field>
<script type="module">
import '@material/web/button/filled-button.js';
import '@material/web/textfield/outlined-text-field.js';
</script>
</body>
</html>html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Symbols+Outlined" rel="stylesheet">
</head>
<body>
<md-filled-button>Get started</md-filled-button>
<md-outlined-text-field label="Email" type="email"></md-outlined-text-field>
<script type="module">
import '@material/web/button/filled-button.js';
import '@material/web/textfield/outlined-text-field.js';
</script>
</body>
</html>Theming with CSS Custom Properties
使用CSS自定义属性配置主题
Apply a custom theme by setting CSS custom properties on or any ancestor:
:rootcss
:root {
/* Color scheme (generate with @material/material-color-utilities) */
--md-sys-color-primary: #6750A4;
--md-sys-color-on-primary: #FFFFFF;
--md-sys-color-primary-container: #EADDFF;
--md-sys-color-on-primary-container: #21005D;
--md-sys-color-secondary: #625B71;
--md-sys-color-on-secondary: #FFFFFF;
--md-sys-color-secondary-container: #E8DEF8;
--md-sys-color-on-secondary-container: #1D192B;
--md-sys-color-surface: #FEF7FF;
--md-sys-color-on-surface: #1D1B20;
--md-sys-color-surface-container: #F3EDF7;
--md-sys-color-outline: #79747E;
--md-sys-color-outline-variant: #CAC4D0;
/* Typography */
--md-sys-typescale-body-large-font: 'Roboto Flex', sans-serif;
--md-sys-typescale-body-large-size: 1rem;
--md-sys-typescale-body-large-weight: 400;
--md-sys-typescale-body-large-line-height: 1.5rem;
/* Shape */
--md-sys-shape-corner-full: 9999px;
--md-sys-shape-corner-medium: 12px;
}通过在或任意父元素上设置CSS自定义属性来应用自定义主题:
:rootcss
:root {
/* 配色方案(使用@material/material-color-utilities生成) */
--md-sys-color-primary: #6750A4;
--md-sys-color-on-primary: #FFFFFF;
--md-sys-color-primary-container: #EADDFF;
--md-sys-color-on-primary-container: #21005D;
--md-sys-color-secondary: #625B71;
--md-sys-color-on-secondary: #FFFFFF;
--md-sys-color-secondary-container: #E8DEF8;
--md-sys-color-on-secondary-container: #1D192B;
--md-sys-color-surface: #FEF7FF;
--md-sys-color-on-surface: #1D1B20;
--md-sys-color-surface-container: #F3EDF7;
--md-sys-color-outline: #79747E;
--md-sys-color-outline-variant: #CAC4D0;
/* 排版 */
--md-sys-typescale-body-large-font: 'Roboto Flex', sans-serif;
--md-sys-typescale-body-large-size: 1rem;
--md-sys-typescale-body-large-weight: 400;
--md-sys-typescale-body-large-line-height: 1.5rem;
/* 形状 */
--md-sys-shape-corner-full: 9999px;
--md-sys-shape-corner-medium: 12px;
}Component-Level Overrides
组件级覆盖
Override individual component tokens for specific customization:
css
md-filled-button {
--md-filled-button-container-color: var(--md-sys-color-primary);
--md-filled-button-label-text-color: var(--md-sys-color-on-primary);
--md-filled-button-container-shape: var(--md-sys-shape-corner-full);
--md-filled-button-container-height: 40px;
}
md-outlined-text-field {
--md-outlined-text-field-container-shape: var(--md-sys-shape-corner-small);
--md-outlined-text-field-focus-outline-color: var(--md-sys-color-primary);
}针对特定组件覆盖令牌以实现自定义:
css
md-filled-button {
--md-filled-button-container-color: var(--md-sys-color-primary);
--md-filled-button-label-text-color: var(--md-sys-color-on-primary);
--md-filled-button-container-shape: var(--md-sys-shape-corner-full);
--md-filled-button-container-height: 40px;
}
md-outlined-text-field {
--md-outlined-text-field-container-shape: var(--md-sys-shape-corner-small);
--md-outlined-text-field-focus-outline-color: var(--md-sys-color-primary);
}Dark Theme
暗色主题
Apply dark theme by overriding color tokens on a class or media query:
css
@media (prefers-color-scheme: dark) {
:root {
--md-sys-color-primary: #D0BCFF;
--md-sys-color-on-primary: #381E72;
--md-sys-color-primary-container: #4F378B;
--md-sys-color-on-primary-container: #EADDFF;
--md-sys-color-surface: #141218;
--md-sys-color-on-surface: #E6E0E9;
--md-sys-color-surface-container: #211F26;
--md-sys-color-outline: #938F99;
--md-sys-color-outline-variant: #49454F;
}
}Full theming guide:
references/theming-and-dynamic-color.md通过类选择器或媒体查询覆盖色彩令牌来应用暗色主题:
css
@media (prefers-color-scheme: dark) {
:root {
--md-sys-color-primary: #D0BCFF;
--md-sys-color-on-primary: #381E72;
--md-sys-color-primary-container: #4F378B;
--md-sys-color-on-primary-container: #EADDFF;
--md-sys-color-surface: #141218;
--md-sys-color-on-surface: #E6E0E9;
--md-sys-color-surface-container: #211F26;
--md-sys-color-outline: #938F99;
--md-sys-color-outline-variant: #49454F;
}
}完整主题配置指南:
references/theming-and-dynamic-color.mdCommon Patterns
通用模式
App Shell
应用框架
Standard MD3 app with responsive navigation + top app bar + content area:
html
<div class="md3-app">
<nav class="md3-nav-rail" aria-label="Main navigation">
<!-- Navigation rail for medium+ screens -->
<md-fab size="small" aria-label="Compose">
<md-icon slot="icon">edit</md-icon>
</md-fab>
<md-navigation-bar>
<md-navigation-tab label="Home">
<md-icon slot="active-icon">home</md-icon>
<md-icon slot="inactive-icon">home</md-icon>
</md-navigation-tab>
<md-navigation-tab label="Search">
<md-icon slot="active-icon">search</md-icon>
<md-icon slot="inactive-icon">search</md-icon>
</md-navigation-tab>
</md-navigation-bar>
</nav>
<main class="md3-content">
<header class="md3-top-app-bar">
<h1 class="md3-top-app-bar__title" style="font: var(--md-sys-typescale-title-large)">
Page Title
</h1>
</header>
<div class="md3-body">
<!-- Content here -->
</div>
</main>
</div>css
.md3-app {
display: flex;
min-height: 100vh;
background: var(--md-sys-color-surface);
color: var(--md-sys-color-on-surface);
}
.md3-nav-rail {
width: 80px;
background: var(--md-sys-color-surface);
border-right: 1px solid var(--md-sys-color-outline-variant);
display: flex;
flex-direction: column;
align-items: center;
padding-top: 12px;
gap: 12px;
}
.md3-content {
flex: 1;
display: flex;
flex-direction: column;
}
.md3-top-app-bar {
height: 64px;
padding: 0 16px;
display: flex;
align-items: center;
background: var(--md-sys-color-surface);
}
.md3-body {
padding: 24px;
flex: 1;
}
/* Responsive: switch to bottom nav on compact */
@media (max-width: 599px) {
.md3-app { flex-direction: column; }
.md3-nav-rail {
order: 1;
width: 100%;
flex-direction: row;
justify-content: center;
border-right: none;
border-top: 1px solid var(--md-sys-color-outline-variant);
padding: 0;
}
}带响应式导航+顶部应用栏+内容区域的标准MD3应用:
html
<div class="md3-app">
<nav class="md3-nav-rail" aria-label="Main navigation">
<!-- 中等尺寸以上屏幕使用导航栏 -->
<md-fab size="small" aria-label="Compose">
<md-icon slot="icon">edit</md-icon>
</md-fab>
<md-navigation-bar>
<md-navigation-tab label="Home">
<md-icon slot="active-icon">home</md-icon>
<md-icon slot="inactive-icon">home</md-icon>
</md-navigation-tab>
<md-navigation-tab label="Search">
<md-icon slot="active-icon">search</md-icon>
<md-icon slot="inactive-icon">search</md-icon>
</md-navigation-tab>
</md-navigation-bar>
</nav>
<main class="md3-content">
<header class="md3-top-app-bar">
<h1 class="md3-top-app-bar__title" style="font: var(--md-sys-typescale-title-large)">
Page Title
</h1>
</header>
<div class="md3-body">
<!-- 内容区域 -->
</div>
</main>
</div>css
.md3-app {
display: flex;
min-height: 100vh;
background: var(--md-sys-color-surface);
color: var(--md-sys-color-on-surface);
}
.md3-nav-rail {
width: 80px;
background: var(--md-sys-color-surface);
border-right: 1px solid var(--md-sys-color-outline-variant);
display: flex;
flex-direction: column;
align-items: center;
padding-top: 12px;
gap: 12px;
}
.md3-content {
flex: 1;
display: flex;
flex-direction: column;
}
.md3-top-app-bar {
height: 64px;
padding: 0 16px;
display: flex;
align-items: center;
background: var(--md-sys-color-surface);
}
.md3-body {
padding: 24px;
flex: 1;
}
/* 响应式:紧凑屏幕切换为底部导航 */
@media (max-width: 599px) {
.md3-app { flex-direction: column; }
.md3-nav-rail {
order: 1;
width: 100%;
flex-direction: row;
justify-content: center;
border-right: none;
border-top: 1px solid var(--md-sys-color-outline-variant);
padding: 0;
}
}Card Grid
卡片网格
html
<div class="md3-card-grid">
<div class="md3-card md3-card--outlined">
<img src="image.jpg" alt="Description" class="md3-card__media">
<div class="md3-card__content">
<h3 style="font: var(--md-sys-typescale-title-medium)">Card Title</h3>
<p style="font: var(--md-sys-typescale-body-medium); color: var(--md-sys-color-on-surface-variant)">
Supporting text for this card.
</p>
</div>
<div class="md3-card__actions">
<md-text-button>Learn more</md-text-button>
<md-filled-tonal-button>Action</md-filled-tonal-button>
</div>
</div>
</div>css
.md3-card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 16px;
}
.md3-card--outlined {
border: 1px solid var(--md-sys-color-outline-variant);
border-radius: var(--md-sys-shape-corner-medium, 12px);
background: var(--md-sys-color-surface);
overflow: hidden;
}
.md3-card__content { padding: 16px; }
.md3-card__actions { padding: 8px 16px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.md3-card__media { width: 100%; aspect-ratio: 16/9; object-fit: cover; }html
<div class="md3-card-grid">
<div class="md3-card md3-card--outlined">
<img src="image.jpg" alt="Description" class="md3-card__media">
<div class="md3-card__content">
<h3 style="font: var(--md-sys-typescale-title-medium)">Card Title</h3>
<p style="font: var(--md-sys-typescale-body-medium); color: var(--md-sys-color-on-surface-variant)">
Supporting text for this card.
</p>
</div>
<div class="md3-card__actions">
<md-text-button>Learn more</md-text-button>
<md-filled-tonal-button>Action</md-filled-tonal-button>
</div>
</div>
</div>css
.md3-card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 16px;
}
.md3-card--outlined {
border: 1px solid var(--md-sys-color-outline-variant);
border-radius: var(--md-sys-shape-corner-medium, 12px);
background: var(--md-sys-color-surface);
overflow: hidden;
}
.md3-card__content { padding: 16px; }
.md3-card__actions { padding: 8px 16px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.md3-card__media { width: 100%; aspect-ratio: 16/9; object-fit: cover; }Form Layout
表单布局
html
<form class="md3-form">
<md-outlined-text-field label="Full name" required></md-outlined-text-field>
<md-outlined-text-field label="Email" type="email" required></md-outlined-text-field>
<md-outlined-text-field label="Message" type="textarea" rows="4"></md-outlined-text-field>
<div class="md3-form__actions">
<md-text-button type="reset">Cancel</md-text-button>
<md-filled-button type="submit">Submit</md-filled-button>
</div>
</form>css
.md3-form {
display: flex;
flex-direction: column;
gap: 16px;
max-width: 560px;
}
.md3-form__actions {
display: flex;
gap: 8px;
justify-content: flex-end;
margin-top: 8px;
}More patterns: ,
references/navigation-patterns.mdreferences/layout-and-responsive.mdhtml
<form class="md3-form">
<md-outlined-text-field label="Full name" required></md-outlined-text-field>
<md-outlined-text-field label="Email" type="email" required></md-outlined-text-field>
<md-outlined-text-field label="Message" type="textarea" rows="4"></md-outlined-text-field>
<div class="md3-form__actions">
<md-text-button type="reset">Cancel</md-text-button>
<md-filled-button type="submit">Submit</md-filled-button>
</div>
</form>css
.md3-form {
display: flex;
flex-direction: column;
gap: 16px;
max-width: 560px;
}
.md3-form__actions {
display: flex;
gap: 8px;
justify-content: flex-end;
margin-top: 8px;
}更多模式:、
references/navigation-patterns.mdreferences/layout-and-responsive.mdAnti-Patterns
反模式
Never do these when implementing MD3:
- Mix MD2 and MD3 libraries: Don't use (MD2) alongside
@material/mdc-*(MD3). They have incompatible APIs and styling.@material/web - Hardcode colors: Always use tokens, never raw hex/rgb values. Hardcoded colors break dynamic theming, dark mode, and contrast adjustment.
var(--md-sys-color-*) - Ignore tonal pairing: Only combine colors in their intended pairs (e.g., +
primary,on-primary+surface-container). Arbitrary pairings break contrast in dynamic color and high contrast modes.on-surface - Use for dividers: Use
outlinefor dividers.outline-variantis for important boundaries like text field borders.outline - Import all of @material/web: Always import individual component modules. Barrel imports include every component and destroy bundle size.
- Use directly: Use shape tokens (
border-radius) so shapes stay consistent with theming.var(--md-sys-shape-corner-medium) - Use shadows for elevation by default: MD3 communicates elevation through tonal surface color, not shadows. Only add shadows when elements need extra separation from busy backgrounds.
- Apply frontend-design "avoid Roboto" rule: On Android, Roboto is the default Material typeface; web often uses Roboto or Roboto Flex with MD3 tokens. Replace only when intentionally customizing the type scale.
- Assume SSR compatibility: uses Web Components (custom elements) which require JavaScript to render. They won't produce meaningful HTML in SSR without additional hydration strategies.
@material/web - Ignore foldables and large screens: MD3 is designed for all screen sizes. Don't ship phone-only layouts — use canonical layouts, multi-pane at 600dp+, and test on foldable/tablet emulators. Place no interactive content across the fold/hinge.
- Stretch content to fill wide screens: On Large (1200dp+) and Extra-large (1600dp+) windows, constrain content to a max width (840–1040dp). Endless-width text lines are unreadable.
实现MD3时绝对不要做以下这些事:
- 混用MD2与MD3库:不要同时使用(MD2)和
@material/mdc-*(MD3)。二者的API和样式互不兼容。@material/web - 硬编码颜色:始终使用令牌,绝对不要使用原始十六进制/RGB值。硬编码颜色会破坏动态主题、暗色模式及对比度调整功能。
var(--md-sys-color-*) - 忽略色调配对:仅使用指定的颜色配对组合(如+
primary、on-primary+surface-container)。随意配对会在动态色彩和高对比度模式下破坏可读性。on-surface - 用作为分割线:分割线应使用
outline。outline-variant用于重要边界,如文本框边框。outline - 导入整个@material/web包:始终单独导入组件模块。整体导入会包含所有组件,导致包体积急剧增大。
- 直接使用:使用形状令牌(
border-radius),确保形状与主题保持一致。var(--md-sys-shape-corner-medium) - 默认用阴影表示层级:MD3通过色调化表面颜色传达层级,而非阴影。仅当元素需要与复杂背景额外区分时才添加阴影。
- 遵循前端设计的“避免使用Roboto”规则:在Android上,Roboto是Material的默认字体;Web端通常在MD3令牌中使用Roboto或Roboto Flex。仅在有意自定义排版层级时才替换字体。
- 假设支持SSR:使用Web Components(自定义元素),需要JavaScript才能渲染。若无额外的水合策略,它们在SSR中无法生成有意义的HTML。
@material/web - 忽略折叠屏和大屏幕:MD3专为所有屏幕尺寸设计。不要只发布手机端布局——使用标准布局,在600dp+尺寸下使用多面板布局,并在折叠屏/平板模拟器上测试。不要在折叠铰链区域放置可交互内容。
- 拉伸内容以填充宽屏:在大尺寸(1200dp+)和超大尺寸(1600dp+)窗口中,将内容限制在最大宽度(840–1040dp)。无限宽度的文本行难以阅读。
Platform Notes
平台注意事项
Flutter
Flutter
dart
MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
);dart
MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
);Jetpack Compose
Jetpack Compose
See Jetpack Compose (primary) above. Use with / only when and dynamic color is enabled; otherwise supply static light/dark schemes.
LocalContext.currentdynamicLightColorSchemedynamicDarkColorSchemeBuild.VERSION.SDK_INT >= Build.VERSION_CODES.S详见上方**Jetpack Compose(核心方案)**。仅当且启用动态色彩时,才使用结合 / ;否则提供静态亮色/暗色配色方案。
Build.VERSION.SDK_INT >= Build.VERSION_CODES.SLocalContext.currentdynamicLightColorSchemedynamicDarkColorSchemeComponent Name Mapping
组件名称映射
| Concept | Web | Flutter | Compose |
|---|---|---|---|
| Filled button | | | |
| Outlined text field | | | |
| FAB | | | |
| Navigation bar | | | |
| Switch | | | |
| 概念 | Web端 | Flutter | Jetpack Compose |
|---|---|---|---|
| 填充按钮 | | | |
| 轮廓文本框 | | | |
| FAB | | | |
| 导航栏 | | | |
| 开关 | | | |
M3 Expressive (May 2025)
M3 Expressive(2025年5月更新)
The Expressive update adds visual richness while maintaining usability. Availability differs by platform — do not assume one stack implements everything.
| Capability | Jetpack Compose | Flutter | Web ( |
|---|---|---|---|
| Expressive layout scaffold / adaptive layout | Compose-first via Material3 adaptive APIs and window size classes | Use Flutter adaptive/layout primitives | CSS/container queries/manual layout; no Material Web parity |
| 8dp spacing system | Use design tokens / | Use theme spacing constants | CSS custom properties / design tokens |
| Expressive lists, menus, search, search app bar | Primary target per current Material guidance; check BOM and opt-ins | Check current Flutter Material docs | Spec-aligned custom implementation; |
| Spring / motion physics | Supported in Material 3 (see | Varies by Flutter Material version | Not in Material Web; use easing/duration or custom motion |
| Emphasized typography | Via theme / type scale | Via theme | Token/CSS only; no full Expressive component set |
| Shape morphing | Compose-first in Google’s expressive rollout | Check current Flutter docs | Not in |
| New button sizes (XS–XL), toggle | Follow Compose Material3 components | Follow Flutter MD3 | Height/CSS approximations only |
| Extra corner tokens (e.g. large-increased) | | Theme shapes | CSS |
| 3 contrast levels | Scheme builders / system | Plugins / manual | |
| Watches / XR form factors | Use Compose/Wear/XR-specific guidance where available | Platform-specific | Web/spatial UI custom implementation |
Web: Material Web is maintenance-only; M3 Expressive is not on Web. Use CSS easing/duration tokens as fallback for motion, not spring parity.
Legacy easing/duration remains valid for transitions (enter/exit/shared-axis) where the spec still references them; see the Motion table below.
Expressive更新在保持可用性的同时增加了视觉丰富度。各平台支持情况不同——不要假设所有技术栈都实现了所有功能。
| 功能特性 | Jetpack Compose | Flutter | Web( |
|---|---|---|---|
| 表现力布局脚手架/自适应布局 | 通过Material3自适应API和窗口尺寸类别优先支持 | 使用Flutter自适应/布局原语 | CSS/容器查询/手动布局;无Material Web对等实现 |
| 8dp间距系统 | 使用设计令牌/ | 使用主题间距常量 | CSS自定义属性/设计令牌 |
| 表现力列表、菜单、搜索、搜索应用栏 | 是当前Material指导的主要目标;请检查BOM和注解 | 查看当前Flutter Material文档 | 符合规范的自定义实现; |
| 弹簧/物理动效 | Material 3支持(见 | 取决于Flutter Material版本 | 未在Material Web中实现;使用缓动/时长或自定义动效 |
| 强调式排版 | 通过主题/排版层级实现 | 通过主题实现 | 仅支持令牌/CSS;无完整表现力组件集 |
| 形状变形 | Google表现力更新中优先支持Compose | 查看当前Flutter文档 | 未在 |
| 新增按钮尺寸(XS–XL)、切换式 | 遵循Compose Material3组件 | 遵循Flutter MD3 | 仅支持高度/CSS近似实现 |
| 额外圆角令牌(如large-increased) | | 主题形状 | CSS |
| 3种对比度级别 | 配色方案构建器/系统支持 | 插件/手动配置 | JS工具中的 |
| 手表/XR形态设备 | 使用Compose/Wear/XR专属指导(若有) | 平台专属实现 | Web/空间UI自定义实现 |
Web端: Material Web处于维护模式;M3 Expressive未在Web端实现。使用CSS缓动/时长令牌作为动效 fallback,不要追求弹簧动效的一致性。
传统缓动/时长在规范仍引用的过渡动画(进入/退出/共享轴)中依然有效;详见下方动效表格。
MD3 Compliance Audit
MD3合规性审计
When invoked with as the argument (e.g., ), or when asked to audit/review MD3 compliance, analyze the target app or page and produce a compliance report.
audit/material-3 audit当以为参数调用时(例如),或被要求审计/审查MD3合规性时,分析目标应用或页面并生成合规性报告。
audit/material-3 auditAudit Procedure
审计流程
- Identify the target: The user provides a URL (use browser tools to inspect), file paths (read source), or a running app.
- Inspect the following categories and score each 0–10:
| Category | What to check |
|---|---|
| Color tokens | Web: |
| Typography | MD3 type scale: Compose |
| Shape | Compose |
| Elevation | Tonal elevation ( |
| Components | Compose: Material3 composables ( |
| Layout | Canonical layouts; Compose window size class / adaptive APIs; readable max width on large widths; foldable hinge avoidance. |
| Navigation | Bar / rail / drawer / drawers+Compose |
| Motion | Compose |
| Accessibility | MD3 roles help, but verify contrast: UI components often need 3:1 for large text/borders and 4.5:1 for normal text (WCAG 2.x). TalkBack/semantics (Compose), focus order, touch targets (~48dp). Web: ARIA, keyboard. |
| Theming | Compose: |
- Generate the report:
undefined- 确定目标:用户提供URL(使用浏览器工具检查)、文件路径(读取源码)或运行中的应用。
- 检查以下类别,每项评分0–10:
| 类别 | 检查内容 |
|---|---|
| 色彩令牌 | Web端: |
| 排版 | MD3排版层级:Compose |
| 形状 | Compose |
| 层级 | 色调化层级( |
| 组件 | Compose: Material3可组合组件( |
| 布局 | 标准布局;Compose窗口尺寸类别/自适应API;大尺寸下的可读最大宽度;折叠屏铰链避让。 |
| 导航 | 底部栏/侧边栏/抽屉/Compose |
| 动效 | Compose 使用 |
| 无障碍适配 | MD3角色有帮助,但需验证对比度:UI组件通常需要大文本/边框达到3:1,普通文本达到4.5:1(WCAG 2.x)。TalkBack/语义化(Compose)、焦点顺序、触摸目标(约48dp)。Web端: ARIA、键盘导航。 |
| 主题配置 | Compose: |
- 生成报告:
undefinedMD3 Compliance Audit Report
MD3合规性审计报告
Target: [URL or file path]
Date: [date]
Overall Score: [X/100]
目标: [URL或文件路径]
日期: [日期]
总分: [X/100]
Scores by Category
各类别评分
| Category | Score | Status |
|---|---|---|
| Color tokens | X/10 | [pass/warn/fail] |
| Typography | X/10 | [pass/warn/fail] |
| Shape | X/10 | [pass/warn/fail] |
| Elevation | X/10 | [pass/warn/fail] |
| Components | X/10 | [pass/warn/fail] |
| Layout | X/10 | [pass/warn/fail] |
| Navigation | X/10 | [pass/warn/fail] |
| Motion | X/10 | [pass/warn/fail] |
| Accessibility | X/10 | [pass/warn/fail] |
| Theming | X/10 | [pass/warn/fail] |
| 类别 | 得分 | 状态 |
|---|---|---|
| 色彩令牌 | X/10 | [通过/警告/失败] |
| 排版 | X/10 | [通过/警告/失败] |
| 形状 | X/10 | [通过/警告/失败] |
| 层级 | X/10 | [通过/警告/失败] |
| 组件 | X/10 | [通过/警告/失败] |
| 布局 | X/10 | [通过/警告/失败] |
| 导航 | X/10 | [通过/警告/失败] |
| 动效 | X/10 | [通过/警告/失败] |
| 无障碍适配 | X/10 | [通过/警告/失败] |
| 主题配置 | X/10 | [通过/警告/失败] |
Critical Issues
严重问题
[List items scoring 0-3 with specific file:line references and fixes]
[列出得分0-3的项,包含具体文件:行号参考及修复方案]
Warnings
警告
[List items scoring 4-6 with recommendations]
[列出得分4-6的项及建议]
Passing
通过项
[List items scoring 7-10 with notes on what's done well]
[列出得分7-10的项及做得好的地方说明]
Recommended Fixes (Priority Order)
推荐修复方案(优先级排序)
- [Most impactful fix first]
- ...
undefined- [影响最大的修复方案优先]
- ...
undefinedAudit Methods
审计方法
For a live URL (browser or devtools):
- Inspect computed styles and CSS variables ()
--md-sys-* - Resize viewport or use responsive mode for breakpoints
- Capture screenshots at key widths if helpful
For source code (file paths provided):
- Compose/Kotlin: files —
.kt, composables,MaterialThemeabuse, hard-codedColor(0x…), missingDpwhere neededModifier.semantics - Flutter: —
.dart,ThemeDataColorScheme - Web: HTML/JSX/Vue/Svelte; CSS/SCSS for tokens
- Check web imports for vs
@material/web(MD2)@material/mdc-*
Quick checks (adapt paths to your stack):
undefined针对在线URL(浏览器或开发者工具):
- 检查计算样式和CSS变量()
--md-sys-* - 调整视口大小或使用响应式模式查看断点
- 必要时在关键宽度下截图
针对源码(提供文件路径):
- Compose/Kotlin: 文件——
.kt、可组合组件、滥用MaterialTheme、硬编码Color(0x…)、必要时缺失DpModifier.semantics - Flutter: 文件——
.dart、ThemeDataColorScheme - Web端: HTML/JSX/Vue/Svelte;CSS/SCSS中的令牌
- 检查Web端导入的是还是
@material/web(MD2)@material/mdc-*
快速检查(根据技术栈调整路径):
undefinedWeb: hardcoded colors
Web端:硬编码颜色
grep -rn '#[0-9a-fA-F]{3,8}' --include='.css' --include='.scss'
grep -rn '#[0-9a-fA-F]{3,8}' --include='.css' --include='.scss'
Compose: raw Color(...) audits (sample — tune for your codebase)
Compose:原始Color(...)审计(示例——根据代码库调整)
grep -rn 'Color(0x' --include='*.kt'
grep -rn 'Color(0x' --include='*.kt'
MD2 on web
Web端使用MD2
grep -rn '@material/mdc-' --include='.js' --include='.ts'
**Browser automation** (if your environment exposes MCP browser tools): navigate, snapshot DOM/CSS variables, resize for breakpoints — optional, not required.grep -rn '@material/mdc-' --include='.js' --include='.ts'
**浏览器自动化**(若环境提供MCP浏览器工具):导航、快照DOM/CSS变量、调整断点大小——可选,非必需。Scoring Guide
评分指南
- 9-10: Fully MD3 compliant, uses correct tokens and patterns
- 7-8: Mostly compliant, minor issues (e.g., a few hardcoded values)
- 4-6: Partially compliant, some MD3 patterns but significant gaps
- 1-3: Major violations, mostly non-MD3 or MD2 patterns
- 0: Not applicable or completely absent
Status thresholds: pass (7+), warn (4-6), fail (0-3)
- 9-10:完全符合MD3规范,使用正确的令牌和模式
- 7-8:基本符合,存在轻微问题(如少量硬编码值)
- 4-6:部分符合,使用了一些MD3模式但存在显著差距
- 1-3:严重违规,主要使用非MD3或MD2模式
- 0:不适用或完全未使用MD3
状态阈值:通过(7+)、警告(4-6)、失败(0-3)
Reference Documents
参考文档
- — Color roles, tonal palettes, dynamic color, Compose + CSS mapping
references/color-system.md - — Type scale, shape corners, elevation, motion, Expressive notes
references/typography-and-shape.md - — Components: Compose +
references/component-catalog.mdwhere applicable@material/web - — Navigation selection, Compose-first adaptive patterns
references/navigation-patterns.md - — Breakpoints, canonical layouts, insets, foldables
references/layout-and-responsive.md - — Theming: Compose first, then Flutter and web
references/theming-and-dynamic-color.md
- — 色彩角色、色调调色板、动态色彩、Compose与CSS映射
references/color-system.md - — 排版层级、圆角形状、层级、动效、Expressive说明
references/typography-and-shape.md - — 组件:Compose + 适用的
references/component-catalog.md实现@material/web - — 导航选型、Compose优先的自适应模式
references/navigation-patterns.md - — 断点、标准布局、内边距、折叠屏适配
references/layout-and-responsive.md - — 主题配置:优先Compose,其次Flutter和Web端
references/theming-and-dynamic-color.md