MediaQuery
Apply styles to children if media query matches
Import
Source
Docs
Package
Usage
MediaQuery component adds styles to child element if given media query matches:
(max-width: 1200px) and (min-width: 800px) breakpoints
largerThan and smallerThan props
largerThan
and smallerThan
props lets you use theme.breakpoints
:
- larger than lg
- Smaller than lg
- Smaller than xl, larger than sm
- Smaller than 1500px, larger than 800px
Configure breakpoints
Mantine uses Bootstrap's breakpoint values as defaults:
Breakpoint | Viewport width |
---|---|
xs | 576px |
sm | 768px |
md | 992px |
lg | 1200px |
xl | 1400px |
To change these values wrap your application with MantineProvider and set breakpoints
prop on theme:
MediaQuery children
MediaQuery always work with single child and uses className
prop to add styles,
child component must accept it otherwise styles will not be applied the element:
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback