Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Sunday, June 1
    • Home
    • Architecture
    • Salesforce
      • News
      • Apex
      • Integration
      • Books Testimonial
    • Questions
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Integration Posts
    • Downloads
    • About Us
      • Privacy Policy
    SalesforceCodex
    Home»Salesforce»Model Popup in Salesforce Lightning

    Model Popup in Salesforce Lightning

    Dhanik Lal SahniBy Dhanik Lal SahniMay 28, 2018Updated:March 19, 2023No Comments2 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Model Popup in Salesforce Lightning
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Model Popup is very important in some places of CRM application to show records, show messages. I have used this model dialog box in lightning community portal.

    Let us see how to create model dialog box using lightning. We would be required SLDS library. so download and refer it in your base component.

    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    
    <aura:attribute name="openModal" type="boolean" default="false"/>
    
    <aura:attribute name="header" type="string" default="Portal Notification"/>
    
    <aura:attribute name="information" type="string" default="Hello"/>
    <aura:attribute name="param" type="boolean" default="false"/>
    
    <aura:method name="handleOpenModal" action="c.handleOpenModal"/>
    <aura:registerEvent name="onClose" type="c:ModalDialogCloseEvt"/>
    
    <div class="slds-m-around--xx-large">
    <aura:if isTrue="{!v.openModal}">
    <!--Modal Box Start-->
    <div role="dialog" class="slds-modal slds-fade-in-open">
        <div class="slds-modal__container">
        <div class="slds-modal__header green">
        <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.handleCloseModal}">
    X
           <span class="slds-assistive-text">Close</span>
       </button>
       <h1 class="slds-text-heading--medium">{!v.header}</h1>
    </div>
    
    <!--Modal Box Header-->
    <div class="slds-modal__content slds-p-around--medium">
      <center> 
      <p>
        <b>
         {!v.information}
        </b>
      </p>
      </center>
      </div>
     <!--Modal Box Button-->
      <div class="slds-modal__footer">
      <aura:if isTrue="{!v.param}">
         <lightning:button class="slds-button slds-button--brand" onclick="{!c.handleOkModal}" label="Ok"/>
         </aura:if>
        <lightning:button class="slds-button slds-button--brand" onclick="{!c.handleCloseModal}" label="Cancel"/>
       </div>
      </div>
     </div>
    <div class="slds-backdrop slds-backdrop--open"></div> 
    </aura:if>
    </div>
    </aura:component>

    Model Controller JS File:

    ({
        handleOpenModal: function(component, event, helper) {
            //For Display Modal, Set the "openModal" attribute to "true"
            component.set("v.openModal", true);
        },
       	setOKVisibility: function(component, event, helper,param) {
            componet.set("v.param",param);
        },
        handleCloseModal: function(component, event, helper) {
            //For Close Modal, Set the "openModal" attribute to "fasle"  
            component.set("v.openModal", false);
        },
        handleOkModal:function(component, event,helper) {
            helper.fireEvent(component, true, null);
            component.set("v.openModal", false);
            
        }
    })

    Model Helpr JS File:

    ({
    	closeMe : function(comp, event, helper)  { 
            comp.destroy();
    	},
    	fireEvent : function(component, confirmResult, inputResult) {
            var evt = component.getEvent("onClose");
    	        evt.setParams({
    	        dialogType: 'Information',
    	        confirmResult: true,
    	        inputResult: null,
    	        context: {},
    	    });
            debugger;
    	    evt.fire();
    	}
    })
    

    Model Style File:

    .THIS .white svg {
        color:#FFF;
        fill: rgb(255, 255, 255);
    }
    .THIS .red
    {
        background: red;
        border: 3px solid red;
        color: white;
        float: left;
        text-align: center;
        padding-top: 5px;
    }
    
    .THIS .green
    {
        background: green;
        border: 3px solid green;
        color: white;
        float: left;
        text-align: center;
        padding-top: 5px;
    }
    
    lightning model dialog salesforce
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleCreate Signature Pad in Salesforce Lightning
    Next Article Revisit Asynchronous Apex : Type and Usage
    Dhanik Lal Sahni
    • Website

    Related Posts

    By Dhanik Lal Sahni9 Mins Read

    10 Salesforce Chrome Extensions to Boost Your Productivity

    June 1, 2025
    By Dhanik Lal Sahni4 Mins Read

    How to Build a Generic Modal Window in Lightning Web Component

    May 26, 2025
    By Dhanik Lal Sahni6 Mins Read

    Top 10 Salesforce Flow Features of Salesforce Summer ’25

    May 11, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (111) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code analysis (3) code optimization (8) custom metadata types (5) design principle (9) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (65) lightning-combobox (5) lightning-datatable (10) lightning component (31) Lightning web component (63) lwc (52) named credential (8) news (4) optimize apex code (4) optimize apex trigger (3) Permission set (4) pmd (3) Queueable (9) rest api (23) S3 Server (4) salesforce (142) salesforce apex (47) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (111) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code analysis (3) code optimization (8) custom metadata types (5) design principle (9) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (65) lightning-combobox (5) lightning-datatable (10) lightning component (31) Lightning web component (63) lwc (52) named credential (8) news (4) optimize apex code (4) optimize apex trigger (3) Permission set (4) pmd (3) Queueable (9) rest api (23) S3 Server (4) salesforce (142) salesforce apex (47) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.