Home > Back-end >  How do I know exactly which Bootstrap SCSS assets to include?
How do I know exactly which Bootstrap SCSS assets to include?

Time:03-09

According to Bootstrap documentation, when we want to include SASS modules, we should use

// Custom.scss
// Option B: Include parts of Bootstrap

// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
@import "../node_modules/bootstrap/scss/functions";

// 2. Include any default variable overrides here

// 3. Include remainder of required Bootstrap stylesheets
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";

// 4. Include any optional Bootstrap components as you like
@import "../node_modules/bootstrap/scss/root";
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/containers";
@import "../node_modules/bootstrap/scss/grid";

// 5. Add additional custom code here

The directory bootstrap/scss has all these files:

-a----        26-10-1985     10:15           2621 _accordion.scss
-a----        26-10-1985     10:15           1474 _alert.scss
-a----        26-10-1985     10:15            624 _badge.scss
-a----        26-10-1985     10:15            923 _breadcrumb.scss
-a----        26-10-1985     10:15           2969 _button-group.scss
-a----        26-10-1985     10:15           2232 _buttons.scss
-a----        26-10-1985     10:15           4800 _card.scss
-a----        26-10-1985     10:15           5625 _carousel.scss
-a----        26-10-1985     10:15           1127 _close.scss
-a----        26-10-1985     10:15           1196 _containers.scss
-a----        26-10-1985     10:15           5501 _dropdown.scss
-a----        26-10-1985     10:15            256 _forms.scss
-a----        26-10-1985     10:15          10621 _functions.scss
-a----        26-10-1985     10:15            602 _grid.scss
-a----        26-10-1985     10:15            266 _helpers.scss
-a----        26-10-1985     10:15           1158 _images.scss
-a----        26-10-1985     10:15           4552 _list-group.scss
-a----        26-10-1985     10:15            899 _mixins.scss
-a----        26-10-1985     10:15           5658 _modal.scss
-a----        26-10-1985     10:15           2668 _nav.scss
-a----        26-10-1985     10:15           7536 _navbar.scss
-a----        26-10-1985     10:15           1933 _offcanvas.scss
-a----        26-10-1985     10:15           1681 _pagination.scss
-a----        26-10-1985     10:15            859 _placeholders.scss
-a----        26-10-1985     10:15           4402 _popover.scss
-a----        26-10-1985     10:15           1169 _progress.scss
-a----        26-10-1985     10:15          12571 _reboot.scss
-a----        26-10-1985     10:15           1880 _root.scss
-a----        26-10-1985     10:15           1521 _spinners.scss
-a----        26-10-1985     10:15           4215 _tables.scss
-a----        26-10-1985     10:15           1168 _toasts.scss
-a----        26-10-1985     10:15           2608 _tooltip.scss
-a----        26-10-1985     10:15            425 _transitions.scss
-a----        26-10-1985     10:15           1344 _type.scss
-a----        26-10-1985     10:15          14038 _utilities.scss
-a----        26-10-1985     10:15          67864 _variables.scss

How to know exactly which assets to include? Is there any table explaining?

CodePudding user response:

The vast majority of the optional files are component-specific. You can decide whether you want a give component by browsing the component section of the docs.

For example, _accordion.scss corresponds to the Accordion Component. Planning to use it? Include it! If not, skip it.

Anything that's not a component is documented in Bootstrap's sections on Layout (e.g. _grid.scss), Content (e.g. _type.scss), Forms, Helpers, or Utilities.

You can find all of these in the Bootstrap docs. Look at the table of contents or use the search functionality for each.

  • Related