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
feat: Ability to use relative color syntax in the theme file #29336
Comments
Thanks for the feature request. This is a really cool idea! The team did some discovery into this last week, and unfortunately we won't be able to support this at the moment. The original reason why we have separate hex and rgb values is noted on our docs. In an ideal world we'd be able to use the relative color syntax that you mentioned and be able to have a single set of hex color tokens. Unfortunately, Firefox does not support the relative color syntax, so supporting this would not work there. Chrome, Edge, and Safari support it, but there are several older versions of these browsers that Ionic still supports. We considered a couple alternatives:
:root {
--ion-text-color-white: 255, 255, 255;
}
.foo {
color: rgb(var(--ion-text-color-white) 0.5);
} We didn't like this approach for a couple reasons: b. The usage would be more involved than it is now since you would need to always use the :root {
- --ion-text-color-white: #ffffff;
+ --ion-text-color-white: 255, 255, 255;
}
.foo {
- color: var(--ion-text-color-white);
+ color: rgb(var(--ion-text-color-white));
}
I think it's worth looking into again once browser support improves. I am going to close this, but let me know if you have any questions. |
Hi, @liamdebeasi, this makes sense. Thank you so much for looking into it, and for your super thoughtful explanation! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Describe the Feature Request
Hi! I would love a way to convert hex values to rgb values in theme file so I don't have to hardcode rgb values when I already have hex variables. One possible solution is to use relative color syntax.
Describe the Use Case
From what I can tell, you must add both hex and rgb values separately to the theme file. Ideally, I could create one variable to point to the hex value, and then derive the rgb value from that original variable. If there is already a way to do this now, I would love to know it! If not, I would like to propose being able to use relative color syntax.
Current:
Suggested future state:
Thank you!
Describe Preferred Solution
No response
Describe Alternatives
No response
Related Code
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: