diff --git a/scss/_side-navigation.scss b/scss/_side-navigation.scss index 9c2dcbf0ac..ab8ffc00c2 100644 --- a/scss/_side-navigation.scss +++ b/scss/_side-navigation.scss @@ -1,16 +1,19 @@ .side-nav { - --#{$prefix}side-nav-width: 18.75rem; - --#{$prefix}side-nav-color: #{$black}; - --#{$prefix}side-nav-bg: #{$white}; - --#{$prefix}side-nav-hover-bg: #{$gray-300}; - --#{$prefix}side-nav-active-bg: #{$gray-400}; - --#{$prefix}side-nav-active-border-color: var(--#{$prefix}link-hover-color); - --#{$prefix}side-nav-icon-size: 1.5625rem; - --#{$prefix}side-nav-icon-margin-x: 15px; - --#{$prefix}side-nav-item-height: 2.5rem; - --#{$prefix}side-nav-item-padding-left: var(--#{$prefix}side-nav-icon-margin-x); - --#{$prefix}side-nav-border-width: 1px; - --#{$prefix}side-nav-border-color: #{$gray-500}; + // scss-docs-start side-nav-css-vars + --#{$prefix}side-nav-width: #{$side-nav-width}; + --#{$prefix}side-nav-color: #{$side-nav-color}; + --#{$prefix}side-nav-bg: #{$side-nav-bg}; + --#{$prefix}side-nav-border-width: #{$side-nav-border-width}; + --#{$prefix}side-nav-border-color: #{$side-nav-border-color}; + --#{$prefix}side-nav-icon-size: #{$side-nav-icon-size}; + --#{$prefix}side-nav-icon-margin-x: #{$side-nav-icon-margin-x}; + --#{$prefix}side-nav-item-height: #{$side-nav-item-height}; + --#{$prefix}side-nav-item-padding-left: #{$side-nav-item-padding-left}; + --#{$prefix}side-nav-item-hover-bg: #{$side-nav-item-hover-bg}; + --#{$prefix}side-nav-item-active-bg: #{$side-nav-item-active-bg}; + --#{$prefix}side-nav-item-active-border-color: #{$side-nav-item-active-border-color}; + // scss-docs-end side-nav-css-vars + --#{$prefix}offcanvas-width: var(--#{$prefix}side-nav-width); --#{$prefix}offcanvas-padding-x: 0; --#{$prefix}offcanvas-padding-y: 0; --#{$prefix}offcanvas-border-width: 0; @@ -19,6 +22,16 @@ width: var(--#{$prefix}side-nav-width); height: 100%; overflow: hidden auto; + scrollbar-width: thin; + + &::-webkit-scrollbar { + width: 9px; + background-color: $gray-300; + } + + &::-webkit-scrollbar-thumb { + background-color: $gray-500; + } svg, img { @@ -46,6 +59,10 @@ min-height: subtract(100%, var(--#{$prefix}side-nav-item-height)); scrollbar-width: thin; + @include media-breakpoint-up(lg) { + min-height: 100%; + } + &::-webkit-scrollbar { width: 9px; background-color: $gray-300; @@ -60,7 +77,7 @@ --#{$prefix}accordion-border-width: 0; --#{$prefix}accordion-body-padding-x: 0; --#{$prefix}accordion-body-padding-y: 0; - --#{$prefix}accordion-btn-font-size: 1rem; + --#{$prefix}accordion-btn-font-size: #{$font-size-base}; --#{$prefix}accordion-btn-font-weight: #{$font-weight-normal}; .accordion-body { @@ -106,11 +123,11 @@ border: 0; &:hover { - background-color: var(--#{$prefix}side-nav-hover-bg); + background-color: var(--#{$prefix}side-nav-item-hover-bg); } &.active { - background: linear-gradient(to right, var(--#{$prefix}side-nav-active-border-color), var(--#{$prefix}side-nav-active-border-color) 4px, var(--#{$prefix}side-nav-active-bg) 4px, var(--#{$prefix}side-nav-active-bg)); + background: linear-gradient(to right, var(--#{$prefix}side-nav-item-active-border-color), var(--#{$prefix}side-nav-item-active-border-color) 4px, var(--#{$prefix}side-nav-item-active-bg) 4px, var(--#{$prefix}side-nav-item-active-bg)); } } @@ -139,22 +156,26 @@ [data-focus-visible-added] { z-index: 3; - outline: var(--#{$prefix}side-nav-active-border-color) solid 3px; + outline: var(--#{$prefix}side-nav-item-active-border-color) solid 3px; outline-offset: -3px; } } .side-nav-dark { - --#{$prefix}side-nav-color: #{$white}; - --#{$prefix}side-nav-bg: #{$gray-900}; - --#{$prefix}side-nav-hover-bg: #{$black}; - --#{$prefix}side-nav-active-bg: #{$gray-700}; - --#{$prefix}side-nav-border-color: #{$gray-700}; + // scss-docs-start side-nav-dark-css-vars + --#{$prefix}side-nav-color: #{$side-nav-dark-color}; + --#{$prefix}side-nav-bg: #{$side-nav-dark-bg}; + --#{$prefix}side-nav-border-color: #{$side-nav-dark-border-color}; + --#{$prefix}side-nav-item-hover-bg: #{$side-nav-dark-item-hover-bg}; + --#{$prefix}side-nav-item-active-bg: #{$side-nav-dark-item-active-bg}; + // scss-docs-end side-nav-dark-css-vars } .side-nav-collapsible { - --#{$prefix}side-nav-width: calc(var(--#{$prefix}side-nav-icon-size) + var(--#{$prefix}side-nav-icon-margin-x) * 2); // stylelint-disable-line function-disallowed-list - --#{$prefix}offcanvas-width: 300px; + // scss-docs-start side-nav-collapsible-css-vars + --#{$prefix}side-nav-width: #{$side-nav-collapsible-closed-width}; + --#{$prefix}offcanvas-width: #{$side-nav-collapsible-opened-width}; + // scss-docs-end side-nav-collapsible-css-vars .offcanvas-body { & > :not(.collapse-horizontal) { @@ -174,9 +195,11 @@ } .side-nav-collapsible-content { - --#{$prefix}side-nav-bg: #{linear-gradient(to right, $gray-900, $gray-900 var(--#{$prefix}side-nav-width), $white var(--#{$prefix}side-nav-width))}; - --#{$prefix}side-nav-border-color: #{$gray-700}; - --#{$prefix}offcanvas-width: 325px; + // scss-docs-start side-nav-collapsible-content-css-vars + --#{$prefix}side-nav-bg: #{$side-nav-collapsible-content-bg}; + --#{$prefix}side-nav-border-color: #{$side-nav-collapsible-content-border-color}; + --#{$prefix}offcanvas-width: #{$side-nav-collapsible-content-opened-width}; + // scss-docs-end side-nav-collapsible-content-css-vars .offcanvas-header, .show + * { diff --git a/scss/_variables.scss b/scss/_variables.scss index 90b4f45319..e373252f95 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -2072,4 +2072,33 @@ $footer-terms-padding-y-md: $spacer * 1.1 !default; $footer-gap: $spacer * .75 !default; $footer-gap-xl: $spacer * 1.7 !default; // scss-docs-end footer + +//// Side navigation +// scss-docs-start side-nav-variables +$side-nav-width: $spacer * 15 !default; +$side-nav-color: $black !default; +$side-nav-bg: $white !default; +$side-nav-border-width: map-get($border-widths, 1) !default; +$side-nav-border-color: $gray-500 !default; +$side-nav-icon-size: $spacer * 1.25 !default; +$side-nav-icon-margin-x: 15px !default; +$side-nav-item-height: $spacer * 2 !default; +$side-nav-item-padding-left: $side-nav-icon-margin-x !default; +$side-nav-item-hover-bg: $gray-300 !default; +$side-nav-item-active-bg: $gray-400 !default; +$side-nav-item-active-border-color: var(--#{$prefix}link-hover-color) !default; + +$side-nav-collapsible-closed-width: calc(var(--#{$prefix}side-nav-icon-size) + var(--#{$prefix}side-nav-icon-margin-x) * 2) !default; // stylelint-disable-line function-disallowed-list +$side-nav-collapsible-opened-width: $spacer * 15 !default; + +$side-nav-collapsible-content-bg: linear-gradient(to right, $gray-900, $gray-900 var(--#{$prefix}side-nav-width), $white var(--#{$prefix}side-nav-width)) !default; +$side-nav-collapsible-content-border-color: $gray-700 !default; +$side-nav-collapsible-content-opened-width: $spacer * 16.25 !default; + +$side-nav-dark-color: $white !default; +$side-nav-dark-bg: $gray-900 !default; +$side-nav-dark-border-color: $gray-700 !default; +$side-nav-dark-item-hover-bg: $black !default; +$side-nav-dark-item-active-bg: $gray-700 !default; +// scss-docs-end side-nav-variables // End mod diff --git a/site/content/docs/5.2/components/side-navigation.md b/site/content/docs/5.2/components/side-navigation.md index 6e86f07b7b..79e0b1a93e 100644 --- a/site/content/docs/5.2/components/side-navigation.md +++ b/site/content/docs/5.2/components/side-navigation.md @@ -4,22 +4,29 @@ title: Side Navigation description: Documentation and examples for Boosted's exclusive Brand responsive side navigation. group: components toc: true +added: "5.3" --- ## How it works -Side navigation is based on `.offcanvas-*` class. Please refer to [its documentation]({{< docsref "/components/offcanvas#responsive" >}}) to learn more about its behavior. +Side navigation is based on `.offcanvas-lg` class. Please refer to [Offcanvas]({{< docsref "/components/offcanvas#responsive" >}}) to learn more about its behavior. Since it uses [responsive offcanvas]({{< docsref "/components/offcanvas#responsive" >}}), please resize your browser to see its responsive behavior. -Side navigation may need the Javascript from Accordions, Collapse, Tabs or Tooltips, depending on the implemented navigation, to work correctly. +In the side navigation, each displayed element should have `.side-nav-item` to ensure correct size and behavior. -## Basic +{{< callout warning >}} +In order to make side navigation work properly, please make sure that the Javascript files from [Collapse]({{< docsref "/components/collapse#usage" >}}) and [Tabs]({{< docsref "/components/navs-tabs#javascript-behavior" >}}) are imported in your project. +{{< /callout >}} -{{< example class="p-0 d-block d-lg-flex" >}} - +## Examples -
+### Basic + +{{< example class="p-lg-0 d-block d-lg-flex side-nav-example" >}} + + +
- +
@@ -27,9 +34,6 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt

@@ -48,8 +52,6 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
  • Label
  • Label
  • Label
  • -
  • Label
  • -
  • Label
  • @@ -66,8 +68,6 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
  • Label
  • Label
  • Label
  • -
  • Label
  • -
  • Label
  • @@ -84,8 +84,6 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
  • Label
  • Label
  • Label
  • -
  • Label
  • -
  • Label
  • @@ -94,12 +92,10 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt +

    @@ -109,18 +105,14 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
  • Label
  • Label
  • Label
  • -
  • Label
  • -
  • Label
  • +

    @@ -130,8 +122,6 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
  • Label
  • Label
  • Label
  • -
  • Label
  • -
  • Label
  • @@ -140,78 +130,78 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt +
    Content that should fill the remaining space.
    {{< /example >}} -{{< example class="p-0 d-block d-lg-flex" >}} - +### Basic with icons -
    +{{< example class="p-lg-0 d-block d-lg-flex side-nav-example" >}} + + +
    - +
    -
    +
    -

    -

    -
    +
    -
    +
    -

    -

    -
    -

    -

    -
    -

    -

    -
    + @@ -220,38 +210,42 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
    +
    -

    -

    - +
    -

    -

    -
    + @@ -260,17 +254,28 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
    +
    Content that should fill the remaining space.
    {{< /example >}} -## Collapsible with title +### Collapsible + +To use the collapsible behavior, know that: + +- The toggle arrow is displayed by adding `.side-nav-collapse` to an empty `.side-nav-item`. +- The collapsible navigation width can be set by: + - `--bs-side-nav-width` for the closed state. + - `--bs-offcanvas-width` for the opened state. +- The collapsible side navigation uses [Tooltips]({{< docsref "/components/tooltips#usage" >}}) internally. -{{< example class="p-0 side-nav-example d-block d-lg-flex" >}} - +#### Collapsible basic -
    +{{< example class="p-lg-0 side-nav-example d-block d-lg-flex" >}} + + +
    - +
     
    @@ -280,47 +285,51 @@ Side navigation may need the Javascript from Accordions, Collapse, Tabs or Toolt
    +
    Content that should fill the remaining space.
    {{< /example >}} -## Collapsible with content +#### Collapsible with drawer content -Strongly WIP, onclick functions are a test without extra JS. But fully working example atm. +The collapsible side navigation comes with ready to use `onclick` calls: +- On the Offcanvas toggler button to `show` its content. +- On the Offcanvas close button to `hide` its content. +- On each menu item to `show` its content. (nav-item) -{{< example class="p-0 side-nav-example d-block d-lg-flex" >}} - +{{< example class="p-lg-0 side-nav-example d-block d-lg-flex" >}} + -
    +
    - +
     
    @@ -360,6 +369,18 @@ Strongly WIP, onclick functions are a test without extra JS. But fully working e

    Dashboard

    + +
    +
    +

    Charts

    + +
    +
    +

    Financial

    @@ -381,6 +402,7 @@ Strongly WIP, onclick functions are a test without extra JS. But fully working e
    +

    +

    +

    +

    -
    -
    -

    Charts

    - -
    -
    +
    Content that should fill the remaining space.
    {{< /example >}} -## Right side - -Collapsible side navigation come with a static variant: `.side-nav-static`. - -{{< example class="p-0 side-nav-example d-block d-lg-flex" >}} - - -
    -
    - -
    -
    -
     
    -
    - - +## Static -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    +Collapsible side navigation comes with a static variant: `.side-nav-static`. +
    + +
    +
    + +
    +
    +
     
    +
    + + +
    +
    Content that should fill the remaining space.
    -
    Content that should fill the remaining space.
    -{{< /example >}} -## Collapsible with title +```html + -{{< example class="p-0 side-nav-example d-block d-lg-flex" >}} - +
    +
    ...
    +
    ...
    +
    -
    -
    - -
    -
    -
     
    -
    +
    Content that should fill the remaining space.
    +``` - +## Right sided -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    +Side navigation comes with a right sided variant: `.offcanvas-end`. +
    + +
    +
    + +
    +
    +
     
    +
    + +
      +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    +
    +
    Content that should fill the remaining space.
    + +```html + + +
    +
    ...
    +
    ...
    +
    +
    Content that should fill the remaining space.
    -{{< /example >}} +``` ## Dark variant Side navigation comes with a dark variant: `.side-nav-dark`. -{{< example class="p-0 d-block d-lg-flex bg-dark" >}} - +{{< callout info >}} +Dark variant can be applied on any example except the [Collapsible with drawer content](#collapsible-with-drawer-content) one. +{{< /callout >}} -
    -
    - -
    -
    -
    -
    -

    - -

    -
    -
    -
    -
    -

    - -

    -
    -
    - +
    + +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    +
    +
    +

    + +

    +
    +
    + +
    -
    -
    -

    - -

    -
    -
    - +
    +

    + +

    +
    +
    + +
    -
    -
    -

    - -

    -
    -
    - +
    +

    + +

    +
    +
    + +
    -
    -
    -

    - -

    -
    -
    - +
    +

    + +

    +
    +
    + +
    -
    -
    -

    - -

    -
    -
    - +
    +

    + +

    +
    +
    + +
    +
    Content that should fill the remaining space.
    + +```html + + +
    +
    ...
    +
    ...
    +
    +
    Content that should fill the remaining space.
    -{{< /example >}} +``` + +
    + +
    +
    + +
    +
    +
     
    +
    + + +
    +
    +
    +
    Content that should fill the remaining space.
    +
    + +```html + + +
    +
    ...
    +
    ...
    +
    + +
    Content that should fill the remaining space.
    +``` + +## CSS + +### Variables + +As part of Boosted's evolving CSS variables approach, side navigation now use local CSS variables on `.side-nav` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too. + +{{< scss-docs name="side-nav-css-vars" file="scss/_side-navigation.scss" >}} + +Some additional CSS variables are also present on `.side-nav-collapsible`: + +{{< scss-docs name="side-nav-collapsible-css-vars" file="scss/_side-navigation.scss" >}} + +Some additional CSS variables are also present on `.side-nav-collapsible-content`: + +{{< scss-docs name="side-nav-collapsible-content-css-vars" file="scss/_side-navigation.scss" >}} + +Customization through CSS variables can be seen on the `.side-nav-dark` modifier class where we override specific values without adding duplicate CSS selectors. + +{{< scss-docs name="side-nav-dark-css-vars" file="scss/_side-navigation.scss" >}} + +### Sass variables + +{{< scss-docs name="side-nav-variables" file="scss/_variables.scss" >}}