{"id":2596,"date":"2017-07-14T09:01:50","date_gmt":"2017-07-14T09:01:50","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=2596"},"modified":"2025-05-09T07:11:11","modified_gmt":"2025-05-09T07:11:11","slug":"using-nested-lightning-components-in-salesforce","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/07\/14\/using-nested-lightning-components-in-salesforce\/","title":{"rendered":"Using Nested Lightning Components in Salesforce"},"content":{"rendered":"<p>We have already gone back and forth on how Lightning is beneficial and yet minimalistic, how it could be rendered on <a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/03\/27\/add-lightning-components-to-visualforce-page\/\" target=\"_blank\" rel=\"noopener\">VisualForce Pages<\/a> and how to implement their <a href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/05\/03\/creating-a-visualforce-page-with-the-help-of-lightning-design-system\/\" target=\"_blank\" rel=\"noopener\">design system on Salesforce Classic<\/a> if you want a taste of both worlds. Since its emergence, a large swarm of developers has gone on tireless approaches to make Lightning productive and materialistic at the same time. And since its framework is readily supported by Salesforce 1 and Classic future implementations of Salesforce components in Lightning makes more sense.<\/p>\n<p>As mentioned earlier, we have already seen how Lightning components can be implemented in the Visualforce page, following the same track in this blog we are going to see how to implement nested Lightning components in Visualforce. For our demo purpose, we would be creating a CSS based auto text slider so without further ado let\u2019s jump right into it.<\/p>\n<p>First, you need to create a Lightning component, this Lightning component will consist of all the attributes that we will be using for sliding animation, refer the below code-<\/p>\n<div id=\"attachment_2602\" style=\"width: 896px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/1.-First-Lightning-Component.png\" target=\"_blank\" rel=\"noopener\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-2602\" class=\"wp-image-2602 size-full\" title=\"First Lightning Component\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/1.-First-Lightning-Component.png\" alt=\"1. First Lightning Component\" width=\"886\" height=\"192\" \/><\/a><p id=\"caption-attachment-2602\" class=\"wp-caption-text\">1. First Lightning Component<\/p><\/div>\n<p>Now, create another Lightning component this component will consist of all the logic of the CSS will be implemented here. The components helper class will consist of all the logic which will control the styling, the delay how long the slide should appear and how the content should be displayed, refer the below code-<\/p>\n<div id=\"attachment_2603\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/2.-Second-Lightning-Component.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2603\" class=\"wp-image-2603 size-large\" title=\"Second Lightning Component\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/2.-Second-Lightning-Component-1024x622.png\" alt=\"2. Second Lightning Component\" width=\"595\" height=\"361\" \/><\/a><p id=\"caption-attachment-2603\" class=\"wp-caption-text\">2. Second Lightning Component<\/p><\/div>\n<div id=\"attachment_2604\" style=\"width: 807px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/3.-Component-controller.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2604\" class=\"wp-image-2604 size-full\" title=\"Component controller\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/3.-Component-controller.png\" alt=\"3. Component controller\" width=\"797\" height=\"248\" \/><\/a><p id=\"caption-attachment-2604\" class=\"wp-caption-text\">3. Component controller<\/p><\/div>\n<div id=\"attachment_2605\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/4.-Component-helper-class-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2605\" class=\"wp-image-2605 size-large\" title=\"Component helper class\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/4.-Component-helper-class-1-1024x587.png\" alt=\"4. Component helper class-1\" width=\"595\" height=\"341\" \/><\/a><p id=\"caption-attachment-2605\" class=\"wp-caption-text\">4.1. Component helper class-1<\/p><\/div>\n<div id=\"attachment_2606\" style=\"width: 994px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/5.-Component-helper-class-2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2606\" class=\"wp-image-2606 size-full\" title=\"Component helper class\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/5.-Component-helper-class-2.png\" alt=\"5. Component helper class-2\" width=\"984\" height=\"686\" \/><\/a><p id=\"caption-attachment-2606\" class=\"wp-caption-text\">4.2. Component helper class-2<\/p><\/div>\n<div id=\"attachment_2607\" style=\"width: 632px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/6.-Component-helper-class-3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2607\" class=\"wp-image-2607 size-full\" title=\"Component helper class\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/6.-Component-helper-class-3.png\" alt=\"6. Component helper class-3\" width=\"622\" height=\"114\" \/><\/a><p id=\"caption-attachment-2607\" class=\"wp-caption-text\">4.3. Component helper class-3<\/p><\/div>\n<div id=\"attachment_2608\" style=\"width: 679px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/7.-Style-class-for-Second-component.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2608\" class=\"wp-image-2608 size-full\" title=\"Style class for Second component\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/7.-Style-class-for-Second-component.png\" alt=\"7. Style class for Second component\" width=\"669\" height=\"666\" \/><\/a><p id=\"caption-attachment-2608\" class=\"wp-caption-text\">5.1. Style class for Second component<\/p><\/div>\n<div id=\"attachment_2610\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/8.-Style-class-for-Second-component-2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2610\" class=\"wp-image-2610 size-large\" title=\"Style class for Second component\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/8.-Style-class-for-Second-component-2-1024x576.png\" alt=\"8. Style class for Second component-2\" width=\"595\" height=\"335\" \/><\/a><p id=\"caption-attachment-2610\" class=\"wp-caption-text\">5.2. Style class for Second component-2<\/p><\/div>\n<div id=\"attachment_2611\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/9.-Style-class-for-Second-component-3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2611\" class=\"wp-image-2611 size-large\" title=\"Style class for Second component\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/9.-Style-class-for-Second-component-3-1024x576.png\" alt=\"9. Style class for Second component-3\" width=\"595\" height=\"335\" \/><\/a><p id=\"caption-attachment-2611\" class=\"wp-caption-text\">5.3. Style class for Second component-3<\/p><\/div>\n<div id=\"attachment_2612\" style=\"width: 639px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/10.-Style-class-for-Second-component-4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2612\" class=\"wp-image-2612 size-full\" title=\"Style class for Second component\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/10.-Style-class-for-Second-component-4.png\" alt=\"10. Style class for Second component-4\" width=\"629\" height=\"651\" \/><\/a><p id=\"caption-attachment-2612\" class=\"wp-caption-text\">5.4. Style class for Second component-4<\/p><\/div>\n<p>And now, finally, we will create one more component which would consist of both the components that we created. This third component will have an attribute \u201cimplements\u201d which should be \u201cflexipage:availableForAllPageTypes\u201d and its \u201caccess\u201d should be set to \u201cglobal\u201d so that they would be available for use in Lightning as well as in Classic.<\/p>\n<div id=\"attachment_2613\" style=\"width: 1015px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/11.-Third-component.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2613\" class=\"wp-image-2613 size-full\" title=\"Third component\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/11.-Third-component.png\" alt=\"11. Third component\" width=\"1005\" height=\"238\" \/><\/a><p id=\"caption-attachment-2613\" class=\"wp-caption-text\">6. Third component<\/p><\/div>\n<p>Now, create a Lightning App which would consist of all the three Lightning components that we created. Refer the below code for the same-<\/p>\n<div id=\"attachment_2614\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/12.-Slider-App.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2614\" class=\"wp-image-2614 size-large\" title=\"Slider App\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/12.-Slider-App-1024x227.png\" alt=\"12. Slider App\" width=\"595\" height=\"132\" \/><\/a><p id=\"caption-attachment-2614\" class=\"wp-caption-text\">7. Slider App<\/p><\/div>\n<p>Finally, we will be creating a Visualforce page that would refer all these components and display them. We created a Visualforce page named \u201cNestedCompDemo\u201d and implemented the following logic-<\/p>\n<div id=\"attachment_2609\" style=\"width: 827px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/13.-NestedCompDemo-Vf-page.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2609\" class=\"wp-image-2609 size-full\" title=\"NestedCompDemo\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/13.-NestedCompDemo-Vf-page.png\" alt=\"13. NestedCompDemo-Vf page\" width=\"817\" height=\"484\" \/><\/a><p id=\"caption-attachment-2609\" class=\"wp-caption-text\">8. NestedCompDemo-Vf page<\/p><\/div>\n<p>Once you are done you can preview the page and see the changes for yourself. Although this blog main emphasis was to give you a brief of how nested Lightning components can be implemented by the end of this demo you would successfully implementing an auto text slider. For more advanced example visit this blog.<\/p>\n<div id=\"attachment_2601\" style=\"width: 490px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/14.-Nested-Lightning-Components.gif\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2601\" class=\"wp-image-2601 size-full\" title=\"Nested Lightning Components\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/14.-Nested-Lightning-Components.gif\" alt=\"14. Nested Lightning Components\" width=\"480\" height=\"75\" \/><\/a><p id=\"caption-attachment-2601\" class=\"wp-caption-text\">9. Nested Lightning Components<\/p><\/div>\n<p><strong>About Us<\/strong><br \/>\n<a href=\"https:\/\/www.greytrix.com\/\" target=\"_blank\" rel=\"noopener\">Greytrix<\/a> is one stop solution provider for Sage ERP and Sage CRM needs. We provide complete end-to-end assistance for your technical consultations, product customization\u2019s, data migration, system integrations, third party add-on development and implementation expertise.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\" target=\"_blank\" rel=\"noopener\">Greytrix<\/a> have some unique solutions for Cloud CRM such as Salesforce integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\" target=\"_blank\" rel=\"noopener\">Sage X3<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\" target=\"_blank\" rel=\"noopener\">Sage 100<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\" target=\"_blank\" rel=\"noopener\">Sage 300<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\" target=\"_blank\" rel=\"noopener\">Salesforce customization and development services<\/a> to business partners and end users. <a href=\"http:\/\/www.greytrix.com\/\" target=\"_blank\" rel=\"noopener\">Greytrix<\/a> have some unique solutions for On-Premise CRM such as Sage CRM integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-x3-integration\" target=\"_blank\" rel=\"noopener\">Sage X3<\/a>, <a href=\"http:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-100-erp-integration\" target=\"_blank\" rel=\"noopener\">Sage 100<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-300-erp-integration\" target=\"_blank\" rel=\"noopener\">Sage 300<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-500-erp-integration\" target=\"_blank\" rel=\"noopener\">Sage 500<\/a> and Sage 50 . We also offer best-in-class On-Premise <a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/sage-crm\" target=\"_blank\" rel=\"noopener\">Sage CRM customization and development services<\/a> to business partners and end users.<\/p>\n<p>For more information, please contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have already gone back and forth on how Lightning is beneficial and yet minimalistic, how it could be rendered on VisualForce Pages and how to implement their design system on Salesforce Classic if you want a taste of both worlds. Since its emergence, a large swarm of developers has gone on tireless approaches to\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/07\/14\/using-nested-lightning-components-in-salesforce\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[206,208,213,388,392,469,526],"class_list":["post-2596","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-lightning","tag-lightning-component","tag-lightning-out","tag-salesforce-classic","tag-salesforce-development","tag-slds","tag-visualforce-page"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=2596"}],"version-history":[{"count":3,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2596\/revisions"}],"predecessor-version":[{"id":10672,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2596\/revisions\/10672"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=2596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=2596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=2596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}