I want to customize my bootstrap with scss so I know that I have to make custom.scss and put some scss code into this - but there ins't working because I don't know where can I pust these file.
the below picture from official website of bootstrap - but it doesn't working
also I did this - and some structor that I fonded in internet
Asked
Active
Viewed 267 times
-1

mohsen Ghalandar
- 130
- 9
1 Answers
0
It doesn't meter where is your file is. The point is to include your custom variables before variables from bootstrap.
You can create BS file, where you can include BS components and other elements and in this file you can override default variables.
More over, in this case you can optimize your target CSS file.
One more thing - in example I using BS5, in v4 approach the same (because it's SCSS).
Your structure:
.
└── scss/
├── _bs-variables.scss
├── custom-bootstrap.scss
└── custom.scss
Example:
_bs-variables.scss
:
$primary: tomato;
custom-bootstrap.scss
:
/*!
* Bootstrap v5.1.3 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
// scss-docs-start import-stack
// Configuration
@import "~bootstrap/scss/functions";
// override default variables
@import "./bs-variables"; // here is your custom variables include
// default BS variables
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/mixins";
@import "~bootstrap/scss/utilities";
// Layout & components
@import "~bootstrap/scss/root";
@import "~bootstrap/scss/reboot";
@import "~bootstrap/scss/type";
@import "~bootstrap/scss/images";
@import "~bootstrap/scss/containers";
...
custom.scss
:
@import './custom-bootstrap';
// other SCSS code
...

Yaroslav Trach
- 1,833
- 2
- 12
- 18
-
I copy/paste your code but primary color wont change – mohsen Ghalandar Apr 22 '22 at 10:36
-
how you building your css? – Yaroslav Trach Apr 22 '22 at 10:38
-
I just make custom.scss and then put your code into that - I should did anything more ? – mohsen Ghalandar Apr 22 '22 at 10:47
-
have you created and imported overriding variables before @import "~bootstrap/scss/variables"; line? In any case you have to build SCSS into CSS. I need more intel to tell you what is wrong – Yaroslav Trach Apr 22 '22 at 10:50