Skip to content

Instantly share code, notes, and snippets.

@manuelcoppotelli
Created February 13, 2018 09:08
Show Gist options
  • Save manuelcoppotelli/86f43435034aa9901939e871c28c5b47 to your computer and use it in GitHub Desktop.
Save manuelcoppotelli/86f43435034aa9901939e871c28c5b47 to your computer and use it in GitHub Desktop.
Creates a CSS-only loading spinner.
.is-loading {
color: transparent !important;
pointer-events: none;
}
.is-loading:after {
-webkit-animation: spinAround 500ms infinite linear;
animation: spinAround 500ms infinite linear;
border: 2px solid #dbdbdb;
border-radius: 290486px;
border-right-color: transparent;
border-top-color: transparent;
content: "";
display: block;
height: 1em;
position: relative;
width: 1em;
position: absolute;
left: calc(50% - (1em / 2));
top: calc(50% - (1em / 2));
position: absolute !important;
}
@-webkit-keyframes spinAround {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@keyframes spinAround {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@manuelcoppotelli
Copy link
Author

manuelcoppotelli commented Feb 13, 2018

it's a good practice to disable the buttons on click to stop the user from spamming or accidentally pressing the buttons twice while the process is still in progress.

Append to the buttons:

:disabled="loading"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment