23 CSS Checkboxes

Slide-In Label

A confirmation label slides in from the left when the checkbox is checked.

Pure CSS MIT licensed

Slide-In Label the 22nd of 23 designs in the 23 CSS Checkboxes collection. The design is implemented in pure CSS — no JavaScript required. Copy the HTML and CSS panels below into your project. Because the demo is pure CSS, it works in any framework or templating engine you happen to use. The design honours prefers-reduced-motion and uses real semantic markup, so it ships accessibility-ready out of the box.

Live preview

Open in playground

The code

<label class="cb-slidein">
  <input class="cb-slidein__input" type="checkbox" checked />
  <span class="cb-slidein__box">
    <svg width="12" height="9" viewBox="0 0 14 11" fill="none">
      <polyline
        points="1,5.5 5,9.5 13,1"
        stroke="white"
        stroke-width="2.2"
        stroke-linecap="round"
        stroke-linejoin="round"
      />
    </svg>
  </span>
  <span class="cb-slidein__text">Done!</span>
</label>
.cb-slidein {
  display: inline-flex; align-items: center;
  gap: 10px; cursor: pointer; user-select: none;
}
.cb-slidein__input { display: none; }
.cb-slidein__box {
  width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid rgba(30,217,138,.3);
  display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
  color: transparent;
  transition: background .25s, border-color .25s,
              color .25s;
}
.cb-slidein__text {
  font-size: 14px; color: #1ed98a;
  max-width: 0; overflow: hidden;
  white-space: nowrap; opacity: 0;
  transition: max-width .4s cubic-bezier(.23,1,.32,1),
              opacity .4s ease;
}
.cb-slidein__input:checked + .cb-slidein__box {
  background: #1ed98a; border-color: #1ed98a;
  color: #fff;
}
.cb-slidein__input:checked ~ .cb-slidein__text {
  max-width: 200px; opacity: 1;
}

Search CodeFronts

Loading…