ilokesto

Media

Media renders children based on a CSS media query match. With a render prop it receives the matches boolean; otherwise it renders children when the query matches and fallback when it does not.

import { Media } from '@ilokesto/utilinent';

<Media query="(min-width: 768px)">{(matches) => matches ? <Desktop /> : <Mobile />}</Media>

<Media query="(min-width: 768px)" fallback={<MobileNav />}><DesktopNav /></Media>

Props

PropTypeDescription
querystringA CSS media query string.
childrenReactNode | (matches) => ReactNodeContent or render prop.
fallbackReactNodeRendered when the query does not match (non-render-prop usage). Defaults to null.

On this page