Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Control visibility of lightning component using slds-hide
<!-- Component Markup -->
<div aura:id="yourIdentifier">
<c:Your_Component />
</div>
/**
* Controller Method
*/
showComponent : function (component, event, helper) {
$A.util.removeClass(component.find("yourIdentifier"), "slds-hide");
},
hideComponent : function (component, event, helper) {
$A.util.addClass(component.find("yourIdentifier"), "slds-hide");
}
@Maxscores

This comment has been minimized.

Copy link

Maxscores commented Aug 15, 2018

This is great, didn't know about 'slds-hide'. I'd provide an improvement by using $A.util.toggleClass. Can simplify this to a single method like so:

toggleComponent : function (component, event, helper) {
	$A.util.toggleClass(component.find("yourIdentifier"), "slds-hide");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.