useBreakpoint

Responsive state derived from the window size.

The React Native answer to a media query. Reports the largest Tailwind breakpoint the window satisfies, plus its dimensions and orientation.

For styling, prefer Uniwind's responsive prefixes — md:flex-row costs nothing at runtime. Reach for this hook when the behaviour changes, not just the look: rendering a sheet on a phone and a dialog on a tablet.

Usage

import { useBreakpoint, BottomSheet, Dialog } from 'panelui-native';

function Picker(props) {
  const { isAtLeast } = useBreakpoint();

  return isAtLeast('md') ? <Dialog {...props} /> : <BottomSheet {...props} />;
}

Reading the current breakpoint

const { current, width, isLandscape } = useBreakpoint();
// current: 'base' | 'sm' | 'md' | 'lg' | 'xl'

API Reference

Returns

ValueTypeDescription
current'base' | 'sm' | 'md' | 'lg' | 'xl'Largest breakpoint the window satisfies.
isAtLeast(bp: Breakpoint) => booleanWhether the window is at least that wide.
widthnumberWindow width in px.
heightnumberWindow height in px.
isLandscapebooleanWhether width exceeds height.

Breakpoints

Exported as BREAKPOINTS, matching Tailwind's:

NameMin width
sm640
md768
lg1024
xl1280

On this page