Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

491 B
Raw Blame
import type { MediaRuleOptions } from "./rules";

/**
 * Check if a media query matches a given width.
 * Only applies to width-based breakpoints (minWidth/maxWidth).
 * Custom condition breakpoints are not matched by this function.
 */
export const matchMedia = (options: MediaRuleOptions, width: number) => {
  const minWidth = options.minWidth ?? Number.MIN_SAFE_INTEGER;
  const maxWidth = options.maxWidth ?? Number.MAX_SAFE_INTEGER;
  return width >= minWidth && width <= maxWidth;
};