0

I want to pass css variable into my media query but I don't know how.

It's a Next.Js project, and I use theme-ui's sx property to assign style.

const styles = {

    headerLinkContainer: {
        width: '500px',
        justifyContent: 'space-evenly',
        alignItems: 'center',
        "@media screen and (min-width: var(--medium-devices))": {
            display: 'none',
        }
    },
}

I tried "@media screen and (min-width: 'var(--medium-devices)')" but it doesn't work.

Can you help me guys ?

0

1 Answer 1

0

You cannot use media queries in js. The best solution is this:

if (window.matchMedia("(min-width: 600px)").matches) {
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you ! Also I found an answer here if someone needs it stackoverflow.com/questions/40722882/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.