UNPKG

@intility/bifrost-react

Version:

React library for Intility's design system, Bifrost.

21 lines (20 loc) 492 B
"use client"; import useMediaQuery from "./useMediaQuery.js"; const map = { small: 600, medium: 960, large: 1280, xl: 1600, xxl: 1920 }; export default function useBreakpoint(from, to) { const matchArray = []; if (from) { matchArray.push(`(min-width: ${map[from]}px)`); } if (to) { matchArray.push(`(max-width: ${map[to] - 1}.9px)`); } const matchString = matchArray.join(" and "); return useMediaQuery(matchString) ?? false; }