-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Migration guide for M3 token update #11480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/content/release/breaking-changes/material-design-3-token-update.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
title: Material 3 Tokens Update in Flutter | ||
description: >- | ||
The latest Material Design 3 tokens(v6.1) have been applied to the Flutter | ||
Material library. | ||
--- | ||
|
||
## Summary | ||
|
||
The Material Design tokens updated the mapping of 4 color roles (only in Light | ||
mode) to be more visually appealing while retaining accessible contrast. Testing | ||
identified this change as [non-breaking] in Flutter, but some customers might | ||
notice this small change. The update affected the following color properties: | ||
|
||
* On-primary-container (Primary10 to Primary30) | ||
* On-secondary-container (Secondary10 to Secondary30) | ||
* On-tertiary-container (Tertiary10 to Tertiary30) | ||
* On-error-container (Error10 to Error30) | ||
|
||
Widgets that have been using these roles with their default value might look | ||
different. | ||
|
||
Additionally, the Material 3 tokens updated the border color of Chips from | ||
`ColorScheme.outline` to `ColorScheme.outlineVariant` to improve visual | ||
hierarchy between chips and buttons. Chips (`Chip`, `ActionChip`, `ChoiceChip`, | ||
`FilterChip`, and `InputChip`) that have been using the chip border tokens may | ||
look different. | ||
|
||
## Migration guide | ||
|
||
The differences in the mappings of the color roles are small. Use | ||
`ColorScheme.copyWith` to revert to the original default colors: | ||
|
||
Code before migration: | ||
|
||
```dart | ||
final ColorScheme colors = ThemeData().colorScheme; | ||
``` | ||
|
||
Code after migration: | ||
|
||
```dart | ||
final ColorScheme colors = ThemeData().colorScheme.copyWith( | ||
onPrimaryContainer: const Color(0xFF21005D), | ||
onSecondaryContainer: const Color(0xFF1D192B), | ||
onTertiaryContainer: const Color(0xFF31111D), | ||
onErrorContainer: const Color(0xFF410E0B), | ||
); | ||
``` | ||
|
||
After applying the token update, the default border color of M3 chips looks | ||
lighter. Take `ActionChip` as an example: | ||
|
||
Code before migration: | ||
|
||
```dart | ||
final Widget chip = ActionChip( | ||
label: const Text('action chip'), | ||
onPressed: () {}, | ||
); | ||
``` | ||
|
||
Code after migration: | ||
|
||
```dart | ||
final Widget chip = ChipTheme( | ||
data: ChipThemeData( | ||
side: BorderSide( | ||
color: Theme.of(context).colorScheme.outline | ||
), | ||
), | ||
child: ActionChip( | ||
label: const Text('action chip'), | ||
onPressed: () {} | ||
) | ||
); | ||
``` | ||
|
||
## Timeline | ||
|
||
Landed in version: 3.26.0-0.0.pre<br> | ||
In stable release: not yet | ||
|
||
## References | ||
|
||
API documentation: | ||
|
||
* [`ColorScheme`][] | ||
* [`ThemeData`][] | ||
* [`Chip`][] | ||
|
||
Relevant PRs: | ||
|
||
* [Update tokens to v5.0.0][] | ||
* [Update tokens to v6.1.0][] | ||
|
||
[`ColorScheme`]: {{site.api}}/flutter/material/ColorScheme-class.html | ||
[`ThemeData`]: {{site.api}}/flutter/material/ThemeData-class.html | ||
[`Chip`]: {{site.api}}/flutter/material/Chip-class.html | ||
[Update tokens to v5.0.0]: {{site.repo.flutter}}/pull/153385 | ||
[Update tokens to v6.1.0]: {{site.repo.flutter}}/pull/153722 | ||
[non-breaking]: {{site.repo.flutter}}/flutter/blob/master/docs/contributing/Tree-hygiene.md#1-determine-if-your-change-is-a-breaking-change |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to include some API references like in other migration guides. ColorScheme, Theme, and Chip classes look relevant to include here.