8

I've imported a few different components in my React project, and most of them have .css files with preset style settings. For the most part, I've been manually changing the CSS files to suit my needs. Is there a way to change the CSS directly from React? That is, is there similar to jquery where i can find the corresponding classes and change the attributes?

2
  • You can only do inline-styling from a React component, apart from setting classes and ids. Commented Jan 25, 2016 at 22:02
  • I would update the stylesheet. Otherwise it will probably become a mess because now there are two places were you are modifying styles. Commented May 3, 2016 at 6:31

1 Answer 1

3

For small changes here and there you can use React Inline Styles.

If you want to modify more things, you can create css/less/scss files that are local to your components and override the styles of imported components there. Here's a good example. Make sure to check the webpack configs that make that work.

Sign up to request clarification or add additional context in comments.

3 Comments

Avoid inline styles like the plague. Seems like a good idea at the time but down the road becomes very difficult to maintain.
Generally yes, but if you have a style that will only apply to this one element, and there's no way to generalize it, than why not? Definitely something not to be abused though.
True. Avoid inline styles like a mild flu.

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.