Is it possible to use Lightning web component Css in Aura component Bundle or Visual Force Page?
-
what do you mean lightning web component css ?– gllsOct 23, 2019 at 12:25
-
1As per winter 20 release we can share CSS style Rules. For reference salesforcecodex.com/2019/08/…– Jill_sfdcOct 23, 2019 at 12:43
-
1I think you can only share the CSS style rules between LWC components - this works because you import the css. AURA components are namespaced which will prevent the css from working.– Caspar HarmerOct 24, 2019 at 20:22
1 Answer
It's impossible to import the LWC CSS into an Aura.
However I had the same need so what I ended up doing is move the LWC CSS into a static resource CSS file. After that I imported that CSS in the Aura component and LWC component that needed it. This works.
Here's how to do it in Aura:
<ltng:require styles="{!$Resource.resourceName}" />
And for multiple CSS files:
styles="{!join(',',
$Resource.myStyles + '/stylesheetOne.css',
$Resource.myStyles + '/moreStyles.css')}"
And here's how to do it in LWC:
import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
import resourceName from '@salesforce/resourceUrl/resourceName';
loadStyle(this, resourceName + '/stylesheet.css');