I am trying to change the variant in when the lightning button is clicked. How can i change the variant when I toggle between the button?
JS Code
showMonthly(event) {
this.showMonthlyData = true;
event.target.variant='brand';
this.showYearlyData = false;
this.yearlyBrand = 'neutral';
alert('Monthly',this.showMonthly);
alert(this.yearlyBrand);
alert(event.target.variant);
}
showYearlyFunc(event) {
event.target.variant='brand';
this.showMonthlyData = false;
this.monthlyBrand = 'neutral';
alert(this.monthlyBrand);
alert(event.target.variant);
}
HTML
<lightning-button-group>
<lightning-button class="slds-theme_brand" label="Monthly" variant={monthlyBrand} onclick={showMonthly}></lightning-button>
<lightning-button class="slds-theme_brand" label="Yearly" variant={yearlyBrand} onclick={showYearlyFunc}></lightning-button>
</lightning-button-group>