I was looking for a library something that has a similar behaviour like twMerge
. For example:
twMerge('p-0 p-10 p-4')
results in applying the style p-4
now, If I define a default for a React component as
MyBaseComponent
with it’s default styles in MyBaseComponent.module.scss
, and later I want to override the custom styling if I compose this component into another component, I’d like to do something like this without using booleans
MyExtendedComponent containerClassName={styles.MyExtendedContainer}
where the base component would have something like
function MyBaseComponent(props) {
return <div className={customCompose(props.containerClassName, styles.baseContainer)}>
... </div>
}
and the properties that are overridden by containerClass
should take precedence.
twMerge seems to only work for tailwind classes, clsx and other libs don’t override modular scss. I’m wondering if there is any solution to achieve the above.