🎉 Black Friday deal! 30% off your first year of CodyHouse Pro →

Projects

Progress value is 30%

Visibility

How to hide/show elements in CodyFrame.


🎥 CodyFrame visibility classes
🕐 9:16

🔍 On this page:

  1. Visibility property
  2. Display property
  3. Display/hide at specific breakpoints
  4. is-visible/is-hidden classes
  5. No-JS
  6. Print

Visibility property #

Visibility utility classes:

Class Description
.visible visibility: visible;
.invisible visibility: hidden;

Edit the visibility utility classes at specific breakpoints adding the @{breakpoint} suffix (@xs, @sm, @md, @lg, @xl - e.g., [email protected]).

Display property #

Display utility classes:

Class Description
.block display: block;
.flex display: flex;
.inline-block display: inline-block;
.inline-flex display: inline-flex;
.inline display: inline;
.contents display: contents;
.hide display: none;

Edit the display utility classes at specific breakpoints adding the @{breakpoint} suffix (@xs, @sm, @md, @lg, @xl - e.g., [email protected]).

Display/hide at specific breakpoints #

Use the [email protected]{breakpoint} classes to show an element at a specific breakpoint:

<div class="component [email protected]"></div>

<style>
  .component {
    display: inline-flex;
  }
</style>

Unlike the display property utility classes, when you apply the [email protected] class to an element, for example, you're automatically hiding it (display: none) until the medium breakpoint, when its display value is changed to the one declared in CSS (in the above example → inline-flex).

This is possible because we use the "not" media query logic: 

@include breakpoint(md, "not all") {
  .display\@md { 
    display: none !important; 
  }
}

// in CSS it compiles to 👇
@media not all and (min-width: 64rem) {
  .display\@md {
    display: none !important;
  }
}

You can combine the [email protected]{breakpoint} utility classes with the display property utility classes:

<div class="component inline-flex [email protected]">
  <!-- ... -->
</div>

Or use only the display property utility classes:

<div class="component hide [email protected]">
  <!-- ... -->
</div>

is-visible/is-hidden classes #

The .is-visible/.is-hidden utility classes can be used to toggle the display value of an element regardless of the breakpoint.

We define the --display variable so that you can set any display value you want on a component level by updating the CSS variable (you don't need to set the variable if display = block, which is the default value of the variable).

:root {
  --display: block;
}

.is-visible {
  display: var(--display) !important;
}

.is-hidden {
  display: none !important;
}

.component {
  display: none;
  --display: flex;
}

no-js #

To hide an element if JavaScript is disabled by the user, use the .no-js:is-hidden class:

<button class="no-js:is-hidden">Show sidebar</button>

Print #

To hide an element if the page is printed, use the .print:is-hidden class:

<header class="print:is-hidden"></header>
<main></main>
<footer class="print:is-hidden"></footer>

Project duplicated

Project created

Globals imported

There was an error while trying to export your project. Please try again or contact us.