Skip to content

Instantly share code, notes, and snippets.

@sfdcale
Created May 1, 2019 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfdcale/05b7d0e8702e13081951d1e5828abc0c to your computer and use it in GitHub Desktop.
Save sfdcale/05b7d0e8702e13081951d1e5828abc0c to your computer and use it in GitHub Desktop.
change button on click
<template>
<button class={cssClass}>
<lightning-icon icon-name={iconName} onclick={handleToggleClick}>Non Profit</lightning-icon>
</button>
</template>
import { LightningElement, track} from 'lwc';
export default class PcSelectButtonFramework extends LightningElement {
buttonClicked; //defaulted to false
@track cssClass = 'slds-button slds-button_neutral inactive';
@track iconName = 'utility:preview';
// Handles click on the 'Show/hide content' button
handleToggleClick() {
this.buttonClicked = !this.buttonClicked; //set to true if false, false if true.
this.cssClass = this.buttonClicked ? 'slds-button slds-button_neutral active' : 'slds-button slds-button_neutral inactive';
this.iconName = this.buttonClicked ? 'utility:hide' : 'utility:preview';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment