Last active
June 13, 2023 19:47
-
-
Save LokeshSagi/ecd729b06bb84e080570a16c03c44c79 to your computer and use it in GitHub Desktop.
Show spinner component in LWC.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.backdrop { | |
position: fixed; | |
left: 0; | |
top: 0; | |
width: 100%; | |
height: 100%; | |
background: rgba(8, 7, 7, 0.5); /* background color while spinner onscreen */ | |
z-index: 15000; /* set z-index always high */ | |
} | |
.spinshow::after { | |
position: absolute; | |
content: "Please wait while loading"; | |
width: 100%; | |
text-align: center; | |
top: calc(50% + 3em); | |
font-weight: bold; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<template if:true={showSpinner}> | |
<div class="backdrop"> | |
<lightning-spinner class="spinshow" size="large" variant="brand" alternative-text="Loading"> | |
</lightning-spinner> | |
</div> | |
</template> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @lwc/lwc/no-async-operation */ | |
import { LightningElement, track } from 'lwc'; | |
export default class SpinnerComponent extends LightningElement { | |
@track showSpinner = true; | |
/* connectedCallback() { | |
setTimeout(() => { | |
this.showSpinner = false; | |
}, 3000); | |
} */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment