Support css variables for colors
See original GitHub issueFeature Proposal
It would be nice to be able to use css variables, so we can keep our styles clean.
For e.g. this css:
:root {
--main-color: #52006a;
}
Then reference it like this.
export const data = {
labels,
datasets: [
{
label: 'Dataset 1',
data: labels.map(() => faker.datatype.number({ min: 0, max: 1000 })),
backgroundColor: 'var(--main-color)',
},
{
label: 'Dataset 2',
data: labels.map(() => faker.datatype.number({ min: 0, max: 1000 })),
backgroundColor: 'var(--main-color)',
},
],
};
https://codesandbox.io/s/headless-snow-htvps?file=/App.tsx
Feature Use Case
I’m trying to keep my charts always styled with the correct color. This depends on dark/light style and is a hassle to have in mulitple places in your app. Ideally, there would be one place where we can change the main-color.
Possible Implementation
I’m not sure if there is anything blocking this, most other components seemed happy with the approach above.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Using CSS custom properties (variables) - MDN Web Docs
Custom properties (sometimes referred to as CSS variables or cascading variables) are entities defined by CSS authors that contain specific ...
Read more >CSS Variables - The var() function - W3Schools
A good way to use CSS variables is when it comes to the colors of your design. Instead of copy and paste the...
Read more >A Complete Guide To CSS Variables [With Examples]
CSS variables are custom properties in which you can store a value and use it anywhere in the HTML code. They were introduced...
Read more >CSS Variables (Custom Properties) | Can I use... Support ...
CSS Variables (Custom Properties). - CR. Permits the declaration and usage of cascading variables in stylesheets. Usage % of. all users, all tracked ......
Read more >How can I define colors as variables in CSS? - Stack Overflow
CSS itself doesn't use variables. However, you can use another language like SASS to define your styling using ...
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
Its really simple to implement externally: https://codepen.io/kurkle/pen/KKpaYwx
Similar to #2077
That might be true, since SVG is in the DOM (and thus has no other platforms). I’d guess you could disable SSR for chart.js (probably depending on the framework you are using), and get it working that way.