Search code examples
cssreactjsnpmoverridingweb-component

Override React Component


I have a react component that is being created by a NPM package. I want to alter one of the CSS properties of this component without touching any of the code in this package. In other words, I need a way to inject this CSS property into the component. How do I go about doing this?


Solution

  • A few ideas:

    1st- Depending on the NPM Module you may be able to pass a special class to the component.

    2nd- Try adding a class to the component after rendering.

    3rd- If you can, wrap the component in a div or span with your own class name. This can help by allowing you granularity on your CSS Selector.