Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Transitions

    Animate between states, or loop.

    --transition: var(--default-transition) covers the commonly animated properties with the kit's spring easing. A --<utility>--starting tier sets the value the element animates in from.

    To animate fewer properties, use one of the groups --default-transition is built from: --default-transition-colors, --default-transition-transforms, --default-transition-effects (opacity, filters, shadow), and --default-transition-content (display, overlay and the other discrete properties, with allow-discrete). A button that only changes color can use --transition: var(--default-transition-colors). Each group has a matching --default-transition-property-* list of names for writing your own transition-property.

    --transition-duration and --transition-delay change the timing without restating the property list. They also win over a primitive's own transition, so --transition-duration: 0.6s slows a dialog down without touching its CSS. Unlike --transition, they take breakpoint tiers as well as states, so a stagger can tighten on small screens:

    <li style="--transition: var(--default-transition-effects); --transition-delay: 120ms; --transition-delay--md: 240ms">

    Like every tiered utility, a tier needs the base value: --transition-delay--md alone does nothing.

    prefers-reduced-motion: reduce sets --default-transition-duration to 0s, but a literal --transition-duration keeps its value. To respect the setting, write the duration in terms of the token, for example --transition-duration: calc(var(--default-transition-duration) * 2).

    Animation

    --animation takes any animation value, with breakpoints and states. The kit ships Tailwind's four loops as tokens: --spin for a spinner, --ping for a dot that scales out and fades (put it on a copy stacked behind the dot), --pulse for a skeleton loader's slow fade, and --bounce for a scroll hint.

    <svg style="--animation: var(--spin)" aria-hidden="true">…</svg>
    <span style="--display: grid-pile">
      <i style="--size: 2; --bg: var(--color-primary); --radius: full; --animation: var(--ping)"></i>
      <i style="--size: 2; --bg: var(--color-primary); --radius: full"></i>
    </span>

    --spin runs linear. --pulse takes 2s on the default easing. --ping and --bounce use --default-animation, which is 1s, the default easing, and infinite, so a keyframe name composes with it: --animation: spin var(--default-animation). The loops that animate transform leave --rotate, --scale, and --translate working on top.

    The keyframes are named spin, ping, pulse, and bounce, and they sit in the lowest layer, so a page's own keyframes of the same name win. prefers-reduced-motion: reduce stops every --animation value, your own included.

    Reference

    Transitions utilities
    UtilityWritesValueTiersNotes
    --transitiontransitionany CSS valuestates--before-transition / --after-transition
    --transition-durationtransition-durationany CSS valuebreakpoints, states--before-transition-duration / --after-transition-duration
    --transition-delaytransition-delayany CSS valuebreakpoints, states--before-transition-delay / --after-transition-delay
    --animationanimationany animation value, or a token: var(--spin), var(--ping), var(--pulse), var(--bounce)breakpoints, statesworks tier-only

    API