For my personal project, I am incorporating Radix components alongside radix-ui/colors. However, when attempting to import color variables into the CSS Module, I encountered an error. It seems that using the :root selector in the _app file is necessary, as importing colors from the global stylesheet does not impact the component.module.css files, resulting in the variables' values not being read.
Here's the content of the globals.css file:
@import '../../node_modules/@radix-ui/colors/blackA.css';
@import '../../node_modules/@radix-ui/colors/green.css';
@import '../../node_modules/@radix-ui/colors/mauve.css';
@import '../../node_modules/@radix-ui/colors/violet.css';
@import '../../node_modules/@radix-ui/colors/whiteA.css';
And here's the content of the _app file:
import '../styles/globals.css'
import NiceModal from '@ebay/nice-modal-react'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
return (
<NiceModal.Provider>
<Component {...pageProps} />
</NiceModal.Provider>
)
}
I'm wondering if there is a way to effectively utilize color variables with Next.js and vanilla CSS without resorting to the styled-components / stitches approach recommended in the Radix documentation. Attempting to import variables directly into the module.css files resulted in an error.