I were trying to follow this example:
https://www.solidjs.com/tutorial/bindings_classlist?solved
But myApp uses import styles from App.module.css and I do not know how to make it work with styles.selected
#Follow the ClassList example using import styles for styles.selected
13 messages · Page 1 of 1 (latest)
Hi !
With css modules you import like that :
import styles from "./App.module.css"
You can use your class as a key like that : classList={{[styles.myStyle]: current() === 'foo'}}
and how do I put else option ?
in which part ?
myStyle when its foo and myStyle2 when it is something else
hum setting class=mystyles works
classList use an object, so you can add as much properties as you want.
In js, if you want a variable to be a key of an object, you have two way :
myObject = {}followed bymyObject[styles.myStyle] = 'val'- all in once :
myObject = { [styles.myStyle] : 'val'}
yes both solution are available, class & classList add a css class to the dom node
classList help if you want it conditionally
I mean, I use class and classList to highlight it conditionally
but I read it somewhere I shouldn't use both class and classList ?
yeah using both at the same time can be weird sometimes, I don't remember exactly what kind of weird behaviour