Visible

Specification

"Visible" component is a utility component that displays the given children when a certain responsive condition is met.

Current implementation utilizes the visibility: hidden and visibility: visible CSS properties for dynamically displayed content. That is to preserve a physical space taken by the component and prevent page jumps during Server-Side Rendering.

Props

<Visible/> component accepts the same props as the <Only/> component. Please refer to its description.

Example

Explicit breakpoint

import React from 'react'
import { Visible } from 'atomic-layout'

export const Post = () => (
  <article>
    {/* Refer to a breakpoint defined in "Layout.configure()" by name */}
    <Visible for="sm">
      <p>Renders on "sm" breakpoint</p>
    </Visible>
    
    {/* Or, provide a custom breakpoint object */}
    <Visible for={{ minWidth: 900, maxWidth: 1000 }}>
      <p>Renders on the custom breakpoint</p>
    </Visible>
  </article>
)

High-pass

High-pass is a display model where the content is shown after a specified breakpoint (incl.).

Low-pass

Low-pass is a display model where the content is displayed prior to a specified breakpoint.

Bell

Bell is a combination of low-pass and high-pass display models. The content is displayed starting from a certain breakpoint, and displayed prior to a certain breakpoint.

Notch

Notch is the reversed variant of the Bell behavior: the content is visible everywhere except the given breakpoints range.

Standalone usage

This component can be used independently from any other components of the library.

Custom breakpoints

Apart from passing defined breakpoint names, you can provide a custom breakpoint Object to the props of this component. The provided breakpoint's options will be used to control the rendering behavior.

Last updated