After encountering a problem in my React app where I had a mix of inline JS styles and CSS classes, I made the decision to separate everything into CSS modules for more organized styling. Now, I import these modules like so:
import styles from './ImageTextOption.module.css'
. This allows me to use them as JS objects.
However, I noticed that styles no longer cascade from parent elements that are not defined in the same module. For example, I had a selector like .selected .option-text
, but even though I have the selected
class applied outside, the unique name transformation of option-text
prevents it from matching the option-text
element inside the selected
element. What is the correct approach to make them match again when using CSS modules?