Leave Yamada UI a star

Star
Yamada UIYamada UIv1.7.2

useMediaQuery

useMediaQuery is a custom hook that detects whether it matches a single or multiple media queries.

Source@yamada-ui/use-media-query

Import

import { useMediaQuery } from "@yamada-ui/react"
Copied!

Usage

Editable example

const [isLarge, isDark] = useMediaQuery([
  "(min-width: 1280px)",
  "(prefers-color-scheme: dark)",
])

return (
  <>
    <Text>{isLarge ? "larger than 1280px" : "smaller than 1280px"}</Text>
    <Text>{isDark ? "color mode is dark" : "color mode is light"}</Text>
  </>
)
Copied!

Edit this page on GitHub

PrevioususeLocalStorageNextuseNotice