Ask any question about Bootstrap here... and get an instant response.
Post this Question & Answer:
How can I customize the default spacing utilities in Bootstrap?
Asked on Feb 27, 2026
Answer
Bootstrap 5 allows you to customize the default spacing utilities using Sass variables. You can adjust the spacing scale to fit your design needs by modifying these variables before compiling your Bootstrap CSS.
Modify the values in the `$spacers` map to your desired spacing sizes.
Import Bootstrap after your custom variables to ensure they are applied.
<!-- BEGIN COPY / PASTE -->
$spacers: (
0: 0,
1: 0.25rem,
2: 0.5rem,
3: 1rem,
4: 1.5rem,
5: 3rem
);
@import "bootstrap";
<!-- END COPY / PASTE -->Additional Comment:
- Copy the default `$spacers` map from Bootstrap's source code.
- You need a Sass compiler to compile the Bootstrap source with your customizations.
- This approach allows you to maintain consistency across your project with custom spacing utilities.
Recommended Links:
