Create range slider positioned horizontally and vertically between two specific numbers and get the slider value using the event.detail property in Lightning Web Component — LWC | how to get range slider value in lwc salesforce

1,926 views


Hey guys, today in this post we are going to learn about How to Create input range slider positioned horizontally and vertically and specifying a value between two specific numbers in Lightning Web Component — LWC | How to get the slider value using the event.detail property in lwc.

A lightning-slider component is a horizontal or vertical slider for specifying a value between two specified numbers. For example, this slider can be used to capture user input about order quantity or when you want to use an input field of type=”range”. To orient the slider vertically, set type=”vertical”. Older browsers that don’t support the slider fall back and treat it as type=”text”. To know more detail about range slider, click Here..

In this example we are changing the range slider and getting the slider value using the event.detail property.

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
   

To know more Specification about the input range slider and it’s supported property, Click Here.

Files we used to create range slider

lwcRangeSlider.html LWc HTML File Template HTML file to create range slider and get value with min and max in Salesforce Lightning Web Component (LWC)
lwcRangeSlider.js LWC JavaScript File It’s hold a javascript on Handle sliderChange function to get the value of range slider in Salesforce.
lwcRangeSlider.js-meta.xml XML Meta File It is used to where this lightning web component file you want to display as like lightning__AppPage, lightning__RecordPage, lightning__HomePage.

Final Output

how can I retrieve and display slider range value in salesforce lwc -- w3web.net

 
 

You can download file directly from github by Click Here.

 
 

Other related post that would you like to learn in Salesforce

  • Find the below steps

Create Lightning Web Component HTML

Step 1:- Create Lightning Web Component HTML ➑ lwcRangeSlider.html

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 

SFDX:Lightning Web Component ➑ New ➑ lwcRangeSlider.html

lwcRangeSlider.html [Lightning Web Component HTML]

  1.    <template>
  2.     <lightning-card title="Create input range slider for specifying a value between two specified numbers in LWC" icon-name="custom:custom21" size="small">
  3.         <div class="slds-p-around_medium">   
  4.            <div class="slds slds-grid slds-wrap"> 
  5.                 <div class="slds-col slds-size_12-of-12">
  6.  
  7.                     <div class="slds-col slds-size_12-of-12">
  8.                         <div class="slds-section__title-action slds-p-around--small">
  9.                             <h3>Slider changed and get the slider value</h3>
  10.                         </div> 
  11.                         <lightning-slider
  12.                                 label="Volume"
  13.                                 step="10"
  14.                                 value={slideValue}
  15.                                 onchange={sliderChange}>
  16.                             </lightning-slider>
  17.                             <div class="slds-m-vertical_medium">
  18.                             <p>The value of the slider is: <span class="slds-text-heading_small">{slideValue}</span></p>
  19.                         </div>
  20.                     </div>
  21.                     <br/>
  22.  
  23.                     <div class="slds-section__title-action slds-p-around--small">
  24.                         <h3>The range slider size and slider positioned horizontally</h3>
  25.                     </div>         
  26.                     <lightning-slider label="Volume" size="x-small"></lightning-slider>
  27.                     <lightning-slider label="Volume" size="small"></lightning-slider>
  28.                     <lightning-slider label="Volume" size="medium"></lightning-slider>
  29.                     <lightning-slider label="Volume" size="large"></lightning-slider>
  30.                     <lightning-slider label="Volume"></lightning-slider>
  31.                 </div>
  32.  
  33.                 <div class="slds-col slds-size_12-of-12">
  34.                     <div class="slds-section__title-action slds-p-around--small">
  35.                         <h3>The range slide positioned vertically</h3>
  36.                     </div> 
  37.                     <lightning-slider label="Volume" type="vertical"></lightning-slider>
  38.                 </div>
  39.  
  40.             </div>
  41.     </div> 
  42. <br/><br/>
  43.    <!--Start RelatedTopics Section-->
  44. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  45.  
  46.             <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>
  47.  
  48.             <br/><br/>
  49.             <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>
  50.             <div style="display:block; overflow:hidden;"> 
  51.                 <div style="width: 50%; float:left; display:inline-block">
  52.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  53.                         <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>
  54.                         <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>
  55.                         <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>
  56.                         <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>
  57.                         <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>
  58.                     </ul>
  59.             </div>
  60.  
  61.             <div style="width: 50%; float:left; display:inline-block">
  62.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  63.                         <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>
  64.                         <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>
  65.                         <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>
  66.                         <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>
  67.                         <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>
  68.                     </ul>
  69.                 </div>
  70.                <div style="clear:both;"></div> 
  71.                <br/>
  72.                 <div class="youtubeIcon">
  73.                     <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>
  74.                 </div>
  75.     </div>
  76.  
  77. </div>
  78.  
  79.   <!--End RelatedTopics Section-->
  80.  
  81.    </lightning-card> 
  82. </template>
  83.  
  84.     </lightning-card>
  85. </template>

Create Lightning Web Component Javascript

Step 2:- Create Lightning Web Component Javascript ➑ lwcRangeSlider.js

SFDX:Lightning Web Component ➑ New ➑ lwcRangeSlider.js

lwcRangeSlider.js [LWC JavaScript File]

  1.    import { LightningElement } from 'lwc';
  2.  
  3. export default class LwcRangeSlider extends LightningElement {
  4.     slideValue = 20; //initial value
  5.  
  6.     sliderChange(event) {
  7.         this.slideValue = event.detail.value;
  8.     }
  9.  
  10. }

Create Lightning Web Component Meta XML

Step 3:- Create Lightning Web Component Meta XML ➑ lwcRangeSlider.js-meta.xml

SFDX:Lightning Web Component ➑ New >> lwcRangeSlider.js-meta.xml

lwcRangeSlider.js-meta.xml [LWC Meta Data XML]

  1.    <?xml version="1.0" encoding="UTF-8"?>
  2. <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  3.     <apiVersion>45.0</apiVersion>
  4.     <isExposed>true</isExposed>
  5.     <targets>
  6.         <target>lightning__AppPage</target>
  7.         <target>lightning__RecordPage</target>
  8.         <target>lightning__HomePage</target>
  9.       </targets>
  10. </LightningComponentBundle>

Create Lightning Application

Step 4:- Create Lightning Application : lwcRangeSliderApp.app

From Developer Console ➑ File ➑ New ➑ Lightning Application

lwcRangeSliderApp.app [Component Application File]

  1.    <aura:application extends="force:slds">
  2.     <c:lwcRangeSlider/>
  3.  </aura:application>

how to get range slider value in lwc salesforce -- w3web.net

Further post that would you like to learn in Salesforce

 

To Find Some Important Additional Information

If you think you and your family members also like to earn money in additional time, then go this link. In this site, you can earn money for the lifetime at low effort. To Earn Unlimited Everyday With This Trick, Sign Up Free and Get Magic.. Get Started for Free

Check Out Youtube:- Earn Unlimited Everyday With This Trick:- Click Here

 

 

FAQ (Frequently Asked Questions)

How do I make a range slider?

Range slider is a very intuitive user interface with one or two handles to allows user to choose a value within a limited range.

What is range slider?

A range slider is an input field that merchants can use to select a numeric value within a given range (minimum and maximum values).

How do I make a double range slider?

To create doubleslider add attribute data-role='doubleslider' to input element. Currently Metro 4 support only horizontal type of slider.

Related Topics | You May Also Like

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

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



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment