Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Why am I facing an SLDS card margin issue?

Asked by Clare Matthews May 18, 2023 1.6K views 1 answer
Share

About this question

When lightning cards render, the first one seems to always be misaligned at the top no matter what. (this is obviously fixable with CSS). I used dynamic rendering, standard lightning:Card component and SLDS card blueprints, all resulted in the same behaviour.

dynamic lightning card:

component.cmp

{!v.body}

componentController.js

doInit : function(cmp, evt, helper) { const featureCards = cmp.get('v.newFeatures'); featureCards.forEach( function(element){ helper.createComponent(cmp, evt, element); }) },

componentHelper.js

createComponent : function(cmp, evt, data) { $A.createComponent( "c:newFeatureCard", { "title": data.component.label, "cardBody": data.component.description }, function(newCard, status, errorMessage){ //Add the new button to the body array if (status === "SUCCESS") { var body = cmp.get("v.body"); body.push(newCard); cmp.set("v.body", body); } else if (status === "INCOMPLETE") { console.log("No response from server or client is offline.") // Show offline error } else if (status === "ERROR") { console.log("Error: " + errorMessage); // Show error message } } ); },

lightning:card component:

component.cmp

Non Dynamic Cards
asdasd Card Body (custom component) asdasd Card Body (custom component) asdasd Card Body (custom component) asdasdasd Card Body (custom component) asdsad Card Body (custom component) asdasdsda Card Body (custom component)

SLDS Card Blueprint:

component.cmp

SLDS BluePrint Cards

Can someone shed some light as to the origin of this behaviour and how to fix it? (Is this something that should be raised with Salesforce support? - easy css fix, just throwing this out there for the community)

the same behaviour results if I don't wrap the cards in a grid

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.