Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Navbar.module.css usage

I am very new to this react stuff. I tried to add styling to my navbar component from module CSS file but it is showing me an error where style can only have objects, not strings.

Below is my code for react component.

I have first imported the file :
import styles from './Components/Navbar.module.css'

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Then i tried to give the styles to my component div :

<div className='navbar' style = {styles.navbar}>

I would appreciate your help!

Everything has been mentioned above. Please Help!

>Solution :

Here you are assigning a className as string, rather assign the {styles.navbar} to className and remove the style attribute. This is because the {styles.navbar} is a string and it will assign the component styles as per the className. This will fix your code.

<div className={styles.navbar}>

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading