Documentation
useBreakpoint

useBreakpoint

The useBreakpoint hook provides an easy way to determine the current viewport size based on predefined theme breakpoints. It returns an object with boolean values representing whether the viewport is considered mobile, tablet, laptop, or desktop.

Usage

First, you need to import the useBreakpoint hook from the kitchn package.

import { useBreakpoint } from "kitchn";

Example

You can use the useBreakpoint hook to conditionally render components based on the current viewport size.

Parameters

The useBreakpoint hook does not accept any parameters.

Return Value

The useBreakpoint hook returns an object with the following properties:

NameTypeDescription
isMobilebooleantrue if the viewport width is equal to or less than the mobile breakpoint defined in the theme.
isTabletbooleantrue if the viewport width is equal to or less than the tablet breakpoint defined in the theme.
isLaptopbooleantrue if the viewport width is equal to or less than the laptop breakpoint defined in the theme.
isDesktopbooleantrue if the viewport width is equal to or less than the desktop breakpoint defined in the theme.