AI CSS Animations

Neo-Brutalist Checkbox

A neo-brutalist checkbox: thick ink border, a hard offset shadow and flat color. Checking slams the box into its shadow and punches in a square-capped tick. The ink follows your text color.

Also known as: brutalist checkbox css, hard shadow checkbox, neubrutalism checkbox.

HTML

<label class="chk-brutalist-checkbox">
  <input type="checkbox">
  <span class="chk-brutalist-checkbox-box">
    <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
  </span>
  <span class="chk-brutalist-checkbox-text">Ship it</span>
</label>

CSS

.chk-brutalist-checkbox {
  --c: var(--chk-color, #3b82f6);
  font-size: var(--chk-size, 24px);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  gap: 0.75em;}
.chk-brutalist-checkbox input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.chk-brutalist-checkbox-box {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  flex: none;
  width: 1.5em;
  height: 1.5em;
  border: 0.15em solid currentColor;
  border-radius: 0.2em;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  box-shadow: 0.22em 0.22em 0 currentColor;
  transition:
    transform 0.12s cubic-bezier(0.5, 0, 0.75, 0),
    box-shadow 0.12s cubic-bezier(0.5, 0, 0.75, 0),
    background-color 0.15s ease;
}
.chk-brutalist-checkbox-box svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.6;
  stroke-linecap: square;
  stroke-linejoin: miter;
  transform: scale(0);
  transition: transform 0.1s ease-in;
}
.chk-brutalist-checkbox-text {
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chk-brutalist-checkbox input:checked + .chk-brutalist-checkbox-box {
  background: var(--c);
  box-shadow: 0 0 0 currentColor;
  transform: translate(0.22em, 0.22em);
}
.chk-brutalist-checkbox input:checked + .chk-brutalist-checkbox-box svg {
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.2, 2, 0.5, 1) 0.1s;
}
.chk-brutalist-checkbox input:focus-visible + .chk-brutalist-checkbox-box {
  outline: 0.125em solid var(--c);
  outline-offset: 0.18em;
}

@media (prefers-reduced-motion: reduce) {
  .chk-brutalist-checkbox, .chk-brutalist-checkbox *, .chk-brutalist-checkbox::before, .chk-brutalist-checkbox::after, .chk-brutalist-checkbox *::before, .chk-brutalist-checkbox *::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