docs/components/hooks/useBreakpoint.ts

10 строки
281 B
TypeScript

import { useTheme } from '@primer/react'
import { useMediaQuery } from './useMediaQuery'
type Size = 'small' | 'medium' | 'large' | 'xlarge'
export function useBreakpoint(size: Size) {
const { theme } = useTheme()
return useMediaQuery(`(max-width: ${theme?.sizes[size]})`)
}