1

With Lightning most of my use case has been creating a component and adding it to the Lightning app builder page. I use just to preview my component behavior from developer console.

Having said this I see developers/salesforce docs load the SLDS as static resource and reference it in components using ltng:require

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/apps_slds.htm

http://www.sfdcmonkey.com/2016/12/26/use-lightning-design-system-framework/

The major disadvantage I see with this method is getting struck to a specific version and constantly having to update the slds version in the static resource to the latest version from the server. Is there any way I can extend/ implement the force:slds as an interface at a component level?

For the sake of argument if I use only lightning:XXXX components in my code, I will inherit lightning styling by default but this is not possible all the time. When using ui:XXX and custom html components I will have to use the SLDS as a static resource to apply styling on my non lightning:XXXX components.

Am I missing something basic (or) is loading SLDS as a static resource the only way to use SLDS at a component level?

  • 1
    You don’t need to load anything. The slds just works by default in lightning. Am I misunderstanding your question? I don’t even use the extends:slds – Eric Oct 13 '17 at 0:32
  • @Eric can you post that as an answer, I always thought slds has to be included through ltng:require to apply the style to in a custom component. I missed the basic concept that SLDS is part of lightning and <button class="slds-button slds-button_neutral">Refresh</button> would resolve with lightning styles applied because as you said slds is part of lightning. – Rao Oct 13 '17 at 0:51
  • Done. Not sure what the use case is for extending force:slds is though – Eric Oct 13 '17 at 1:32
2

You don’t need to load anything. The slds just works by default in lightning

I may be missing some use cases though as I am not sure why there is documentation stating you should extend force:slds when I have never needed to.....

  • My guess is Including the force:slds as static resource may have been relevant when exposing component in a vf page prior to winter 18 , but with lightstylesheets= true / apex:slds option at the apex:page level we may no more need slds as static resource – Rao Oct 13 '17 at 1:43
  • @Rao - Yea, but the extends="force:slds" is only relevant to the lightning component so not sure what its purpose is now yet the winter 18 documentation still includes it – Eric Oct 13 '17 at 1:46
  • In a application perspective, you still need the extends=force:slds in your aura:application and when previewing the component from the developer console right? – Rao Oct 13 '17 at 1:50
  • @Rao - not sure. I have never had to use it. Then again I don't use dev console at all so maybe. I have several lightning applications but none of them use the force:slds and they work just fine since lightning automatically includes the styles – Eric Oct 13 '17 at 1:52
  • 2
    When you include <c:component> inside aura:application from dev console my understanding is the aura:application works like a stand alone app/ a seperate container where the page does not have context of lightning stylesheets, hence we need to extend force:slds to apply the lightning style sheets – Rao Oct 13 '17 at 1:56

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.