-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Support tone-based surface and surface container ColorScheme
roles
#115912
Comments
ColorScheme
roles
Tokens are now available for this. It's important to note the updates above are part of version 162 and represent a breaking change corresponding that will need to be carefully prepared. Googlers, see g/material-tokens-announce for more info. |
ColorScheme
rolesColorScheme
roles
For anyone looking for a workaround until this gets integrated into Flutter. You can generate these colors using the material_color_utilites package. Change the tone of a color Hct toneColor = Hct.fromInt(Colors.red.value); // Hct.fromInt(0xFF4285F4)
toneColor.tone = 10;
Color result = Color(toneColor.toInt()); Some quick and dirty code to generate these colors from a seed color: static Color seedColor = Colors.red;
static Color getSurface(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 6 : 98));
}
static Color getSurfaceDim(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 6 : 87));
}
static Color getSurfaceBright(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 24 : 98));
}
static Color getSurfaceContainerLowest(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 4 : 100));
}
static Color getSurfaceContainerLow(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 10 : 96));
}
static Color getSurfaceContainer(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 12 : 94));
}
static Color getSurfaceContainerHigh(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 17 : 92));
}
static Color getSurfaceContainerHighest(bool darkMode) {
CorePalette p = CorePalette.of(seedColor.value);
return Color(p.neutral.get(darkMode ? 22 : 90));
}
|
Is there expected timelines when this will be available? |
Any updates? |
These changes appear to be part of a wider set of updates to the color system, see this. DetailsAddedThe following color roles have been added. See: https://m3.material.io/styles/color/the-color-system/color-roles:
New fixed accent colors have also been introduced (see #137683). Changed
DeprecatedThe following color roles are marked as legacy/deprecated:
As stated here:
The "On background" and "Surface Variant" roles still exist in the list of tokens but are not shown as part of the color scheme and possibly will be deprecated soon. |
Currently, Flutter generates the Material 3 color schemes using However, it appears that the |
CC @QuncCccccc, @Piinks |
Hi, is there an update on this? Will the flutter ColorScheme class be extended with the different Surface color roles, enabling static setting and fine graded impact on these? |
I created an extension of BuildContext to get all the colors from DynamicScheme, using the material_color_utilites package, just in case it is useful to anyone
|
any updates? |
#138521 will be merged soon! |
#144805 adds an enhancement for ColorScheme.fromSeed() so when we input a brighter color with a high chroma and we want the resulting |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Guidelines: https://m3.material.io/styles/color/the-color-system/color-roles#0abbf8b7-61e1-49ee-9f97-4967beb1e4fe
New tone-based colors will replace the existing surface roles. The updated roles remove the use of opacity overlays and thus of surface tint colors. The updated roles are also no longer tied to elevation, offering more flexibility for large screens, and support for future feature development including global user-controlled contrast and color fidelity. Material recommends teams accept these updates across code, tokens, and figma.
The following diagram shows the recommended approach to remapping from the old to the new surfaces.
Google issue b/266528810 and Google-internal Material Design rationale with FAQ
The text was updated successfully, but these errors were encountered: