diff --git a/ui/utilities/visibility/flavors/responsive/_index.scss b/ui/utilities/visibility/flavors/responsive/_index.scss index c90cde70b0..60156e636a 100644 --- a/ui/utilities/visibility/flavors/responsive/_index.scss +++ b/ui/utilities/visibility/flavors/responsive/_index.scss @@ -13,3 +13,32 @@ @include visibility(small, $mq-small, $mq-medium); @include visibility(medium, $mq-medium, $mq-large); @include visibility(large, $mq-large); + +// Generates responsive visibility tags +@each $key, $value in ( + 'x-small': $mq-x-small, + 'small': $mq-small, + 'medium': $mq-medium, + 'large': $mq-large, + 'x-large': $mq-x-large, +) { + @media(min-width: $value) { + // [EXAMPLE] slds-hide--medium: + // HIDES the element when window is BIGGER than medium. + // element will be displayed normaly when window is smaller. + .slds-hide--#{$key} { + // !important is required to increase specificity + display: none !important; + } + } + + @media(max-width: $value - 1px) { + // [EXAMPLE] slds-show--medium: + // HIDES the element when window is SMALLER than medium. + // element will be displayed normaly when window is bigger. + .slds-show--#{$key} { + // !important is required to increase specificity + display: none !important; + } + } +} diff --git a/ui/utilities/visibility/flavors/responsive/index.markup.md b/ui/utilities/visibility/flavors/responsive/index.markup.md index fedd4eeea4..29d95a1ecc 100644 --- a/ui/utilities/visibility/flavors/responsive/index.markup.md +++ b/ui/utilities/visibility/flavors/responsive/index.markup.md @@ -1,4 +1,7 @@ -
Responsive visibility classes will show and hide content on specific breakpoints. By default, -show
renders as display: block;
, but you may pass through a display property of your choice by adding a modifier to the end of the classname. For example, you may need to render an element as display: inline-block
at a medium breakpoint, adding --inline-block
to the end of .slds-medium-show
to produce the class of .slds-medium-show--inline-block
will give you that outcome.
Responsive visibility classes will HIDE content on specific breakpoints.
+slds-show--[breakpoint]
renders display: none;
when the the view port width is smaller than the breakpoint, and do nothing if it is bigger or equal.
+slds-hide--[breakpoint]
does the oposite by rendering display: none;
when the the view port width is bigger or equal than the breakpoint, and do nothing if it is smaller.
+
.slds-x-small-show
.slds-hide--x-small
.slds-small-show
.slds-show--x-small
.slds-medium-show
.slds-hide--small
.slds-large-show
.slds-show--small
.slds-x-small-show-only
.slds-hide--medium
.slds-small-show-only
.slds-show--medium
.slds-hide--large
.slds-medium-show-only
.slds-show--large
.slds-max-x-small-hide
.slds-hide--x-large
.slds-max-small-hide
.slds-show--x-large
.slds-max-medium-hide