can I use has selector to look for any new css classes that were added dynamically ?

I wanted to use :has selector to look for a class named dark-mode that is added dynamically in react , so I was wondering if I can do something like body:has('dark-mode'){background:black,color:white}
3 Replies
Coder_Carl
Coder_Carl2y ago
The question I have is: where are you setting .dark-mode
i_lost_to_loba_kreygasm
i will show u
<ChakraProvider>
<Header/>
<Routes>
<Route path='/' element={<Hero/>}/>
<Route path='/about' element={<About/>}/>

</Routes>


</ChakraProvider>
<ChakraProvider>
<Header/>
<Routes>
<Route path='/' element={<Hero/>}/>
<Route path='/about' element={<About/>}/>

</Routes>


</ChakraProvider>
in the header component it has a button smth like this
className={darkMode?'dark-mode':''}
className={darkMode?'dark-mode':''}
Kevin Powell
Kevin Powell2y ago
As long as .dark-mode is a child of the body, which it clearly is, then it works