From 4c06e34d87ab1d44124f0e32cc2426d727ba41e1 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 24 May 2022 10:50:03 -0700 Subject: [PATCH] Add horizontal collapse support --- scss/_transitions.scss | 6 +++++ scss/_variables.scss | 1 + site/content/docs/4.6/components/collapse.md | 23 ++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/scss/_transitions.scss b/scss/_transitions.scss index 40be4d918add..a261f2ddc5d8 100644 --- a/scss/_transitions.scss +++ b/scss/_transitions.scss @@ -17,4 +17,10 @@ height: 0; overflow: hidden; @include transition($transition-collapse); + + &.width { + width: 0; + height: auto; + @include transition($transition-collapse-width); + } } diff --git a/scss/_variables.scss b/scss/_variables.scss index 319a719b918c..293d238b970b 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -257,6 +257,7 @@ $caret-spacing: $caret-width * .85 !default; $transition-base: all .2s ease-in-out !default; $transition-fade: opacity .15s linear !default; $transition-collapse: height .35s ease !default; +$transition-collapse-width: width .35s ease !default; $embed-responsive-aspect-ratios: () !default; $embed-responsive-aspect-ratios: join( diff --git a/site/content/docs/4.6/components/collapse.md b/site/content/docs/4.6/components/collapse.md index 020237cfd509..2c94415084ef 100644 --- a/site/content/docs/4.6/components/collapse.md +++ b/site/content/docs/4.6/components/collapse.md @@ -40,6 +40,29 @@ Generally, we recommend using a button with the `data-target` attribute. While n {{< /example >}} +## Horizontal + +The collapse plugin also supports horizontal collapsing. Add the `.width` modifier class to transition the `width` instead of `height` and set a `width` on the immediate child element. Feel free to write your own custom Sass, use inline styles, or use our [width utilities]({{< docsref "/utilities/sizing" >}}). + +{{< callout info >}} +Please note that while the example below has a `min-height` set to avoid excessive repaints in our docs, this is not explicitly required. **Only the `width` on the child element is required.** +{{< /callout >}} + +{{< example >}} +

+ +

+
+
+
+ This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered. +
+
+
+{{< /example >}} + ## Multiple targets A `