2

Is it possible to use Lightning web component Css in Aura component Bundle or Visual Force Page?

3
  • what do you mean lightning web component css ?
    – glls
    Commented Oct 23, 2019 at 12:25
  • 1
    As per winter 20 release we can share CSS style Rules. For reference salesforcecodex.com/2019/08/…
    – Jill_sfdc
    Commented Oct 23, 2019 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. Commented Oct 24, 2019 at 20:22

1 Answer 1

2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .