diff options
author | Mark Otto <markd.otto@gmail.com> | 2022-10-23 00:13:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-23 00:13:39 +0300 |
commit | 0968db80997613828634ddb4b2c3980871f0ed41 (patch) | |
tree | 385a5a0161d0537ad1f81e679c39a1288fc64d8d | |
parent | bbe1ffdb680eba550604df167ec32bf1505ca8e1 (diff) |
Add `z-index` utilities, `.z-*` (#37317)
* Add z-index utilities, .z-*
* Fix missing comma in _utilities.scss
* Fix bundlewatch
* Fix lint
* Update site/content/docs/5.2/utilities/z-index.md
Co-authored-by: Julien Déramond <julien.deramond@orange.com>
* custom appearance
* linter
Co-authored-by: Julien Déramond <juderamond@gmail.com>
Co-authored-by: Julien Déramond <julien.deramond@orange.com>
-rw-r--r-- | .bundlewatch.config.json | 2 | ||||
-rw-r--r-- | scss/_utilities.scss | 7 | ||||
-rw-r--r-- | scss/_variables.scss | 10 | ||||
-rw-r--r-- | site/assets/scss/_component-examples.scss | 26 | ||||
-rw-r--r-- | site/content/docs/5.2/utilities/z-index.md | 46 | ||||
-rw-r--r-- | site/data/sidebar.yml | 1 |
6 files changed, 90 insertions, 2 deletions
diff --git a/.bundlewatch.config.json b/.bundlewatch.config.json index 8c390c6e0e..a14a0a15a7 100644 --- a/.bundlewatch.config.json +++ b/.bundlewatch.config.json @@ -26,7 +26,7 @@ }, { "path": "./dist/css/bootstrap.css", - "maxSize": "29.5 kB" + "maxSize": "29.75 kB" }, { "path": "./dist/css/bootstrap.min.css", diff --git a/scss/_utilities.scss b/scss/_utilities.scss index 7a597046b3..d69f89a982 100644 --- a/scss/_utilities.scss +++ b/scss/_utilities.scss @@ -703,8 +703,13 @@ $utilities: map-merge( visible: visible, invisible: hidden, ) - ) + ), // scss-docs-end utils-visibility + "z-index": ( + property: z-index, + class: z, + values: $zindex-levels, + ) ), $utilities ); diff --git a/scss/_variables.scss b/scss/_variables.scss index 132c5dbb0e..dd4bf01261 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -1054,6 +1054,16 @@ $zindex-tooltip: 1080 !default; $zindex-toast: 1090 !default; // scss-docs-end zindex-stack +// scss-docs-start zindex-levels-map +$zindex-levels: ( + n1: -1, + 0: 0, + 1: 1, + 2: 2, + 3: 3 +) !default; +// scss-docs-end zindex-levels-map + // Navs diff --git a/site/assets/scss/_component-examples.scss b/site/assets/scss/_component-examples.scss index f4865daf8a..8f39b2209a 100644 --- a/site/assets/scss/_component-examples.scss +++ b/site/assets/scss/_component-examples.scss @@ -302,6 +302,32 @@ min-height: 240px; } +.bd-example-zindex-levels { + min-height: 15rem; + + > div { + background-color: tint-color($bd-violet, 75%); + border: 1px solid tint-color($bd-violet, 50%); + } + + > :nth-child(2) { + top: 3rem; + left: 3rem; + } + > :nth-child(3) { + top: 4.5rem; + left: 4.5rem; + } + > :nth-child(4) { + top: 6rem; + left: 6rem; + } + > :nth-child(5) { + top: 7.5rem; + left: 7.5rem; + } +} + // // Code snippets // diff --git a/site/content/docs/5.2/utilities/z-index.md b/site/content/docs/5.2/utilities/z-index.md new file mode 100644 index 0000000000..afd667474f --- /dev/null +++ b/site/content/docs/5.2/utilities/z-index.md @@ -0,0 +1,46 @@ +--- +layout: docs +title: Z-index +description: Use our low-level `z-index` utilities to quickly change the stack level of an element or component. +group: utilities +toc: true +--- + +## Example + +{{< added-in "5.3.0" >}} + +Use `z-index` utilities to stack elements on top of one another. Requires a `position` value other than `static`, which can be set with custom styles or using our [position utilities]({{< docsref "/utilities/position/" >}}). + +{{< callout >}} +We call these "low-level" `z-index` utilities because of their default values of `-1` through `3`, which we use for the layout of overlapping components. High-level `z-index` values are used for overlay components like modals and tooltips. +{{< /callout >}} + +{{< example class="bd-example-zindex-levels position-relative" >}} +<div class="z-n1 position-absolute p-5 rounded-3"></div> +<div class="z-0 position-absolute p-5 rounded-3"></div> +<div class="z-1 position-absolute p-5 rounded-3"></div> +<div class="z-2 position-absolute p-5 rounded-3"></div> +<div class="z-3 position-absolute p-5 rounded-3"></div> +{{< /example >}} + +## Overlays + +Bootstrap overlay components—dropdown, modal, offcanvas, popover, toast, and tooltip—all have their own `z-index` values to ensure a usable experience with competing "layers" of an interface. + +Read about them in the [`z-index` layout page]({{< docsref "/layout/z-index" >}}). + +## Component approach + +On some components, we use our low-level `z-index` values to manage repeating elements that overlap one another (like buttons in a button group or items in a list group). + +Learn about our [`z-index` approach]({{< docsref "/extend/approach#z-index-scales" >}}). + +## CSS + +### Sass map + +Customize this Sass map to change the available values and generated utilities. + +{{< scss-docs name="zindex-levels-map" file="scss/_variables.scss" >}} + diff --git a/site/data/sidebar.yml b/site/data/sidebar.yml index c35631add4..51c60ba62d 100644 --- a/site/data/sidebar.yml +++ b/site/data/sidebar.yml @@ -133,6 +133,7 @@ - title: Text - title: Vertical align - title: Visibility + - title: Z-index - title: Extend icon: tools |