0

The Lightning Component that I built uses a lot of inline CSS. This is because of the configurations for certain clients who wants to give a more personal look and feel of our app. These configurations are passed in as JSON through an API.

We got feedback from Salesforce Security Review team that inline CSS is discouraged (and absolute positions is disallowed). What would be an alternative to applying the configured/dynamic css to the component? Would I do it in the afterRender cycle and label each component with an ID and applying the CSS?

1

There is no policy blocking inline styles in the Security Review. The issue is to not modify styles of DOM elements that don't belong to your component, but inline styles applied to your own DOM elements are fine.

You can book an office hour and discuss this further with a member of the team if there are still questions.

0

Why not just using local css classes in "style" component part and use them in the HTML of the component ?

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

  • because these aren't fixed styles, these are styles configured by the client and saved as JSON. An example would be like changing the color of the button or text using a certain hex code. – kev_panda Dec 15 '16 at 23:35
  • Couldn't your client config generate a CSS file, then in your app with ltng:require you include your base CSS then the client custom CSS so that its classes override your base CSS ? – Nicolas Vuillamy Dec 18 '16 at 0:01
  • we could, but we have multiple clients and to generate and append the CSS for every client would be a lot of work and exactly scalable. Thank you for your suggestions though, I really appreciate it. – kev_panda Dec 19 '16 at 17:02
  • I have the same requirement on my project ( ISV that every client will customize ) , and I really plan to do this way , even if I dynamically have to create ltng:require components to include the client CSS to override our base CSS ^^ – Nicolas Vuillamy Dec 19 '16 at 17:27

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.