AI CSS Animations

Bookmark Save Checkbox

A bookmark ribbon that fills from the top and dips like it just dropped onto the page, while the word Save rolls up to Saved. The fill is a clipped copy of the icon, so it pours in cleanly both ways.

Also known as: bookmark checkbox css, save for later toggle, bookmark icon animation css.

HTML

<label class="chk-bookmark-save">
  <input type="checkbox">
  <span class="chk-bookmark-save-icon" aria-hidden="true">
    <svg class="chk-bookmark-save-outline" viewBox="0 0 24 24"><path d="M6.5 3.5h11a1 1 0 0 1 1 1v16l-6.5-4.2-6.5 4.2v-16a1 1 0 0 1 1-1z"/></svg>
    <span class="chk-bookmark-save-fill"><svg viewBox="0 0 24 24"><path d="M6.5 3.5h11a1 1 0 0 1 1 1v16l-6.5-4.2-6.5 4.2v-16a1 1 0 0 1 1-1z"/></svg></span>
  </span>
  <span class="chk-bookmark-save-words"><span>Save</span><span aria-hidden="true">Saved</span></span>
</label>

CSS

.chk-bookmark-save {
  --c: var(--chk-color, #3b82f6);
  font-size: var(--chk-size, 24px);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  line-height: 1.3;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  gap: 0.45em;}
.chk-bookmark-save input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.chk-bookmark-save-icon {
  display: grid;
  width: 1.5em;
  height: 1.5em;
  border-radius: 0.3em;
}
.chk-bookmark-save-icon svg {
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: color-mix(in srgb, currentColor 38%, transparent);
  stroke-width: 1.8;
  stroke-linejoin: round;
  transition: stroke 0.25s ease;
}
.chk-bookmark-save-outline {
  grid-area: 1 / 1;
}
.chk-bookmark-save-fill {
  grid-area: 1 / 1;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.25s ease-in;
}
.chk-bookmark-save-fill svg {
  fill: var(--c);
  stroke: var(--c);
}
.chk-bookmark-save-words {
  display: flex;
  flex-direction: column;
  height: 1.3em;
  overflow: hidden;
}
.chk-bookmark-save-words > span {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.25s ease;
}
.chk-bookmark-save:hover .chk-bookmark-save-outline {
  stroke: var(--c);
}
.chk-bookmark-save input:checked + .chk-bookmark-save-icon {
  animation: chk-bookmark-save-drop 0.5s ease-out;
}
.chk-bookmark-save input:checked + .chk-bookmark-save-icon .chk-bookmark-save-outline {
  stroke: var(--c);
}
.chk-bookmark-save input:checked + .chk-bookmark-save-icon .chk-bookmark-save-fill {
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.chk-bookmark-save input:checked ~ .chk-bookmark-save-words > span {
  transform: translateY(-100%);
  color: var(--c);
}
.chk-bookmark-save input:focus-visible + .chk-bookmark-save-icon {
  outline: 0.12em solid var(--c);
  outline-offset: 0.18em;
}
@keyframes chk-bookmark-save-drop {
  0% { transform: translateY(0); }
  35% { transform: translateY(0.2em) scaleY(1.08); }
  65% { transform: translateY(-0.08em) scaleY(0.97); }
  100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .chk-bookmark-save, .chk-bookmark-save *, .chk-bookmark-save::before, .chk-bookmark-save::after, .chk-bookmark-save *::before, .chk-bookmark-save *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --chk-color on the element or a parent. Currently previewing #3b82f6.
  • Size: set --chk-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 24px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar checkboxes