December 23, 2020

How to check and uncheck check box lightning:input in LWC in Salesforce?

Sample Code:

HTML:

<template>

    <div class="slds-theme--default slds-p-around_large">

        <lightning-input type="checkbox" label="Basic option" checked={showBool}></lightning-input><br/><br/>

        <lightning-button variant="brand"
                          label="Uncheck"
                          onclick={hide}></lightning-button>

    </div>
  
</template>

JavaScript:

import { LightningElement } from 'lwc';

export default class Sample extends LightningElement {

    showBool = true;

    hide() {

        this.showBool = false;

    }

}

Output:



No comments:

Post a Comment