Media
NextUI provides a set of reusable set of media queries.
Media Queries
You can apply different variants at different breakpoints, reduced animations with @motion
or even apply Safari specific styles with @safari
media.
export const media = { xs: `(min-width: ${defaultTokens.breakpoints.xs})`, sm: `(min-width: ${defaultTokens.breakpoints.sm})`, md: `(min-width: ${defaultTokens.breakpoints.md})`, lg: `(min-width: ${defaultTokens.breakpoints.lg})`, xl: `(min-width: ${defaultTokens.breakpoints.xl})`, xsMin: `(min-width: ${defaultTokens.breakpoints.xs})`, smMin: `(min-width: ${defaultTokens.breakpoints.sm})`, mdMin: `(min-width: ${defaultTokens.breakpoints.md})`, lgMin: `(min-width: ${defaultTokens.breakpoints.lg})`, xlMin: `(min-width: ${defaultTokens.breakpoints.xl})`, xsMax: `(max-width: ${defaultTokens.breakpoints.xs})`, smMax: `(max-width: ${defaultTokens.breakpoints.sm})`, mdMax: `(max-width: ${defaultTokens.breakpoints.md})`, lgMax: `(max-width: ${defaultTokens.breakpoints.lg})`, xlMax: `(max-width: ${defaultTokens.breakpoints.xl})`, motion: '(prefers-reduced-motion)', safari: 'not all and (min-resolution:.001dpcm)', hover: '(any-hover: hover)', dark: '(prefers-color-scheme: dark)', light: '(prefers-color-scheme: light)' };
Usage
Here is an example of how to use the NextUI media queries:
Note: If you want to see the changes in the preview, you need to resize the browser window.