Type safe colors
See original GitHub issueAs discussed in #13875, there is currently support for specifying the colors, based on the configuration in the theme in the following format: “common.white”. For example:
<Typography color="common.white">text</Typography>
This works great, but it is not type safe. With the introduction of Template Literal Types in TypeScript, I believe that this should now be possible to ensure the type-safety.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Web Safe Colors Chart - RapidTables.com
Web safe colors are formed by the combination of red, green and blue (RGB) hex values of 0,33H,66H,99H,CCH,FFH. This results with 6*6*6=216 colors....
Read more >Type safe colors · Issue #26475 · mui/material-ui - GitHub
As discussed in #13875, there is currently support for specifying the colors, based on the configuration in the theme in the following ...
Read more >Using Web Colors In 2020 - A Guide [List Of Web-Safe ... - HTML
Color brings the internet to life and enhances the way in which we view the web. But how do you create colors in...
Read more >Web colors - Wikipedia
Basic colorsEdit ; Hex (RGB) ; Red (RGB) ; Green (RGB) ; Blue (RGB) ; Hue (HSL/HSV) ...
Read more >HTML Ref » Reference » Appendix E » Browser Safe Colors
FFFFFF R: 255. G: 255. B: 255 FFFFCC R: 255. G: 255. B: 204 FFFF99 R: 255. G: 255. B: 1...
FFCC99 R: 255....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It should be with template literal types but we would need to experiment if we can cover every possible color and if that’s viable. Better autocomplete would already be a good first step.
Playground Link
This is definitely the plan. But we have to wait for TypeScript 4.0 to reach end-of-life. Until then we still have to support TypeScript 4.0 and the additional effort of shipping types for multiple TypeScript versions is probably not worth the effort. If people are interested in it, they can upvote the issue.