2

I'm looking to build a custom Lightning Application (not a Lightning Component). Now, SLDS base component does work nice, I've noticed that Themes & Branding applied theme color do not gets affected in the app.

So, if I place a button like this:

<aura:application extends="force:slds">
     <lightning:button variant="brand" label="Save" />
</aura:application>

The button is rendered in the default SLDS styled colors in Lightning Application (code above):

enter image description here

<aura:component >
     <lightning:button variant="brand" label="Save" />
</aura:component>

While if I use same button code in a Lightning Component (code above):

enter image description here

2
  • where are you hosting that application? As component is hosted in one.app container it recives the theme css from the parent one.app May 2, 2018 at 19:58
  • Well, it's a lightning application, I don't think we can host it inside one.app, it is it's own app :), thus wanted to know, if there is any way to determine Lightning Experience Theme branding?
    – VarunC
    May 2, 2018 at 20:23

1 Answer 1

0

This isn't ideal as it takes an API call to retrieve, but you can use the User Interface API to retrieve the active theme from your apex controller.

https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_themes_active.htm

Make a GET request to /ui-api/themes/active and you should retrieve a response with brandColor, brandImage, defaultGroupBanner, defaultGroupImage, defaultPageBanner, defaultUserBanner, defaultUserImage, headerColor, linkColor, and pageColor attributes. You can than use these to style your app.

2
  • Can we retrieve Active Theme fromLightning Component without UI API call? If so I can retrieve and possibly pass the theme in Lightning Application url parameters.
    – VarunC
    May 3, 2018 at 16:28
  • I don't believe it is possible to retrieve the active theme yet, but since themes and brands were new in Spring '18 I wouldn't be surprised if they added a way to access it eventually.
    – Kyle
    May 3, 2018 at 17:08

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.