Search code examples
reactjscss-modules

Add a general style inside a react component


How can I add general styles to my page inside of one of my components. For example, I when my components loads, I want to add a style like this to whole page:

*{
 direction:rtl;
}

and when the component unmounts, I want the style to be removed. I am using css modules for styling.


Solution

  • We can do it using jsx style:

    <style jsx="true">
                  {`
                    * {
                       direction:rtl;
                      }
                 `}
    </style>