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'

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}>

Leave a Reply