How to override bootstrap variables in sass?

21,472

Bootstrap 4 is a big hit. They have completely rewritten it. So, You can override the variables very easily. Just create a _custom-variables.scss file and import it before _variables.scss file in bootstrap.scss as shown below. enter image description here

Copy the variable which you want to override, paste it in _custom-variables.scss and change the value as you want. Also remove the !default attribute. Compile it again and done. The !default attribute is reverse of !important. It will take the value of previously declared variable.

Share:
21,472
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I was trying to customize a Bootstrap 4. I want to copy settings from _variable.scss file to _custom.scss to override. But I didn't find _custom.scss file in source code. How do I add this _custom.scss file in my project?

  • Ryan
    Ryan about 6 years
    This part was super helpful: "The !default attribute is reverse of !important. It will take the value of previously declared variable."
  • Bill Gardner
    Bill Gardner almost 5 years
    This answer worked for me and was a much simpler solution to the one shown here: stackoverflow.com/questions/45776055/…
  • JDandChips
    JDandChips almost 3 years
    The !default comment has changed my life.