Anukriti
Anukriti

Reputation: 31

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!

Upvotes: 1

Views: 398

Answers (1)

Snehil Agrahari
Snehil Agrahari

Reputation: 288

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

Upvotes: 1

Related Questions