The Bootstrap 4.1 documentation on spacing says that I can extend the $spacers variable (which is used by the margin and padding classes) but it doesn't explain how.
Can anyone share a link to official documentation? If that doesn't exist can anyone explain?
You can follow Bootstrap's Variable defaults documentation for how to override the default for just a single Sass variable. You can add your own by setting $spacers
in your override file:
// Your variable overrides
$spacer: 1rem;
$spacers: (
6: ($spacer * 3.5),
7: ($spacer * 10)
)
// Bootstrap and its default variables
@import "../node_modules/bootstrap/scss/bootstrap";
The variable the docs refer to is called $spacers
and is in _variables.scss:
// Spacing
//
// Control the default styling of most Bootstrap elements by modifying these
// variables. Mostly focused on spacing.
// You can add more entries to the $spacers map, should you need more variation.
$spacer: 1rem !default;
$spacers: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$spacers: map-merge(
(
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3)
),
$spacers
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With