diff options
Diffstat (limited to 'vendor/twbs/bootstrap/site/content/docs/5.0/customize')
7 files changed, 0 insertions, 705 deletions
diff --git a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/color.md b/vendor/twbs/bootstrap/site/content/docs/5.0/customize/color.md deleted file mode 100644 index 7d1615589..000000000 --- a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/color.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -layout: docs -title: Color -description: Bootstrap is supported by an extensive color system that themes our styles and components. This enables more comprehensive customization and extension for any project. -group: customize -toc: true ---- - -## Theme colors - -We use a subset of all colors to create a smaller color palette for generating color schemes, also available as Sass variables and a Sass map in Bootstrap's `scss/_variables.scss` file. - -<div class="row"> - {{< theme-colors.inline >}} - {{- range (index $.Site.Data "theme-colors") }} - <div class="col-md-4"> - <div class="p-3 mb-3 bg-{{ .name }} {{ if .contrast_color }}text-{{ .contrast_color }}{{ else }}text-white{{ end }}">{{ .name | title }}</div> - </div> - {{ end -}} - {{< /theme-colors.inline >}} -</div> - -All these colors are available as a Sass map, `$theme-colors`. - -{{< scss-docs name="theme-colors-map" file="scss/_variables.scss" >}} - -Check out [our Sass maps and loops docs]({{< docsref "/customize/sass#maps-and-loops" >}}) for how to modify these colors. - -## All colors - -All Bootstrap colors are available as Sass variables and a Sass map in `scss/_variables.scss` file. To avoid increased file sizes, we don't create text or background color classes for each of these variables. Instead, we choose a subset of these colors for a [theme palette](#theme-colors). - -Be sure to monitor contrast ratios as you customize colors. As shown below, we've added three contrast ratios to each of the main colors—one for the swatch's current colors, one for against white, and one for against black. - -<div class="row font-monospace"> - {{< theme-colors.inline >}} - {{- range $color := $.Site.Data.colors }} - {{- if (and (not (eq $color.name "white")) (not (eq $color.name "gray")) (not (eq $color.name "gray-dark"))) }} - <div class="col-md-4 mb-3"> - <div class="p-3 mb-2 position-relative swatch-{{ $color.name }}"> - <strong class="d-block">${{ $color.name }}</strong> - {{ $color.hex }} - </div> - {{ range (seq 100 100 900) }} - <div class="p-3 bd-{{ $color.name }}-{{ . }}">${{ $color.name }}-{{ . }}</div> - {{ end }} - </div> - {{ end -}} - {{ end -}} - - <div class="col-md-4 mb-3"> - <div class="p-3 mb-2 position-relative swatch-gray-500"> - <strong class="d-block">$gray-500</strong> - #adb5bd - </div> - {{- range $.Site.Data.grays }} - <div class="p-3 bd-gray-{{ .name }}">$gray-{{ .name }}</div> - {{ end -}} - </div> - {{< /theme-colors.inline >}} - - <div class="col-md-4 mb-3"> - <div class="p-3 mb-2 bd-black text-white"> - <strong class="d-block">$black</strong> - #000 - </div> - <div class="p-3 mb-2 bd-white border"> - <strong class="d-block">$white</strong> - #fff - </div> - </div> -</div> - -### Notes on Sass - -Sass cannot programmatically generate variables, so we manually created variables for every tint and shade ourselves. We specify the midpoint value (e.g., `$blue-500`) and use custom color functions to tint (lighten) or shade (darken) our colors via Sass's `mix()` color function. - -Using `mix()` is not the same as `lighten()` and `darken()`—the former blends the specified color with white or black, while the latter only adjusts the lightness value of each color. The result is a much more complete suite of colors, as [shown in this CodePen demo](https://codepen.io/emdeoh/pen/zYOQOPB). - -Our `tint-color()` and `shade-color()` functions use `mix()` alongside our `$theme-color-interval` variable, which specifies a stepped percentage value for each mixed color we produce. See the `scss/_functions.scss` and `scss/_variables.scss` files for the full source code. - -## Color Sass maps - -Bootstrap's source Sass files include three maps to help you quickly and easily loop over a list of colors and their hex values. - -- `$colors` lists all our available base (`500`) colors -- `$theme-colors` lists all semantically named theme colors (shown below) -- `$grays` lists all tints and shades of gray - -Within `scss/_variables.scss`, you'll find Bootstrap's color variables and Sass map. Here's an example of the `$colors` Sass map: - -{{< scss-docs name="colors-map" file="scss/_variables.scss" >}} - -Add, remove, or modify values within the map to update how they're used in many other components. Unfortunately at this time, not _every_ component utilizes this Sass map. Future updates will strive to improve upon this. Until then, plan on making use of the `${color}` variables and this Sass map. - -### Example - -Here's how you can use these in your Sass: - -```scss -.alpha { color: $purple; } -.beta { - color: $yellow-300; - background-color: $indigo-900; -} -``` - -[Color]({{< docsref "/utilities/colors" >}}) and [background]({{< docsref "/utilities/background" >}}) utility classes are also available for setting `color` and `background-color` using the `500` color values. diff --git a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/components.md b/vendor/twbs/bootstrap/site/content/docs/5.0/customize/components.md deleted file mode 100644 index b512a9036..000000000 --- a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/components.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -layout: docs -title: Components -description: Learn how and why we build nearly all our components responsively and with base and modifier classes. -group: customize -toc: true ---- - -## Base classes - -Bootstrap's components are largely built with a base-modifier nomenclature. We group as many shared properties as possible into a base class, like `.btn`, and then group individual styles for each variant into modifier classes, like `.btn-primary` or `.btn-success`. - -To build our modifier classes, we use Sass's `@each` loops to iterate over a Sass map. This is especially helpful for generating variants of a component by our `$theme-colors` and creating responsive variants for each breakpoint. As you customize these Sass maps and recompile, you'll automatically see your changes reflected in these loops. - -Check out [our Sass maps and loops docs]({{< docsref "/customize/sass#maps-and-loops" >}}) for how to customize these loops and extend Bootstrap's base-modifier approach to your own code. - -## Modifiers - -Many of Bootstrap's components are built with a base-modifier class approach. This means the bulk of the styling is contained to a base class (e.g., `.btn`) while style variations are confined to modifier classes (e.g., `.btn-danger`). These modifier classes are built from the `$theme-colors` map to make customizing the number and name of our modifier classes. - -Here are two examples of how we loop over the `$theme-colors` map to generate modifiers to the `.alert` and `.list-group` components. - -{{< scss-docs name="alert-modifiers" file="scss/_alert.scss" >}} - -{{< scss-docs name="list-group-modifiers" file="scss/_list-group.scss" >}} - -## Responsive - -These Sass loops aren't limited to color maps, either. You can also generate responsive variations of your components. Take for example our responsive alignment of the dropdowns where we mix an `@each` loop for the `$grid-breakpoints` Sass map with a media query include. - -{{< scss-docs name="responsive-breakpoints" file="scss/_dropdown.scss" >}} - -Should you modify your `$grid-breakpoints`, your changes will apply to all the loops iterating over that map. - -{{< scss-docs name="grid-breakpoints" file="scss/_variables.scss" >}} - -For more information and examples on how to modify our Sass maps and variables, please refer to [the Sass section of the Grid documentation]({{< docsref "/layout/grid#sass" >}}). - -## Creating your own - -We encourage you to adopt these guidelines when building with Bootstrap to create your own components. We've extended this approach ourselves to the custom components in our documentation and examples. Components like our callouts are built just like our provided components with base and modifier classes. - -<div class="bd-example"> - <div class="bd-callout my-0"> - <strong>This is a callout.</strong> We built it custom for our docs so our messages to you stand out. It has three variants via modifier classes. - </div> -</div> - -```html -<div class="callout">...</div> -``` - -In your CSS, you'd have something like the following where the bulk of the styling is done via `.callout`. Then, the unique styles between each variant is controlled via modifier class. - -```scss -// Base class -.callout {} - -// Modifier classes -.callout-info {} -.callout-warning {} -.callout-danger {} -``` - -For the callouts, that unique styling is just a `border-left-color`. When you combine that base class with one of those modifier classes, you get your complete component family: - -{{< callout info >}} -**This is an info callout.** Example text to show it in action. -{{< /callout >}} - -{{< callout warning >}} -**This is a warning callout.** Example text to show it in action. -{{< /callout >}} - -{{< callout danger >}} -**This is a danger callout.** Example text to show it in action. -{{< /callout >}} diff --git a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/css-variables.md b/vendor/twbs/bootstrap/site/content/docs/5.0/customize/css-variables.md deleted file mode 100644 index a2d0f33b7..000000000 --- a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/css-variables.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -layout: docs -title: CSS variables -description: Use Bootstrap's CSS custom properties for fast and forward-looking design and development. -group: customize -toc: true ---- - -Bootstrap includes around two dozen [CSS custom properties (variables)](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) in its compiled CSS, with dozens more on the way for improved customization on a per-component basis. These provide easy access to commonly used values like our theme colors, breakpoints, and primary font stacks when working in your browser's inspector, a code sandbox, or general prototyping. - -**All our custom properties are prefixed with `bs-`** to avoid conflicts with third party CSS. - -## Root variables - -Here are the variables we include (note that the `:root` is required) that can be accessed anywhere Bootstrap's CSS is loaded. They're located in our `_root.scss` file and included in our compiled dist files. - -```css -{{< root.inline >}} -{{- $css := readFile "dist/css/bootstrap.css" -}} -{{- $match := findRE ":root {([^}]*)}" $css 1 -}} - -{{- if (eq (len $match) 0) -}} -{{- errorf "Got no matches for :root in %q!" $.Page.Path -}} -{{- end -}} - -{{- index $match 0 -}} - -{{< /root.inline >}} -``` - -## Component variables - -We're also beginning to make use of custom properties as local variables for various components. This way we can reduce our compiled CSS, ensure styles aren't inherited in places like nested tables, and allow some basic restyling and extending of Bootstrap components after Sass compilation. - -Have a look at our table documentation for some [insight into how we're using CSS variables]({{< docsref "/content/tables#how-do-the-variants-and-accented-tables-work" >}}). - -We're also using CSS variables across our grids—primarily for gutters—with more component usage coming in the future. - -## Examples - -CSS variables offer similar flexibility to Sass's variables, but without the need for compilation before being served to the browser. For example, here we're resetting our page's font and link styles with CSS variables. - -```css -body { - font: 1rem/1.5 var(--bs-font-sans-serif); -} -a { - color: var(--bs-blue); -} -``` diff --git a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/optimize.md b/vendor/twbs/bootstrap/site/content/docs/5.0/customize/optimize.md deleted file mode 100644 index 0911667d0..000000000 --- a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/optimize.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -layout: docs -title: Optimize -description: Keep your projects lean, responsive, and maintainable so you can deliver the best experience and focus on more important jobs. -group: customize -toc: true ---- - -## Lean Sass imports - -When using Sass in your asset pipeline, make sure you optimize Bootstrap by only `@import`ing the components you need. Your largest optimizations will likely come from the `Layout & Components` section of our `bootstrap.scss`. - -{{< scss-docs name="import-stack" file="scss/bootstrap.scss" >}} - - -If you're not using a component, comment it out or delete it entirely. For example, if you're not using the carousel, remove that import to save some file size in your compiled CSS. Keep in mind there are some dependencies across Sass imports that may make it more difficult to omit a file. - -## Lean JavaScript - -Bootstrap's JavaScript includes every component in our primary dist files (`bootstrap.js` and `bootstrap.min.js`), and even our primary dependency (Popper) with our bundle files (`bootstrap.bundle.js` and `bootstrap.bundle.min.js`). While you're customizing via Sass, be sure to remove related JavaScript. - -For instance, assuming you're using your own JavaScript bundler like Webpack or Rollup, you'd only import the JavaScript you plan on using. In the example below, we show how to just include our modal JavaScript: - -```js -// Import just what we need - -// import 'bootstrap/js/dist/alert'; -// import 'bootstrap/js/dist/button'; -// import 'bootstrap/js/dist/carousel'; -// import 'bootstrap/js/dist/collapse'; -// import 'bootstrap/js/dist/dropdown'; -import 'bootstrap/js/dist/modal'; -// import 'bootstrap/js/dist/popover'; -// import 'bootstrap/js/dist/scrollspy'; -// import 'bootstrap/js/dist/tab'; -// import 'bootstrap/js/dist/toast'; -// import 'bootstrap/js/dist/tooltip'; -``` - -This way, you're not including any JavaScript you don't intend to use for components like buttons, carousels, and tooltips. If you're importing dropdowns, tooltips or popovers, be sure to list the Popper dependency in your `package.json` file. - -{{< callout info >}} -### Default Exports - -Files in `bootstrap/js/dist` use the **default export**, so if you want to use one of them you have to do the following: - -```js -import Modal from 'bootstrap/js/dist/modal' - -const modal = new Modal(document.getElementById('myModal')) -``` -{{< /callout >}} - -## Autoprefixer .browserslistrc - -Bootstrap depends on Autoprefixer to automatically add browser prefixes to certain CSS properties. Prefixes are dictated by our `.browserslistrc` file, found in the root of the Bootstrap repo. Customizing this list of browsers and recompiling the Sass will automatically remove some CSS from your compiled CSS, if there are vendor prefixes unique to that browser or version. - -## Unused CSS - -_Help wanted with this section, please consider opening a PR. Thanks!_ - -While we don't have a prebuilt example for using [PurgeCSS](https://github.com/FullHuman/purgecss) with Bootstrap, there are some helpful articles and walkthroughs that the community has written. Here are some options: - -- <https://medium.com/dwarves-foundation/remove-unused-css-styles-from-bootstrap-using-purgecss-88395a2c5772> -- <https://lukelowrey.com/automatically-removeunused-css-from-bootstrap-or-other-frameworks/> - -Lastly, this [CSS Tricks article on unused CSS](https://css-tricks.com/how-do-you-remove-unused-css-from-a-site/) shows how to use PurgeCSS and other similar tools. - -## Minify and gzip - -Whenever possible, be sure to compress all the code you serve to your visitors. If you're using Bootstrap dist files, try to stick to the minified versions (indicated by the `.min.css` and `.min.js` extensions). If you're building Bootstrap from the source with your own build system, be sure to implement your own minifiers for HTML, CSS, and JS. - -## Nonblocking files - -While minifying and using compression might seem like enough, making your files nonblocking ones is also a big step in making your site well-optimized and fast enough. - -If you are using a [Lighthouse](https://developers.google.com/web/tools/lighthouse/) plugin in Google Chrome, you may have stumbled over FCP. [The First Contentful Paint](https://web.dev/fcp/) metric measures the time from when the page starts loading to when any part of the page's content is rendered on the screen. - -You can improve FCP by deferring non-critical JavaScript or CSS. What does that mean? Simply, JavaScript or stylesheets that don't need to be present on the first paint of your page should be marked with `async` or `defer` attributes. - -This ensures that the less important resources are loaded later and not blocking the first paint. On the other hand, critical resources can be included as inline scripts or styles. - -If you want to learn more about this, there are already a lot of great articles about it: - -- <https://web.dev/render-blocking-resources/> -- <https://web.dev/defer-non-critical-css/> - -## Always use HTTPS - -Your website should only be available over HTTPS connections in production. HTTPS improves the security, privacy, and availability of all sites, and [there is no such thing as non-sensitive web traffic](https://https.cio.gov/everything/). The steps to configure your website to be served exclusively over HTTPS vary widely depending on your architecture and web hosting provider, and thus are beyond the scope of these docs. - -Sites served over HTTPS should also access all stylesheets, scripts, and other assets over HTTPS connections. Otherwise, you'll be sending users [mixed active content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content), leading to potential vulnerabilities where a site can be compromised by altering a dependency. This can lead to security issues and in-browser warnings displayed to users. Whether you're getting Bootstrap from a CDN or serving it yourself, ensure that you only access it over HTTPS connections. diff --git a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/options.md b/vendor/twbs/bootstrap/site/content/docs/5.0/customize/options.md deleted file mode 100644 index 0d846270b..000000000 --- a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/options.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -layout: docs -title: Options -description: Quickly customize Bootstrap with built-in variables to easily toggle global CSS preferences for controlling style and behavior. -group: customize ---- - -Customize Bootstrap with our built-in custom variables file and easily toggle global CSS preferences with new `$enable-*` Sass variables. Override a variable's value and recompile with `npm run test` as needed. - -You can find and customize these variables for key global options in Bootstrap's `scss/_variables.scss` file. - -{{< bs-table "table text-start" >}} -| Variable | Values | Description | -| ------------------------------ | ---------------------------------- | -------------------------------------------------------------------------------------- | -| `$spacer` | `1rem` (default), or any value > 0 | Specifies the default spacer value to programmatically generate our [spacer utilities]({{< docsref "/utilities/spacing" >}}). | -| `$enable-rounded` | `true` (default) or `false` | Enables predefined `border-radius` styles on various components. | -| `$enable-shadows` | `true` or `false` (default) | Enables predefined decorative `box-shadow` styles on various components. Does not affect `box-shadow`s used for focus states. | -| `$enable-gradients` | `true` or `false` (default) | Enables predefined gradients via `background-image` styles on various components. | -| `$enable-transitions` | `true` (default) or `false` | Enables predefined `transition`s on various components. | -| `$enable-reduced-motion` | `true` (default) or `false` | Enables the [`prefers-reduced-motion` media query]({{< docsref "/getting-started/accessibility#reduced-motion" >}}), which suppresses certain animations/transitions based on the users' browser/operating system preferences. | -| `$enable-grid-classes` | `true` (default) or `false` | Enables the generation of CSS classes for the grid system (e.g. `.row`, `.col-md-1`, etc.). | -| `$enable-caret` | `true` (default) or `false` | Enables pseudo element caret on `.dropdown-toggle`. | -| `$enable-button-pointers` | `true` (default) or `false` | Add "hand" cursor to non-disabled button elements. | -| `$enable-rfs` | `true` (default) or `false` | Globally enables [RFS]({{< docsref "/getting-started/rfs" >}}). | -| `$enable-validation-icons` | `true` (default) or `false` | Enables `background-image` icons within textual inputs and some custom forms for validation states. | -| `$enable-negative-margins` | `true` or `false` (default) | Enables the generation of [negative margin utilities]({{< docsref "/utilities/spacing#negative-margin" >}}). | -| `$enable-deprecation-messages` | `true` (default) or `false` | Set to `false` to hide warnings when using any of the deprecated mixins and functions that are planned to be removed in `v6`. | -| `$enable-important-utilities` | `true` (default) or `false` | Enables the `!important` suffix in utility classes. | -{{< /bs-table >}} diff --git a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/overview.md b/vendor/twbs/bootstrap/site/content/docs/5.0/customize/overview.md deleted file mode 100644 index 9c8878e3a..000000000 --- a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/overview.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -layout: docs -title: Customize -description: Learn how to theme, customize, and extend Bootstrap with Sass, a boatload of global options, an expansive color system, and more. -group: customize -toc: false -aliases: "/docs/5.0/customize/" -sections: - - title: Sass - description: Utilize our source Sass files to take advantage of variables, maps, mixins, and functions. - - title: Options - description: Customize Bootstrap with built-in variables to easily toggle global CSS preferences. - - title: Color - description: Learn about and customize the color systems that support the entire toolkit. - - title: Components - description: Learn how we build nearly all our components responsively and with base and modifier classes. - - title: CSS variables - description: Use Bootstrap's CSS custom properties for fast and forward-looking design and development. - - title: Optimize - description: Keep your projects lean, responsive, and maintainable so you can deliver the best experience. ---- - -## Overview - -There are multiple ways to customize Bootstrap. Your best path can depend on your project, the complexity of your build tools, the version of Bootstrap you're using, browser support, and more. - -Our two preferred methods are: - -1. Using Bootstrap [via package manager]({{< docsref "/getting-started/download#package-managers" >}}) so you can use and extend our source files. -2. Using Bootstrap's compiled distribution files or [jsDelivr]({{< docsref "/getting-started/download#cdn-via-jsdelivr" >}}) so you can add onto or override Bootstrap's styles. - -While we cannot go into details here on how to use every package manager, we can give some guidance on [using Bootstrap with your own Sass compiler]({{< docsref "/customize/sass" >}}). - -For those who want to use the distribution files, review the [getting started page]({{< docsref "/getting-started/introduction" >}}) for how to include those files and an example HTML page. From there, consult the docs for the layout, components, and behaviors you'd like to use. - -As you familiarize yourself with Bootstrap, continue exploring this section for more details on how to utilize our global options, making use of and changing our color system, how we build our components, how to use our growing list of CSS custom properties, and how to optimize your code when building with Bootstrap. - -## CSPs and embedded SVGs - -Several Bootstrap components include embedded SVGs in our CSS to style components consistently and easily across browsers and devices. **For organizations with more strict <abbr title="Content Security Policy">CSP</abbr> configurations**, we've documented all instances of our embedded SVGs (all of which are applied via `background-image`) so you can more thoroughly review your options. - -- [Accordion]({{< docsref "/components/accordion" >}}) -- [Close button]({{< docsref "/components/close-button" >}}) (used in alerts and modals) -- [Form checkboxes and radio buttons]({{< docsref "/forms/checks-radios" >}}) -- [Form switches]({{< docsref "/forms/checks-radios#switches" >}}) -- [Form validation icons]({{< docsref "/forms/validation#server-side" >}}) -- [Select menus]({{< docsref "/forms/select" >}}) -- [Carousel controls]({{< docsref "/components/carousel#with-controls" >}}) -- [Navbar toggle buttons]({{< docsref "/components/navbar#responsive-behaviors" >}}) - -Based on [community conversation](https://github.com/twbs/bootstrap/issues/25394), some options for addressing this in your own codebase include replacing the URLs with locally hosted assets, removing the images and using inline images (not possible in all components), and modifying your CSP. Our recommendation is to carefully review your own security policies and decide on the best path forward, if necessary. diff --git a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/sass.md b/vendor/twbs/bootstrap/site/content/docs/5.0/customize/sass.md deleted file mode 100644 index 4039bd67c..000000000 --- a/vendor/twbs/bootstrap/site/content/docs/5.0/customize/sass.md +++ /dev/null @@ -1,298 +0,0 @@ ---- -layout: docs -title: Sass -description: Utilize our source Sass files to take advantage of variables, maps, mixins, and functions to help you build faster and customize your project. -group: customize -toc: true ---- - -Utilize our source Sass files to take advantage of variables, maps, mixins, and more. - -## File structure - -Whenever possible, avoid modifying Bootstrap's core files. For Sass, that means creating your own stylesheet that imports Bootstrap so you can modify and extend it. Assuming you're using a package manager like npm, you'll have a file structure that looks like this: - -```text -your-project/ -├── scss -│ └── custom.scss -└── node_modules/ - └── bootstrap - ├── js - └── scss -``` - -If you've downloaded our source files and aren't using a package manager, you'll want to manually setup something similar to that structure, keeping Bootstrap's source files separate from your own. - -```text -your-project/ -├── scss -│ └── custom.scss -└── bootstrap/ - ├── js - └── scss -``` - -## Importing - -In your `custom.scss`, you'll import Bootstrap's source Sass files. You have two options: include all of Bootstrap, or pick the parts you need. We encourage the latter, though be aware there are some requirements and dependencies across our components. You also will need to include some JavaScript for our plugins. - -```scss -// Custom.scss -// Option A: Include all of Bootstrap - -// Include any default variable overrides here (though functions won't be available) - -@import "../node_modules/bootstrap/scss/bootstrap"; - -// Then add additional custom code here -``` - -```scss -// 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 -``` - -With that setup in place, you can begin to modify any of the Sass variables and maps in your `custom.scss`. You can also start to add parts of Bootstrap under the `// Optional` section as needed. We suggest using the full import stack from our `bootstrap.scss` file as your starting point. - -## Variable defaults - -Every Sass variable in Bootstrap includes the `!default` flag allowing you to override the variable's default value in your own Sass without modifying Bootstrap's source code. Copy and paste variables as needed, modify their values, and remove the `!default` flag. If a variable has already been assigned, then it won't be re-assigned by the default values in Bootstrap. - -You will find the complete list of Bootstrap's variables in `scss/_variables.scss`. Some variables are set to `null`, these variables don't output the property unless they are overridden in your configuration. - -Variable overrides must come after our functions are imported, but before the rest of the imports. - -Here's an example that changes the `background-color` and `color` for the `<body>` when importing and compiling Bootstrap via npm: - -```scss -// Required -@import "../node_modules/bootstrap/scss/functions"; - -// Default variable overrides -$body-bg: #000; -$body-color: #111; - -// Required -@import "../node_modules/bootstrap/scss/variables"; -@import "../node_modules/bootstrap/scss/mixins"; - -// Optional Bootstrap components here -@import "../node_modules/bootstrap/scss/root"; -@import "../node_modules/bootstrap/scss/reboot"; -@import "../node_modules/bootstrap/scss/type"; -// etc -``` - -Repeat as necessary for any variable in Bootstrap, including the global options below. - -{{< callout info >}} -{{< partial "callout-info-npm-starter.md" >}} -{{< /callout >}} - -## Maps and loops - -Bootstrap includes a handful of Sass maps, key value pairs that make it easier to generate families of related CSS. We use Sass maps for our colors, grid breakpoints, and more. Just like Sass variables, all Sass maps include the `!default` flag and can be overridden and extended. - -Some of our Sass maps are merged into empty ones by default. This is done to allow easy expansion of a given Sass map, but comes at the cost of making _removing_ items from a map slightly more difficult. - -### Modify map - -All variables in the `$theme-colors` map are defined as standalone variables. To modify an existing color in our `$theme-colors` map, add the following to your custom Sass file: - -```scss -$primary: #0074d9; -$danger: #ff4136; -``` - -Later on, these variables are set in Bootstrap's `$theme-colors` map: - -```scss -$theme-colors: ( - "primary": $primary, - "danger": $danger -); -``` - -### Add to map - -Add new colors to `$theme-colors`, or any other map, by creating a new Sass map with your custom values and merging it with the original map. In this case, we'll create a new `$custom-colors` map and merge it with `$theme-colors`. - -```scss -// Create your own map -$custom-colors: ( - "custom-color": #900 -); - -// Merge the maps -$theme-colors: map-merge($theme-colors, $custom-colors); -``` - -### Remove from map - -To remove colors from `$theme-colors`, or any other map, use `map-remove`. Be aware you must insert it between our requirements and options: - -```scss -// Required -@import "../node_modules/bootstrap/scss/functions"; -@import "../node_modules/bootstrap/scss/variables"; -@import "../node_modules/bootstrap/scss/mixins"; - -$theme-colors: map-remove($theme-colors, "info", "light", "dark"); - -// Optional -@import "../node_modules/bootstrap/scss/root"; -@import "../node_modules/bootstrap/scss/reboot"; -@import "../node_modules/bootstrap/scss/type"; -// etc -``` - -## Required keys - -Bootstrap assumes the presence of some specific keys within Sass maps as we used and extend these ourselves. As you customize the included maps, you may encounter errors where a specific Sass map's key is being used. - -For example, we use the `primary`, `success`, and `danger` keys from `$theme-colors` for links, buttons, and form states. Replacing the values of these keys should present no issues, but removing them may cause Sass compilation issues. In these instances, you'll need to modify the Sass code that makes use of those values. - -## Functions - -### Colors - -Next to the [Sass maps]({{< docsref "/customize/color#color-sass-maps" >}}) we have, theme colors can also be used as standalone variables, like `$primary`. - -```scss -.custom-element { - color: $gray-100; - background-color: $dark; -} -``` - -You can lighten or darken colors with Bootstrap's `tint-color()` and `shade-color()` functions. These functions will mix colors with black or white, unlike Sass' native `lighten()` and `darken()` functions which will change the lightness by a fixed amount, which often doesn't lead to the desired effect. - -{{< scss-docs name="color-functions" file="scss/_functions.scss" >}} - -In practice, you'd call the function and pass in the color and weight parameters. - -```scss -.custom-element { - color: tint-color($primary, 10%); -} - -.custom-element-2 { - color: shade-color($danger, 30%); -} -``` - -### Color contrast - -In order to meet [WCAG 2.0 accessibility standards for color contrast](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html), authors **must** provide [a contrast ratio of at least 4.5:1](https://www.w3.org/WAI/WCAG20/quickref/20160105/Overview.php#visual-audio-contrast-contrast), with very few exceptions. - -An additional function we include in Bootstrap is the color contrast function, `color-contrast`. It utilizes the [WCAG 2.0 algorithm](https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests) for calculating contrast thresholds based on [relative luminance](https://www.w3.org/WAI/GL/wiki/Relative_luminance) in a `sRGB` colorspace to automatically return a light (`#fff`), dark (`#212529`) or black (`#000`) contrast color based on the specified base color. This function is especially useful for mixins or loops where you're generating multiple classes. - -For example, to generate color swatches from our `$theme-colors` map: - -```scss -@each $color, $value in $theme-colors { - .swatch-#{$color} { - color: color-contrast($value); - } -} -``` - -It can also be used for one-off contrast needs: - -```scss -.custom-element { - color: color-contrast(#000); // returns `color: #fff` -} -``` - -You can also specify a base color with our color map functions: - -```scss -.custom-element { - color: color-contrast($dark); // returns `color: #fff` -} -``` - -### Escape SVG - -We use the `escape-svg` function to escape the `<`, `>` and `#` characters for SVG background images. When using the `escape-svg` function, data URIs must be quoted. - -### Add and Subtract functions - -We use the `add` and `subtract` functions to wrap the CSS `calc` function. The primary purpose of these functions is to avoid errors when a "unitless" `0` value is passed into a `calc` expression. Expressions like `calc(10px - 0)` will return an error in all browsers, despite being mathematically correct. - -Example where the calc is valid: - -```scss -$border-radius: .25rem; -$border-width: 1px; - -.element { - // Output calc(.25rem - 1px) is valid - border-radius: calc($border-radius - $border-width); -} - -.element { - // Output the same calc(.25rem - 1px) as above - border-radius: subtract($border-radius, $border-width); -} -``` - -Example where the calc is invalid: - -```scss -$border-radius: .25rem; -$border-width: 0; - -.element { - // Output calc(.25rem - 0) is invalid - border-radius: calc($border-radius - $border-width); -} - -.element { - // Output .25rem - border-radius: subtract($border-radius, $border-width); -} -``` - -## Mixins - -Our `scss/mixins/` directory has a ton of mixins that power parts of Bootstrap and can also be used across your own project. - -### Color schemes - -A shorthand mixin for the `prefers-color-scheme` media query is available with support for `light`, `dark`, and custom color schemes. - -{{< scss-docs name="mixin-color-scheme" file="scss/mixins/_color-scheme.scss" >}} - -```scss -.custom-element { - @include color-scheme(dark) { - // Insert dark mode styles here - } - - @include color-scheme(custom-named-scheme) { - // Insert custom color scheme styles here - } -} -``` |