Open devanihiren opened 3 days ago
create-react-library are almost 4 years old and haven't been updated since then. I wouldn't recommend to use it.
However you cannot use it in this ways in SPFx. SPFx uses CSS Modules
So when you use your component it will become something like:
.header_abcdef{
color: red !important;
}
Which is not applied on your div element, which still has the className of just heading
and not heading_abcdeg
.
You could make it work if you import the style file from the library in the SPFx library something like this.
@use 'sass:meta';
:global{
@include meta.load-css('path-to-library-css/lib.css')
}
Tried CSS Modules Not working
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
None
What browser(s) / client(s) have you tested
Additional environment details
Describe the bug / error
Want to use custom react library to the webpart below is component of the react library
below is style.css file .heading { color: red !important; }
above class not change color of the text text color changes when i apply CSS file from the SPFx webpart or inline CSS only works.
How i can use library CSS class for the styling
Steps to reproduce
npx create-react-library
Cd
Npm pack
Install generated .tgz in SPFx Project
use like other library
Expected behavior
Want to affect style clas from the library stylle.css file