Hey guys, today in this post we are going to learn about how to create a Customizable Tabs for Salesforce Lightning Component pages using component controller Javascript.
- Don’t forget to check out:- How to Create a Vertical Tab Dynamically & Customisable in Lightning Component Click Here For More Information
Files we used in this post example:-
customTabApp.app | Lightning Application | It is used for call the component to preview on browser. |
customTabCmp.cmp |
Lightning Component | It is used for create a custom tabs on lightning component . |
customTabCmpController.js |
JavaScript Controller File | It is used for click function for show and hide the custom tabs section. |
customTabCmp.css | Component Style CSS | It is used for create customΒ Style CSSΒ for active tab highlight section. |
Live Demo
You can download file directly from github by Click Here.
Other related post that would you like to learn in Salesforce
Step 1:- Create Lightning Application : customTabApp.app
From Developer Console >> File >> New >> Lightning Application
customTabApp.app [Component Application File]
<aura:application extends="force:slds">
<c:customTabCmp/>
</aura:application>
Step 2:- Create Lightning Component : customTabCmp.cmp
From Developer Console >> File >> New >> Lightning Component
customTabCmp.cmp [Lightning Component File]
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<div class="slds slds-p-around--medium">
<div class="slds-tabs_default" id="sldsTabItemOver">
<div class="slds-tabs_default__content slds-show" role="tabpanel">
<div class="slds-tabs_scoped">
<ul class="slds-tabs_scoped__nav">
<li class="slds-tabs_scoped__item slds-is-active" id="tabItem3webnet0">
<a class="slds-tabs_scoped__link" href="javascript:void(0);" name="tabItem3webnet0" onclick="{!c.tabActionw3webnet}">Blog</a>
</li>
<li class="slds-tabs_scoped__item" id="tabItem3webnet1">
<a class="slds-tabs_scoped__link" href="javascript:void(0);" name="tabItem3webnet1" onclick="{!c.tabActionw3webnet}">Tutorial</a>
</li>
<li class="slds-tabs_scoped__item" id="tabItem3webnet2">
<a class="slds-tabs_scoped__link" href="javascript:void(0);" name="tabItem3webnet2" onclick="{!c.tabActionw3webnet}">Technical Guide</a>
</li>
<li class="slds-tabs_scoped__item" id="tabItem3webnet3">
<a class="slds-tabs_scoped__link" href="javascript:void(0);" name="tabItem3webnet3" onclick="{!c.tabActionw3webnet}">JQuery</a>
</li>
<li class="slds-tabs_scoped__item" id="tabItem3webnet4">
<a class="slds-tabs_scoped__link" href="javascript:void(0);" name="tabItem3webnet4" onclick="{!c.tabActionw3webnet}">Sitemap</a>
</li>
<li class="slds-tabs_scoped__item" id="tabItem3webnet5">
<a class="slds-tabs_scoped__link" href="javascript:void(0);" name="tabItem3webnet5" onclick="{!c.tabActionw3webnet}">About Us</a>
</li>
<li class="slds-tabs_scoped__item" id="tabItem3webnet6">
<a class="slds-tabs_scoped__link" href="javascript:void(0);" name="tabItem3webnet6" onclick="{!c.tabActionw3webnet}">Contact Us</a>
</li>
</ul>
<div id="activetabItem3webnet0" class="slds-tabs_scoped__content slds-show">
<div class="tabContent">
<div class="postImage">
<a href="https://www.w3web.net/blogging-complete-guide-for-beginners/">
<img src="https://www.w3web.net/wp-content/uploads/2020/07/blogGuide.png" width="200" height="150"/>
</a>
</div>
<p><b>How to start a blog for free that makes money | A simple 8 easy guide step-by-step for beginners</b></p><br/>
<p>In this post we are going to learn about How to start a blog and make money. Easy Guide Step-By-Step for Beginners follow given points.</p><br/>
<p>Blog is a platform where you can share your personal experience that you have in expertise. You can start it from such like your Hobbies, Business, Sports, Medical Equipment, Education, Network Marketing etc..</p><br/>
<p>So think about yourself that in which fields you are much more knowledge and create a blog on the same field.</p><br/>
<p>There are 8 easy steps to start a blogging...<span class="readMore"><a href="https://www.w3web.net/blogging-complete-guide-for-beginners/">Read more...</a></span></p>
</div>
</div>
<div id="activetabItem3webnet1" class="slds-tabs_scoped__content slds-hide">
<div class="tabContent">
<div class="postImage">
<a href="https://www.w3web.net/update-count-of-child-record-based-on-parent-object-value/">
<img src="https://www.w3web.net/wp-content/uploads/2020/08/employeeSizeTrigger.png" width="200" height="150"/>
</a>
</div>
<p><b>Trigger to update count of child records with custom field of parent object</b></p><br/>
<p>Hey guys, today in this post we are going to learn about how to update count of child records with custom field value into parent object using trigger map list in Salesforce.</p><br/>
<p>Real time scenarios:- Write a trigger on parent object where create a custom field as Employee (Number type).</p><br/>
<p>If user insert the parent record, the child record should be automatic inserted equal to the same value of employee...<span class="readMore"><a href="https://www.w3web.net/update-count-of-child-record-based-on-parent-object-value/">Read more...</a></span></p>
</div>
</div>
<div id="activetabItem3webnet2" class="slds-tabs_scoped__content slds-hide">
<div class="tabContent">
<div class="postImage">
<a href="https://www.w3web.net/how-to-voice-typing-in-computer-from-mobile/">
<img src="https://www.w3web.net/wp-content/uploads/2020/07/remote-app2-1-1.png" width="200" height="150"/>
</a>
</div>
<p><b>How to voice typing in computer from mobile?</b></p><br/>
<p>Many people writing a Blog or Article. There can be multiple pages in a single article, if you have not good hand typing speed you will be face so many difficulty.</p><br/>
<p>If you want to write a article English or Hindi very fast than go through the βRemote Mouse Appβ. It is a free app and available on google app store, or you can download from your laptop directly go through this link βhttps://www.remotemouse.net/β. This App helps you to write a article English/Hindi very fast and save the plenty of time....<span class="readMore"><a href="https://www.w3web.net/how-to-voice-typing-in-computer-from-mobile/">Read more...</a></span></p>
</div>
</div>
<div id="activetabItem3webnet3" class="slds-tabs_scoped__content slds-hide">
<div class="tabContent">
<div class="postImage">
<a href="https://www.w3web.net/custom-sidebar-navigation-menu-with-submenu/">
<img src="https://www.w3web.net/wp-content/uploads/2020/08/sidebarNavigationFeature.png" width="200" height="150"/>
</a>
</div>
<p><b>How to Build a Custom Left Sidebar Navigation Menu with Submenu using HTML, CSS and JQuery</b></p><br/>
<p>In this post we are going to learn about how to create a custom left sidebar Navigation Menu with Submenu using HTML, CSS and JQuery...<span class="readMore"><a href="https://www.w3web.net/custom-sidebar-navigation-menu-with-submenu/">Read more...</a></span></p>
</div>
</div>
<div id="activetabItem3webnet4" class="slds-tabs_scoped__content slds-hide">
<div class="tabContent">
<div class="postImage">
<a href="https://www.w3web.net/all-published-post/">
<img src="https://www.w3web.net/wp-content/uploads/2020/08/sitemap.png" width="200" height="150"/>
</a>
</div>
<p><b>Sitemap</b></p>
<p>Here you can find all of the published post on <a href="https://www.w3web.net/">w3web.net</a></p><br/>
<p><span><a href="https://www.w3web.net/how-to-validate-child-component-from-parent-component/">How to validate child component from parent component on click button using aura method in lightning component</a></span></p><br/>
<p><span><a href="https://www.w3web.net/expand-all-collapse-all-rows-in-lightning-component/">Create custom expand all/ collapse all for accordion section rows table based in lightning component</a></span></p><br/>
<p><span><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/">Editing row, Saving row and Removing rows Dynamically in Lightning component Salesforce</a></span></p><br/>
<p><span class="readMore"><a href="https://www.w3web.net/all-published-post/">Read more...</a></span></p>
</div>
</div>
<div id="activetabItem3webnet5" class="slds-tabs_scoped__content slds-hide">
<div class="tabContent">
<div class="postImage">
<a href="https://www.w3web.net/about-us/">
<img src="https://www.w3web.net/wp-content/uploads/2020/08/aboutus.png" width="200" height="150"/>
</a>
</div>
<p><b>About Us</b></p>
<p><b><a href="https://www.w3web.net/">w3web.net</a></b> is the place where you can learn step-by-step about Blog, WordPress, Salesforce Lightning Component, Lightning Web Component (LWC), Visualforce, Technical of Computer Application, Salesforce Plugin, JavaScript, Jquery, CSS, Computer and Accessories, Software Configuration, Customization, Development and much moreβ¦</p><br/>
<p>I am Web and Mobile application developer and sharing knowledge is my passion. Web application development is my interest but it is not biggere then my dream....<span class="readMore"><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/">Read more...</a></span></p>
</div>
</div>
<div id="activetabItem3webnet6" class="slds-tabs_scoped__content slds-hide">
<div class="tabContent">
<div class="postImage">
<a href="https://www.w3web.net/contact-us/">
<img src="https://www.w3web.net/wp-content/uploads/2020/08/contactUs.png" width="200" height="150"/>
</a>
</div>
<p><b>Contact Us</b></p>
<p>Thank you for contact with us. you can write us at the below contact form for any of your queries / clarifications.</p><br/>
<p>You can also email us for a faster response. <b>E-mail:- vijayk085@gmail.com</b>...<span class="readMore"><a href="https://www.w3web.net/contact-us/">Read more...</a></span></p>
</div>
</div>
</div>
</div>
</div>
<br/> <br/>
<!--Start RelatedTopics Section-->
<div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
<p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
<br/><br/>
<p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like β</span> </strong></p>
<div style="display:block; overflow:hidden;">
<div style="width: 50%; float:left; display:inline-block">
<ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;">
<li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
<li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
<li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
<li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
<li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
</ul>
</div>
<div style="width: 50%; float:left; display:inline-block">
<ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;">
<li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
<li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
<li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
<li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
<li><a href="https://www.w3web.net/update-parent-object-from-child/" target="_blank" rel="noopener noreferrer">update parent field from child using apex trigger</a></li>
</ul>
</div>
<div style="clear:both;"></div>
<br/>
<div class="youtubeIcon">
<a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
</div>
</div>
</div>
<!--End RelatedTopics Section-->
</div>
</aura:component>
Step 3:- Create Lightning Component : customTabCmpController.js
From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller
customTabCmpController.js [JavaScript Controller]
({
tabActionw3webnet : function(component, event, helper) {
var thisObj = event.target.name;
var sldsTabItemOver = document.getElementById('sldsTabItemOver');
var scopedItemAll = sldsTabItemOver.querySelectorAll('.slds-tabs_scoped__item');
var scopedContent = sldsTabItemOver.querySelectorAll('.slds-tabs_scoped__content');
var isActive = document.getElementById(thisObj).classList.contains('slds-is-active');
for(var i=0; i<scopedItemAll.length; i++){
scopedItemAll[i].classList.remove('slds-is-active');
scopedContent[i].classList.add('slds-hide');
}
document.getElementById(thisObj).classList.add('slds-is-active');
document.getElementById('active'+thisObj).classList.remove('slds-hide');
document.getElementById('active'+thisObj).classList.add('slds-show');
},
})
Step 4:- Create Lightning Component Style: customTabCmp.css
From Developer Console >> File >> New >> Lightning Component >> Component Style CSS
customTabCmp.css [Style CSS]
.THIS {
}
.THIS .slds-tabs_scoped__item.slds-is-active .slds-tabs_scoped__link{color:#b70e01; text-decoration:none;}
.THIS .tabContent{display:block; padding:5px 0 5px 0px; font-size:14px; overflow: hidden;}
.THIS .tabContent .postImage{display: inline-block; float: left; margin-right: 10px;}
.THIS .readMore{font-size:14px; font-weight:bold; display:inline-block; padding:0 0 0 10px;}
.THIS .readMore a{color:#ff0000; text-decoration:none;}
.THIS .readMore a:hover{color:#04a5ca; text-decoration:underline;}
Further post that would you like to learn in Salesforce
What are the three different custom tabs you can create in Salesforce?
You can create three different kinds of custom tabs: custom object tabs, Web tabs, and Visualforce page tabs.
How do I add a custom object to a tab in Salesforce lightning?
From Setup, in the Quick Find box, enter Tabs , then select Tabs. Click New in the Custom Object Tabs related list. Select the custom object to appear in the custom tab. If you haven't created the custom object, click create a new custom object now and follow the instructions in Create a Custom Object.
What are tabs in Salesforce lightning?
Custom tabs let you display custom object data or other web content in Salesforce. When you add a custom tab to an app in Salesforce Classic, it appears as a tab. When you add a custom tab to an app in Lightning Experience, it appears as an item in the app's navigation bar and in the App Launcher.
Related Topics | You May Also Like
Our Free Courses β
π Get Free Course β
π Salesforce Administrators π Salesforce Lightning Flow Builder π Salesforce Record Trigger Flow Builder |
π Get Free Course β
π Aura Lightning Framework π Lightning Web Component (LWC) π Rest APIs Integration |