Can less variables be compiled to css custom properties? How to merge less code in components into one large .less file?
See original GitHub issuediv{
@main-color: red;
color: @main-color;
border: 1px solid @main-color;
}
compiled out:
div{
--main-color: red;
color: var(--main-color);
border: 1px solid var(--main-color);
}
I know that the variable of less can be used not only for the value of the property, but also for the key of the property. But if don’t consider the latter, because it is not used in my project, how to achieve the compilation from less variables to css custom properties? Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Features In-Depth | Less.js
Less extends CSS with dynamic behavior such as variables, mixins, operations and ... You can easily treat properties like variables using the $prop...
Read more >How to combine less variables from multiple files into one file?
The answer to your question is "Yes". You can import all .less variable files in a single .less file and use that in...
Read more >A Complete Guide to Custom Properties | CSS-Tricks
Custom properties can make code easier to maintain because you can update one value and have it reflected in multiple places.
Read more >The difference between SASS/LESS variables and CSS ...
In CSS custom properties, you use double dash --variable-name , but you have to define the scope of the variable, similar to doing...
Read more >Retrofitting Theming Into A Legacy App Using LESS CSS And ...
If a style is truly global, it should get codified in a global variable. However, if a CSS component has one-off styles specific...
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
@hbshun did you manage to get this working? I’d be very interested to figure out how we can change less variable client side in libraries like antd. Any ideas?
If you want to do the latter, why not just write it that way? There’s no reason to use a Less var that’s not used in a Less function.