Skip to main content
Version: 1.0.2

Breakpoint

Overview

The Breakpoint component provides a declarative way to conditionally render content based on the current viewport size. It eliminates the need for CSS media queries in your React components.

Preview

Installation

npx @mindfiredigital/ignix-ui add breakpoint

Usage

Import the component:

import { Breakpoint } from './components/ui';

Basic Usage

<Breakpoint show="mobile">
<p>This content is visible only on mobile devices.</p>
</Breakpoint>
<Breakpoint hide="desktop">
<p>This content is hidden on desktop devices.</p>
</Breakpoint>
<Breakpoint from="tablet" to="desktop">
<p>This content is visible from tablet to desktop.</p>
</Breakpoint>

Props

PropTypeDescription
show"mobile" | "tablet" | "desktop"Render content only on the specified device.
hide"mobile" | "tablet" | "desktop"Hide content on the specified device.
from"mobile" | "tablet" | "desktop"Render content starting from this breakpoint.
to"mobile" | "tablet" | "desktop"Render content up to this breakpoint.
childrenReactNodeContent to be conditionally rendered.

Examples

Show Content on Mobile

<Breakpoint show="mobile">
<p>This content is visible only on mobile devices.</p>
</Breakpoint>

Hide Content on Desktop

<Breakpoint hide="desktop">
<p>This content is hidden on desktop devices.</p>
</Breakpoint>

Render Content Between Tablet and Desktop

<Breakpoint from="tablet" to="desktop">
<p>This content is visible from tablet to desktop.</p>
</Breakpoint>

Best Practices

  • Use show and hide for simple conditional rendering.
  • Combine from and to for more complex viewport logic.
  • Avoid nesting multiple Breakpoint components unnecessarily.