Search code examples
csspostcsscssnext

How to assigned a css-next variable into another one?


Can someone confirm me if this works :

in my .css file, I have:

--pink-1000: #5A003C;

--old-pink: var(--pink-1000);

Will --old-pink have #5A003C as value ?

I'm using :

"postcss-cssnext": "~3.0.2",

Thanks


Solution

  • This is really easy to test yourself:

    :root {
      --pink-1000: #5A003C;
      --old-pink: var(--pink-1000);
    }
    
    p {
      color: var(--old-pink)
    }
    <p>Test</p>

    If you have easy to answer questions, it is often better to first look at MDN or the CSS Spec. You will find answers more quickly there and StackOverflow requires you to at least try to come up with a solution yourself. Just so you know for next time :)

    Links for custom properties ("css variables"):