![]() |
VOOZH | about |
Bootstrap5 Badges SASS is used to change the default value of badge's font size, font color, padding, border radius, and font-weight.
Steps to override scss of Bootstrap:
Step 1: Install bootstrap using following command:
npm i bootstrap
Step 2: Create your custom scss file and write the variable you want to override. Then include the bootstrap scss file using import.
$class_to_override: values; @import "node_modules/bootstrap/scss/bootstrap"
Step 3: Convert the file to CSS using live server extension.
Step 4: Include the converted scss file to your HTML after the link tag of Bootstrap css.
Project Structure: Here the custom scss file name is โcustom.scssโ and custom.css is converted file
$class_to_override: values; @import "node_modules/bootstrap/scss/bootstrap"
Example 1: In this example, make use of the $badge-font-size, $badge-font-weight, $badge-color, $badge-border-radius variables. Here in the scss file, the font size is changed to 25px, the font weight is changed to 900, the color of the badge text is changed to black and the border-radius is changed to 20px.
custom.scss
CSS file created after conversion
custom.css
index.html
Output:
Example 2: In this example, making use of the $badge-padding-x and $badge-padding-y variables. Here in the scss file, the top padding and bottom padding of the badge is changed to 1.5em, and the left padding and right padding of the badge is changed to 3em.
custom.scss
CSS file created after conversion
custom.css
index.html
Output:
Reference: