I have created a React Component that uses css modules.
I have a Logo component:
import * as React from 'react';
import * as styles from './Logo.module.scss';
import appLogo from "../../assets/logo.png";
interface ILogoProps {
logo?: object,
alt?: string,
externalStyle?: Object
}
export const MyLogo = ({logo, alt, externalStyle} : ILogoProps ):
React.ReactElement<ILogoProps > => {
const defaultLogo = logo? logo : appLogo;
const defaultAlt = alt? alt : 'MY Logo';
return (
<div className={[styles.logo, externalStyle].join(' ')} >
<img src={defaultLogo} alt={defaultAlt}/>
</div>
);
};
export default MyLogo;
.logo{
height: 40px;
background-color: rgba(255,255,255,0.01);
}
I am trying to override the defult background color for the logo by passing in External styles
.test{
background-color: #721c24;
height: 100px;
}
But the css modules that i pass in externally is not able to override the local css of the Logo component.
Note
I have read across several Stackoverflow posts that this is not possible as the Local Css modules cannot be overidden.
By using important in the overriding style it works, but that dosent feel right to me.
Is there any other solution apart from this?