Skip to content

Instantly share code, notes, and snippets.

View parkournick3's full-sized avatar
🥝

Nicolas parkournick3

🥝
View GitHub Profile
@parkournick3
parkournick3 / useTailwindBreakpoint.ts
Last active May 27, 2023 16:07 — forked from SimeonGriggs/useTailwindBreakpoint.js
React (and NextJS, Typescript) Hook which returns the current TailwindCSS breakpoint size based on the current window width.
import { useEffect, useState } from 'react'
import throttle from 'lodash.throttle'
import resolveConfig from 'tailwindcss/resolveConfig'
import tailwindConfig from '../../tailwind.config'
type Breakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl'
const findKeyByValue = (object: { [x: string]: unknown }, value: string) =>