Is there a version of https://mantine.dev/hooks/use-media-query/ where i can just pass the breakpoint name?
#Breakpoint version of useMediaQuery
6 messages · Page 1 of 1 (latest)
useBreakpoint('sm') will return true on screens sm and bigger. and false otherwise
or something of that sort
I've created a cutom hook that I use in some Mantine project : 😉
export const useCustomMediaQuery = (screenSize = 'sm') => {
const theme = useMantineTheme();
return useMediaQuery(`(max-width: ${theme.breakpoints[screenSize]})`);
};
With this you can pass any breakpoint from the mantine theme
Ohh this is nice! This will return true uptil sm screens right?
Yes it will return true when it's on small device thanks to max-width if you want the opposite behavior use min-width