Skip to content
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

Option to stay true to source color #15

Open
JimVanEeden opened this issue Jul 24, 2024 · 7 comments · May be fixed by #17
Open

Option to stay true to source color #15

JimVanEeden opened this issue Jul 24, 2024 · 7 comments · May be fixed by #17
Labels
enhancement New feature or request

Comments

@JimVanEeden
Copy link

Is there a plan to support the following option as can be seen at https://material-foundation.github.io/material-theme-builder/?

image

For my app it would be great to supply a theme color and have that being used as primary color as well. Apparently the color library does support that as it's an option in the theme builder. For now I'm overriding the primary color manually, but as can be seen, some other colors change as well when you enable the option.

Support for this option would be very much appreciated! Thanks

@pchmn
Copy link
Owner

pchmn commented Jul 26, 2024

Yes it seems to be called "color fidelity" (https://m3.material.io/styles/color/advanced/adjust-existing-colors#cb49eeb4-3bbd-4521-9612-0856c27f91ef), and @material/material-color-utilities supports it in last versions apparently.

I'll look into it !

@pchmn pchmn added the enhancement New feature or request label Jul 26, 2024
@pchmn pchmn linked a pull request Nov 22, 2024 that will close this issue
@pchmn
Copy link
Owner

pchmn commented Nov 22, 2024

Sorry for the delay, but you can try beta version @pchmn/[email protected] with color fidelity option:

const { theme, updateTheme } = useMaterial3Theme({ sourceColor: '#3E8260', colorFidelity: true });
// ...
updateTheme('#3E8260', { colorFidelity: true });

Tell me if it works for you, and I'll published it under stable version !

@pchmn
Copy link
Owner

pchmn commented Dec 6, 2024

@JimVanEeden did you have time to test it ?

@JimVanEeden
Copy link
Author

Thanks a lot for the effort! I'm excited to try it out, however I don't think I'll be touching the app for a couple of weeks, so I will post the update later. Of course if anybody else tries it out in the meantime, please let us know :)

@Neyxo
Copy link

Neyxo commented Jan 25, 2025

I just tried it out my first impression was: works great!

However:
The reason I wanted to try it is, that I noticed that for some colors (especially vibrant ones like orange), it does not match the source color at all and thought the color fidelity option might solve that.

While the option makes the primaryContainer close to the source, upon closer testing I noticed two things:

  • It makes primary and secondary colors super close together, kinda defeats having a secondary at all
  • The tertiary color is now completely different and in some cases a bit agressive

But if I understood it correctly the colors come mostly from @material/material-color-utilities?
Also I'm not sure if this is actually working as intended and I'm just misunderstanding/disagreeing with the Material design color standard.

Here some examples of the same color with / without the color fidelity setting:

Image Image Image Image Image Image

@Neyxo
Copy link

Neyxo commented Jan 25, 2025

So I've tried to debug this a bit, since the colors also seem to mismatch the one from the material-theme-builder. Unfortunately their code seems to be closed source.
I guess its either an upstream issue in the typescript variant of @material/material-color-utilities (material-theme-builder is apparently written in Dart). Or, more likely, material-theme-builder does some custom magic.
I for myself will probably continue to use the normal mode and just override the primaryContainer color manually, since thats close enough to what I need.

@pchmn
Copy link
Owner

pchmn commented Jan 27, 2025

Yes the colors come from the official @material/material-color-utilities and it's supposed to follow material design guidelines.

It seems there are difference between dart and typescript libraries of material-color-utilities : material-foundation/material-color-utilities#162.
This could explain the differences with https://material-foundation.github.io/material-theme-builder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants