I am working with primeng and would like to overwrite the css variable value. (this is not important but this will make my issue more clear and what I try to achieve)
for example if I have an badge and i would like to set the background color.
in my debug console I can retrieve the styling that is applied.
background: var(--p-badge-primary-background);
in my stylesheet I have the following code
@import "styleGuide";
.p-badge {
--p-badge-primary-background: red;
}
this works fine but I have a whole styleguide defined and I want to use this as a template so I can changed the layout/style with minimal changes. I don't want look for al the refences of specific color. (here I overwrite a css varible with a new value)
What I like to achieve is to use a scss variables for the value that is defined in my styleguide that I imported.
.p-badge {
--p-badge-primary-background: $color-brand-primairy;
}
I am working with primeng and would like to overwrite the css variable value. (this is not important but this will make my issue more clear and what I try to achieve)
for example if I have an badge and i would like to set the background color.
in my debug console I can retrieve the styling that is applied.
background: var(--p-badge-primary-background);
in my stylesheet I have the following code
@import "styleGuide";
.p-badge {
--p-badge-primary-background: red;
}
this works fine but I have a whole styleguide defined and I want to use this as a template so I can changed the layout/style with minimal changes. I don't want look for al the refences of specific color. (here I overwrite a css varible with a new value)
What I like to achieve is to use a scss variables for the value that is defined in my styleguide that I imported.
.p-badge {
--p-badge-primary-background: $color-brand-primairy;
}
Share
Improve this question
edited Mar 20 at 13:56
Naren Murali
60.3k5 gold badges44 silver badges78 bronze badges
asked Mar 20 at 13:50
BabulaasBabulaas
8894 gold badges16 silver badges51 bronze badges
2 Answers
Reset to default 2You can use interpolation to do this.
SASS Interpolation Docs
.p-badge {
--p-badge-primary-background: #{$color-brand-primary};
}
What I do is this:
on helpers.scss
@use 'variables' as vars;
on _variables.scss
$black: #000;
$white: #fff;
$colors: (
'black': $black,
'white': $white,
);
:root {
@each $name, $color in $colors {
--#{$name}: #{$color};
}
}
and I get on main.css
:root {
--black: #000;
--white: #fff;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744405126a4572591.html
评论列表(0条)