Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change bootstrap primary color to linear-gradient?

I am trying to change bootstrap primary color to linear-gredient but I am getting an error:

$theme-colors: (
  "primary": linear-gradient(to right, #373b44, #4286f4)
);

error:

$link-hover-color:          darken($link-color, 15%) !default;
                           ^
      Argument `$color` of `darken($color, $amount)` must be a color
like image 335
cotut Avatar asked May 23 '18 14:05

cotut


People also ask

How do I add a linear gradient in Bootstrap 5?

By adding a .bg-gradient class, a linear gradient is added as background image to the backgrounds. This gradient starts with a semi-transparent white which fades out to the bottom. Do you need a gradient in your custom CSS? Just add background-image: var(--bs-gradient); .

How do I set Bootstrap to enable true gradients?

Gradients and shadows# Bootstrap 4 has built-in custom variables which begin with $enable- (see Sass options). You can enable gradient and shadow effects with setting $enable-gradients and $enable-shadows to true .

How do you change the color of the gradient of a linear text?

Step 1: Apply a basic background to the body tag and align the text to center of the page. Step 2: Do some basic styling like font-size and family etc. Step 3: Apply the linear gradient property with any colors of your choice.


1 Answers

The problem is that linear-gradient is used for background-image, not foreground color. When the SASS compiler attempts to build Bootstrap it can't use the darken(..) function on a background-image.

Instead you can just change the primary color for the elements that have a background like this...

.bg-primary,
.btn-primary,
.badge-primary,
.alert-primary {
    background-image: linear-gradient(to right, #373b44, #4286f4);
}

https://www.codeply.com/go/XXUxFr6tEZ

like image 189
Zim Avatar answered Oct 05 '22 23:10

Zim