1 year ago
#378900
SlinCode
Bootstrap 5 button-variant mixins gradients explained?
I've been looking at custom scss styling of Bootstrap 5 buttons using mixins. User ZIM's answer on the "How to change btn color in Bootstrap" post is very useful and clearly shows how the syntax for button-variant works.
However, I can't find any clear explanation on how the gradient inside that mixin works (as per the Bootstrap 5 docs).
There is an @include gradient-bg($background) in the mixin example on the buttons page and I can't seem to figure out how to pass a linear gradient to this or how to include it in a hypothetical ".btn-custom" class? Furthermore, how would a hover class with a different gradient background be defined using button-variant?
@mixin button-variant(
$background,
$border,
$color: color-contrast($background),
$hover-background: if($color == $color-contrast-light, shade-color($background, $btn-hover-bg-shade-amount), tint-color($background, $btn-hover-bg-tint-amount)),
$hover-border: if($color == $color-contrast-light, shade-color($border, $btn-hover-border-shade-amount), tint-color($border, $btn-hover-border-tint-amount)),
$hover-color: color-contrast($hover-background),
$active-background: if($color == $color-contrast-light, shade-color($background, $btn-active-bg-shade-amount), tint-color($background, $btn-active-bg-tint-amount)),
$active-border: if($color == $color-contrast-light, shade-color($border, $btn-active-border-shade-amount), tint-color($border, $btn-active-border-tint-amount)),
$active-color: color-contrast($active-background),
$disabled-background: $background,
$disabled-border: $border,
$disabled-color: color-contrast($disabled-background)
) {
color: $color;
@include gradient-bg($background);
border-color: $border;
@include box-shadow($btn-box-shadow);
&:hover {
color: $hover-color;
@include gradient-bg($hover-background);
border-color: $hover-border;
}
Could someone explain this part of the mixin please?
Thanks in advance.
gradient
bootstrap-5
mixins
0 Answers
Your Answer