useMediaQuery
Reactive media queries with named breakpoints, ranges, and pointer queries.
Overview
Copy the source into your project, then import the parts you need. Styles use local StyleX declarations and shared theme tokens. You can change the source without wrapping or replacing a package.
Installation
Run bunx @yopem-ui/cli init from your project root first. The CLI configures StyleX and installs shared files and dependencies.
Run from your project root. The CLI installs required components, shared files, and packages. Previews may need additional components. Existing files are preserved. To refresh installed source, use update; locally edited files need an explicit --force to overwrite.
Preview
Live viewport breakpoint matches
Usage
Pass a breakpoint (sm, md, lg, xl, 2xl, 3xl, or 4xl), max-md, a range such as sm:max-lg, or a raw CSS media query. Named widths are 640, 800, 1024, 1280, 1536, 1600, and 2000 pixels respectively.
Object queries accept min, max, and pointer (coarse or fine). Minimum widths are inclusive and maximum widths exclusive. Server snapshots return false; matchMedia change listeners update the client and unsubscribe on unmount or query changes.
Import from the local file installed by the CLI.
API reference
Generated from canonical TypeScript source. Only component and Base UI props appear below. Required marks a required property, not a required component.