![]() |
VOOZH | about |
Bootstrap 5 Carousel SASS has a set of variables with default values that can be changed to customize the Carousel.
$carousel-control-color: $white;
$carousel-control-width: 15%;
$carousel-control-opacity: 0.5;
$carousel-control-hover-opacity: 0.9;
$carousel-control-transition: opacity .15s ease;
$carousel-indicator-width: 30px;
$carousel-indicator-height: 3px;
$carousel-indicator-hit-area-height: 10px;
$carousel-indicator-spacer: 3px;
$carousel-indicator-opacity: .5;
$carousel-indicator-active-bg: $white;
$carousel-indicator-active-opacity: 1;
$carousel-indicator-transition: opacity .6s ease;
$carousel-caption-width: 70%;
$carousel-caption-color: $white;
$carousel-caption-padding-y: 1.25rem;
$carousel-caption-spacer: 1.25rem;
$carousel-control-icon-width: 2rem;
$carousel-transition-duration: 0.6s;
$carousel-dark-indicator-active-bg: $black;
$carousel-dark-caption-color: $black;
$carousel-dark-control-icon-filter: invert(1) grayscale(100);
Steps to override SCSS of Bootstrap:
Step 1: Install bootstrap using the following command
npm i bootstrapStep 2: Create your custom scss file and write the variable you want to override. Then include the bootstrap scss file using import.
@import "../node_modules/bootstrap/scss/bootstrap.scss";
$variable_to_override: value;
Step 3: Convert the SCSS file to CSS using a live server extension.
Step 4: Include the CSS file in your HTML file.
<link rel="stylesheet" href="./assets/css/style.css">Project Structure :
$carousel-control-icon-width: 5rem;
...
.carousel-control-prev-icon,
.carousel-control-next-icon {
width: $carousel-control-icon-width;
height: $carousel-control-icon-width;
...
}
'. . . ' refers to other variables from the list of variables.
Example 1: In this example, we have modified the $carousel-control-icon-width variable to 5rem from its default value of 2rem.
style.scss
style.css
index.html
Output:
Example 2: In this example, we have modified variables to customize our carousel.
style.scss
style.css
index.html
Output:
References: https://getbootstrap.com/docs/5.0/components/carousel/#sass