AI CSS Animations

Picker Wheel Rotating Text

Words ride a 3D wheel like an iOS picker: the chosen one faces you in a tinted band while its neighbors tilt away above and below. Six faces set 60 degrees apart make one full turn.

Also known as: 3d word wheel, ios picker text animation, cylinder text rotator.

I feel

HTML

<div class="txt-picker-wheel-rotating-text" aria-label="I feel happy, calm, bold, sleepy, curious, ready">I feel
  <span class="txt-picker-wheel-rotating-text-scene" aria-hidden="true">
    <span class="txt-picker-wheel-rotating-text-wheel">
    <span style="--i: 0">happy</span>
    <span style="--i: 1">calm</span>
    <span style="--i: 2">bold</span>
    <span style="--i: 3">sleepy</span>
    <span style="--i: 4">curious</span>
    <span style="--i: 5">ready</span>
  </span>
  </span>
</div>

CSS

.txt-picker-wheel-rotating-text {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 0.3em;
  white-space: nowrap;}
/* padded so the mask covers the rows above and below, with no effect on layout */
.txt-picker-wheel-rotating-text-scene {
  position: relative;
  display: inline-grid;
  margin: -1.5em 0;
  padding: 1.5em 0.25em;
  perspective: 8em;
  color: var(--c);
  -webkit-mask-image: linear-gradient(transparent 4%, #000 36%, #000 64%, transparent 96%);
  mask-image: linear-gradient(transparent 4%, #000 36%, #000 64%, transparent 96%);
}
.txt-picker-wheel-rotating-text-scene::before {
  content: "";
  position: absolute;
  inset: 1.5em 0;
  border-radius: 0.22em;
  background: color-mix(in srgb, var(--c) 14%, transparent);
}
.txt-picker-wheel-rotating-text-wheel {
  display: grid;
  transform-style: preserve-3d;
  /* 6 faces x 1.4s = 8.4s; pushed back by the radius so the front face sits at true size */
  animation: txt-picker-wheel-rotating-text-spin 8.4s cubic-bezier(0.6, 0, 0.3, 1.25) infinite;
}
.txt-picker-wheel-rotating-text-wheel span {
  grid-area: 1 / 1;
  text-align: center;
  backface-visibility: hidden;
  /* radius = half a row / tan(30deg) = 0.6em / 0.577 */
  transform: rotateX(calc(var(--i) * -60deg)) translateZ(1.04em);
}
@keyframes txt-picker-wheel-rotating-text-spin {
  0%, 10.71% { transform: translateZ(-1.04em) rotateX(0deg); }
  16.67%, 27.38% { transform: translateZ(-1.04em) rotateX(60deg); }
  33.33%, 44.05% { transform: translateZ(-1.04em) rotateX(120deg); }
  50%, 60.71% { transform: translateZ(-1.04em) rotateX(180deg); }
  66.67%, 77.38% { transform: translateZ(-1.04em) rotateX(240deg); }
  83.33%, 94.05% { transform: translateZ(-1.04em) rotateX(300deg); }
  100% { transform: translateZ(-1.04em) rotateX(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-picker-wheel-rotating-text, .txt-picker-wheel-rotating-text *, .txt-picker-wheel-rotating-text::before, .txt-picker-wheel-rotating-text::after, .txt-picker-wheel-rotating-text *::before, .txt-picker-wheel-rotating-text *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • 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 text animations