Questions tagged [css-variables]
Custom properties (or CSS variables) allow to define stylesheet-wide values identified by a token and usable in all CSS declarations.
css-variables
654
questions
1
vote
1
answer
72
views
CSS Variables Not Respecting Selector Precedence? [duplicate]
I've got some code I'm writing for a website builder that's causing me issues. We're using CSS variables to define global styles, with both desktop and mobile layout options, e.g.:
:root {
--section-...
1
vote
2
answers
51
views
is there a way to assign a different cssVariable to a cssVariable based on the class it is nested in? [duplicate]
we are using a design system that has 'tokens' and 'primitives'.
the idea is that we can connect different baseColors to a different UI-elements depending on the brand.
<h1>Hi this is header&...
1
vote
2
answers
59
views
how to use css variables to contain color-mix used with another variable
I have in css (generated by sass) variable called --secondary and it's value is red(#f00)
I want to create more variables for opacity like --secondary-100, --secondary-90, ...
I used color-mix in ...
0
votes
1
answer
22
views
What's the syntax for passing a CSS custom property in reagent?
How do I create this HTML in Reagent/hiccup?
<span style="--custom-property: value"></span>
Both Hiccup and Reagent fail to document how to pass CSS custom properties.
0
votes
1
answer
72
views
Make a given oklch color 50% lighter via CSS oklch(from ...) and calc() function
We have a design system that comes with a number of CSS custom properties for colors, e.g.:
:root {
--color--blue-1: oklch(88.6% 0.023 238);
}
We're using the relatively new color format oklch.
Now ...
-1
votes
1
answer
34
views
Use SCSS to convert a CSS variable from HSL to Hex
I have a number of CSS variables containing color values. I'd like to define these in HSL format, but can I let Sass convert these to hex values?
Input:
:root {
--dark: hsl(210, 50%, 13%);
}
Output:...
0
votes
1
answer
38
views
Bootstrap CSS variables not overriding for pagination
Using Bootstrap (currently v5.3.3) I am using a custom-built WordPress theme and setting a whole group of overrides for the colours used.
The custom-built WordPress theme stylesheet is loaded last, ...
0
votes
0
answers
31
views
CSS Multiple Identical Calc Use vs Single Calc in Custom Property on Performance
I am trying to ascertain the difference between the performance impact of storing a css calc function in a css custom variable and using that variable multiple times vs simply using the css calc ...
1
vote
0
answers
66
views
how to use css variables inside javascript in rollup
I have a UI components repo setup with rollup where I want to use my css variables inside my javascript files. I have done this in another repo which was using webpack and it was quite easy:
import ...
0
votes
1
answer
78
views
CSS Custom Properties with fallback for unrecognised css value (eg. clamp())
As it stands, CSS Custom Properties enjoys a global tracked base of 99.05% support according to CanIUse. Most of this is due to IE support that has one of a number off poly fills particularly when ...
0
votes
1
answer
150
views
Can you nest CSS Variables in CSS Variable names
I was wondering if it's possible to nest a CSS Variable within a CSS variable's name or possibly do something similar:
:root {
--color-1: red;
--index: 1;
}
span {
color: var(--color-var(--...
0
votes
0
answers
50
views
How to add the more than 2 color schemes in theme palette like light, dark, abc ,def? Not accepting anything other than light and dark
I am using mui version 5.11.13. I have configured my theme.tsx as below.
Also tried by augmenting module.
import { experimental_extendTheme as extendTheme } from "@mui/material/styles";
...
0
votes
0
answers
133
views
Get all CSS variables on an HTML element with JavaScript when you don't know the names of the CSS Variables? [duplicate]
In JavaScript I need to read all the CSS vars that have been applied to an HTML element.
If I know the name of a CSS variable eg --thing I can get it's value with this code. This works in both Chrome ...
1
vote
1
answer
384
views
How do I use environnement variable in my CSS using nextJs to specify base color?
how can I use an environment variable to specify the base color in my CSS ?
I use NEXTJS
My colors are all defined as variables in my globals.css :
@layer base {
:root {
...
--primary: #...
2
votes
1
answer
283
views
Using var() inside color-mix() appears to make it readable to browsers that don't support color-mix(), preventing the fallback from working
I'm using color-mix to take a button's background-color (set via a custom property) and make it lighter on hover. I expected browsers that don't support color-mix to simply ignore the hover state and ...