Open In App

How to overwrite SASS function for bootstrap ?

As we all know that we have to override the Bootstrap style to give a new look to our website. Otherwise, it will look common by overriding we can change its default theme-background, fonts, colors, spacing, etc. variables. So here we have to override default Bootstrap variables(as variables are responsible for the output).To do so we need bootstrap locally to do that. We need the raw source code behind bootstrap the SASS code and we can easily get that by installing it as a local dependency using NPM(nodes package manager) and you get it automatically when installing Nodejs. Now just follow the steps given below to overwrite :

Example: I have installed node -modules/packages and created my own main.scss file now let given code below as our main code say index.html.




<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
    <link rel="stylesheet"
      href=
      integrity=
"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
      crossorigin="anonymous"/>
  </head>
  <body>
    <button type="submit" class="btn btn-primary">Submit</button>
  </body>
</html>
  
</html>

As we have included bootstrap values in it so after applying changes in our main.scss file that will reflect in our final output




$theme-colors: (
  "primary": #521751,
  "danger": #b80c03
);
@import "node_modules/bootstrap/scss/bootstrap";

Output:


Article Tags :