Want to update checkbox based on toggle option in LWC Salesforce.
<lightning-input type="checkbox" label=" " name="Active" onclick={handleChange}></lightning-input>
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityWant to update checkbox based on toggle option in LWC Salesforce.
<lightning-input type="checkbox" label=" " name="Active" onclick={handleChange}></lightning-input>
Check this documentation link in LWC which has example of what you are asking for
<!-- helloConditionalRendering.html -->
<template>
<lightning-card title="HelloConditionalRendering" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<lightning-input type="checkbox" label="Show details" onchange={handleChange}></lightning-input>
<template if:true={areDetailsVisible}>
<div class="slds-m-vertical_medium">
These are the details!
</div>
</template>
</div>
</lightning-card>
</template>
Code to toggle is in the below js file
// helloConditionalRendering.js
import { LightningElement, track } from 'lwc';
export default class HelloConditionalRendering extends LightningElement {
@track areDetailsVisible = false;
handleChange(event) {
this.areDetailsVisible = event.target.checked;
}
}