<html>
  <head>
  <script defer src="https://cdn.formli.com/html-forms/os-forms-v1.min.js?workspace-id=1745"></script>
  <script defer src="https://cdn.formli.com/elements/os-custom-elements-v1.min.js?workspace-id=1745"></script>
  </head>
  <body>
  <div class="relative">
  <form data-os-autosave data-os-uuid="axemgdo7e8" data-os-element="form" action="https://app.formli.com/api/v1/data_responses" method="post">
    <h3>Fields loading state</h3>
    <input data-os-element="parent-session" data-os-default="urlparam" data-os-urlparam="parent_session_id" type="hidden" />
    <div>
      <label for="dfy10pln3v4">Full name</label>
      <div class="flex">
        <input data-os-loadingclass="field-loading" data-os-element="full-name" data-os-uuid="dfy10pln3v4" value="" type="text" id="dfy10pln3v4" />
        <div class="loading-wrapper">
          <div data-os-element="loading" data-os-for="dfy10pln3v4" class="os-hidden"><div class="lds-dual-ring"></div></div>
          <div data-os-element="success" data-os-for="dfy10pln3v4" class="os-hidden">✅</div>  
        </div>
      </div>
      <div data-os-element="field-error" data-os-for="dfy10pln3v4" class="os-hidden"></div>
    </div>
    <div>
      <label for="dfqednpwkz1">City</label>
      <div class="flex">
        <input data-os-loadingclass="field-loading" data-os-loadingclass="field-loading" data-os-element="city" data-os-uuid="dfqednpwkz1" value="" type="text" id="dfqednpwkz1" />
        <div class="loading-wrapper"><div data-os-element="loading" data-os-for="dfqednpwkz1" class="os-hidden"><div class="lds-dual-ring"></div></div>
          <div data-os-element="success" data-os-for="dfqednpwkz1" class="os-hidden">✅</div>  
        </div>
      </div>
      <div data-os-element="field-error" data-os-for="dfqednpwkz1" class="os-hidden"></div>
    </div>
    <input type="submit" value="Submit" data-os-wait="Please wait..." />
  </form>
  <div class="os-hidden" data-os-element="form-success">
    <div>Thank you! Your submission has been received!</div>
  </div>
  <div class="os-hidden" data-os-element="form-error">
    <div>Oops! Something went wrong while submitting the form.</div>
  </div>
</div>
  </body>
</html>
body {
  font-family: 'Arial', sans-serif;
  background-color: #000; /* Dark background */
  color: #fff; /* White text for contrast */
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
}

form {
  background-color: #333; /* Dark form background */
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
  width: 300px;
}

h3 {
  color: #fff;
  text-align: center;
}

label {
  display: block;
  margin-bottom: 10px;
}

input[type="text"] {
  width: 290px;
  height: 35px;
  border: 5px solid grey;
}

input[type="text"].field-loading {
  border-color: orange;
}

input[type="submit"] {
  background: linear-gradient(45deg, #FFC107, #FF5722); /* Gradient button */
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.3s;
}

input[type="submit"]:hover {
  background: linear-gradient(45deg, #FF9800, #F44336); /* Darker gradient on hover */
}

.lds-ripple {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
}
.lds-ripple div {
  position: absolute;
  border: 4px solid #fff;
  opacity: 1;
  border-radius: 50%;
  animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.lds-ripple div:nth-child(2) {
  animation-delay: -0.5s;
}
@keyframes lds-ripple {
  0% {
    top: 36px;
    left: 36px;
    width: 0;
    height: 0;
    opacity: 0;
  }
  4.9% {
    top: 36px;
    left: 36px;
    width: 0;
    height: 0;
    opacity: 0;
  }
  5% {
    top: 36px;
    left: 36px;
    width: 0;
    height: 0;
    opacity: 1;
  }
  100% {
    top: 0px;
    left: 0px;
    width: 72px;
    height: 72px;
    opacity: 0;
  }
}

.lds-dual-ring {
  display: inline-block;
  width: 25px;
  height: 25px;
}
.lds-dual-ring:after {
  content: " ";
  display: block;
  width: 15px;
  height: 15px;
  margin: 4px;
  border-radius: 50%;
  border: 3px solid #fff;
  border-color: #fff transparent #fff transparent;
  animation: lds-dual-ring 1.2s linear infinite;
}
@keyframes lds-dual-ring {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.os-hidden {
  display: none;
}

form > div {
  margin-bottom: 15px;
}

.flex {
  display: flex;
  gap: 10px;
  align-items: center;
}

.absolute {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.relative {
  position: relative;
}

.cover {
  width: 100%;
  height: 100%;
  background: black;
  opacity: 0.5;
}

.loading-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 35px;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.