The HideAtBreakpoint component can be used to quickly hide a component at a particular breakpoint.
Basic Usage
It takes two props, minWidth
and maxWidth
for the minimum and maximum widths, specified in pixels.
import React from 'react';import { Card, CardBody, HideAtBreakpoint, magma } from 'react-magma-dom';export function Example() {return (<><HideAtBreakpoint maxWidth={599}><Card isInverse background={magma.colors.primary700}><CardBody><strong>Max-Width:</strong> This text will be visible when thebrowser width is greater than or equal to 600px.</CardBody></Card><br /></HideAtBreakpoint><HideAtBreakpoint minWidth={600} background={magma.colors.info}><Card isInverse background={magma.colors.success}><CardBody><strong>Min-Width:</strong> This text will be visible when thebrowser width is less than 600px.</CardBody></Card><br /></HideAtBreakpoint><HideAtBreakpoint><Card isInverse background={magma.colors.success}><CardBody>This text will always be visible.</CardBody></Card></HideAtBreakpoint></>);}
Hide at Breakpoint Props
This component uses forwardRef
. The ref is applied to the outer div
element.
All of the global HTML attributes can be provided as props and will be applied to the wrapping div
element that gets rendered.
children
Description
The content of the component
Type
ReactNode | undefined
Default
-
displayType
Type
enum, one of:
HideAtBreakpointDisplayType.block
HideAtBreakpointDisplayType.flex
HideAtBreakpointDisplayType.inline
HideAtBreakpointDisplayType.inlineFlex
Default
HideAtBreakpointDisplayType.block
maxWidth
Description
Maximum width at which to hide the content
Type
number
Default
-
minWidth
Description
Minimum width at which to hide the content
Type
number
Default
-
On this page