0

We are currently working on a project where, project structure demo: enter image description here

whenever i use pdf.js and pdf.css in seperate project then it works perfectly.But when i put that pdf js and css inside this project ,then the css of the projects overriding the pdf.css

is there any way to use separate css files each component? i have tried doing modules.css ,but i have to change the existing all css for that, please provide some suggestion

1 Answer 1

1

Here is a reference to React's docs. Basically you need to name your file {file_name}.module.css, where the file extension needs to end with module.css

Then you can use like this, as shown on React example:

Class based component

import React, { Component } from 'react';
import styles from './Button.module.css'; // Import css modules stylesheet as styles
import './another-stylesheet.css'; // Import regular stylesheet

class Button extends Component {
  render() {
    // reference as a js object
    return <button className={styles.error}>Error Button</button>;
  }
}

Functional base component

import React, { Component } from 'react';
import styles from './Button.module.css'; // Import css modules stylesheet as styles
import './another-stylesheet.css'; // Import regular stylesheet

const Button = () => {
  return <button className={styles.error}>Error Button</button>
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer,it's a good solution,i've tried in this way earlier,but in this case it is not working for some reason

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.