Usage Of lightning-slider

Let us discuss here how to use the lightning-slider. 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"

Here’s an example of a slider with a step increment of 10.


Handle the change event and get the slider value using the property.

import { LightningElement } from 'lwc';

export default class MyDemo extends LightningElement {
    handleChange(event) {

By default, the min and max values are 0 and 100, but you can specify your own values. If you specify your own step increment value, you can drag the slider based on the step increment only. If you set the value lower than the min value, then the value is set to the min value. Similarly, setting the value higher than the max value results in the value being set to the max value.


In this example, we will be showing the contact data based on the slide range change

Create Apex Class

create an apex class as shown below

public with sharing class ContactController {
    public static List<Contact> getContactList(Integer limitVal) {
        return [SELECT Id, Name,Email,Phone FROM Contact Limit :limitVal];



create a lightning web component using the following sfdx command

 sfdx force:lightning:component:create --type lwc --componentname slider --outputdir force-app\main\default\lwc


Use the below slider.html code


    <div class="slds-m-vertical_medium">
        <h1 class="slds-text-heading_small">Slide to Get the Contacts</h1>
        <lightning-slider label="Contact Limit" step="5" value={val} onchange={handleChange}></lightning-slider>

    <lightning-card title="Contacts List">

        <ul class="slds-m-around_medium">
            <template for:each={} for:item="contact">
                <li key={contact.Id}>


Use the below slider.js code

import {
} from 'lwc';
import getContactList from '@salesforce/apex/ContactController.getContactList';
export default class Slider extends LightningElement {
    @track val = 5;
    @track contacts;
    handleChange(event) {
        this.val =;
    @wire(getContactList, {
        limitVal: '$val'



Use the below slider.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="" fqn="helloWorld">


Push changes and add it to the page layout and you can able to see the like below