BridgeBeta
  • Brand
  • Digital Assets
    Foundations
    Icons
    Components
    Templates
  • Resources
    Design Tokens
    How-tos
    Best Practices
    Libraries
    Accessibility
    Products List
  • Support
    • Overview
    • Actions
      • Overview
      • Button
      • ContextMenu
      • Link
    • Controls
      • Overview
      • Checkbox
      • Tag
      • Toggle
    • Forms
      • Overview
      • DatePicker
      • FileUploader
      • Input
      • NumberInput
      • RadioButton
      • Search
      • Select
      • Slider
      • TextArea
      • TextInput
    • Hooks
      • useIsomorphicLayoutEffect
      • useMediaQuery
      • useSettings
    • Navigation
      • Overview
      • AnchorNavigation
      • BannerNavigation
      • Breadcrumb
      • Footer
      • InfoBar
      • MainNavigation
      • SecondaryNavigation
      • StepNavigation
      • SubNavigation
    • Overlay
      • Overview
      • Credits
      • Modal
      • ModalWrapper
      • Notification
      • Tooltip
    • Structure
      • Overview
      • Accordion
      • AuthLayout
      • Avatar
      • Callout
      • Card
      • ContentSwitcher
      • Empty
      • Hero
      • InlineLoading
      • Item
      • List
      • Loading
      • mdxComponents
      • Module
      • Pagination
      • ReadMore
      • Story
      • Table
      • Tabs
      • Text
      • Unit
      • User
      • WFPCoreProvider
      • Wrapper
Components
Hooks

useMediaQuery

Easily retrieve media dimensions with this Hook React which also works onResize.

If you use this hook in an SSR context, set the initializeWithValue option to false.

Before Safari 14, MediaQueryList is based on EventTarget and only supports addListener/removeListener for media queries. If you don’t support these versions you may remove these checks. Read more about this on MDN.

import { useMediaQuery } from "@wfp/react";
export default function Component() {
const matches = useMediaQuery("(min-width: 768px)");
return (
<div>
{`The view port is ${matches ? "at least" : "less than"} 768 pixels wide`}
</div>
);
}

Details on usehooks-ts

Storybook
Figma library
Contact us
2025 © World Food Programme