This component no longer exists. It was in Wednesday UI’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-13 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
Use Media Query
wednesday-ui/use-media-queryRemovedHook
A hook for checking media queries
Install it
npx shadcn@latest add https://ui.ednesdayw.com/r/use-media-query.jsonSource
1"use client";23import { useEffect, useLayoutEffect, useState } from "react";45type UseMediaQueryOptions = {6 defaultValue?: boolean;7 initializeWithValue?: boolean;8};910type MediaSize =11 | "(max-width: 640px)" // sm12 | "(max-width: 768px)" // md13 | "(max-width: 1024px)" // lg14 | "(max-width: 1280px)" // xl15 | "(max-width: 1536px)"; // 2xl1617const IS_SERVER = typeof window === "undefined";1819const useIsomorphicLayoutEffect =20 typeof window !== "undefined" ? useLayoutEffect : useEffect;2122export function useMediaQuery(23 query: MediaSize,24 options?: UseMediaQueryOptions,25): boolean;2627export function useMediaQuery(28 query: string,29 options?: UseMediaQueryOptions,30): boolean;3132export function useMediaQuery(33 query: string,34 {35 defaultValue = false,36 initializeWithValue = true,37 }: UseMediaQueryOptions = {},38) {39 const getMatches = (query: string) => {40 if (IS_SERVER) {41 return defaultValue;42 }43 return window.matchMedia(query).matches;44 };4546 const [matches, setMatches] = useState(() => {47 if (initializeWithValue) {48 return getMatches(query);49 }50 return defaultValue;51 });5253 const handleChange = () => {54 setMatches(getMatches(query));55 };5657 useIsomorphicLayoutEffect(() => {58 const matchMedia = window.matchMedia(query);5960 handleChange();6162 if (matchMedia.addListener) {63 matchMedia.addListener(handleChange);64 } else {65 matchMedia.addEventListener("change", handleChange);66 }6768 return () => {69 if (matchMedia.removeListener) {70 matchMedia.removeListener(handleChange);71 } else {72 matchMedia.removeEventListener("change", handleChange);73 }74 };75 }, [query]);7677 return matches;78}7980export type UseMediaQueryReturn = ReturnType<typeof useMediaQuery>;
