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 ?
    – glls
    Oct 23 '19 at 12:25
  • 1
    As per winter 20 release we can share CSS style Rules. For reference salesforcecodex.com/2019/08/…
    – Jill_sfdc
    Oct 23 '19 at 12:43
  • 1
    I 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. Oct 24 '19 at 20:22

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:

$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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.