Cube
Recorded: Sept. 20, 2026, noon
| Original | Summarized |
Cube — JavaScript animation library for UI motion cube APIReactFAQAgents Four motions.No dials click to switch Read the API Save rise640ms · 70ms stagger leave320ms · 40ms stagger morph220ms · 130ms lead Sync revealrise, when in view API rise(".hero", { targets: "children" }); // staggered entrance React <Rise as="section" targets="children" className="hero"> // stagger children <Rise show={open} className="toast">Saved</Rise> // rises in, leaves before unmount <Reveal as="ul" targets="children" className="cards">{cards}</Reveal><script setup> <template> <Rise as="section" targets="children" class="hero"> // stagger children <Rise show={open()} class="toast">Saved</Rise> // rises in, leaves before unmount <Reveal as="ul" targets="children" class="cards">{cards}</Reveal><script> <button onclick={save}> {#if open}<div class="toast" in:rise out:leave>Saved</div>{/if} <ul use:reveal={{ targets: "children" }} class="cards">…</ul> Why no dials lead ●├────────┤ 130 FAQ MIT · Daniel White |
Cube is a JavaScript animation library designed for creating sophisticated user interface motion, distinguished by its approach of offering four predefined motions without relying on traditional dials for granular control. The library leverages the Web Animations API as its foundation, ensuring zero runtime dependencies and no reliance on custom frame loops or external polyfills. This design philosophy centers on simplifying complex animation tasks by offering specific, established motion patterns: rise, leave, morph, and reveal, each customizable with settings for duration, curve, and stagger. The library implements four core motion types. The rise motion handles entrances, involving opacity changes and a vertical lift, often applied in a staggered manner to sibling elements. The leave motion manages exits, executing a drop and opacity change, and crucially, holding the element in its final state until it is removed. The morph motion facilitates state transitions, smoothly altering the visual properties, such as text or icons, by smoothly transitioning between states, often involving crossfading. Finally, the reveal motion is designed for content that appears when in view, such as elements below the fold, causing them to rise upon scrolling into the viewport. Cube eschews traditional animation dials by fixing the duration, curve, and distance parameters for each motion type, shifting the control mechanism toward managing stagger and delay to dictate when the motion initiates. This systematic constraint allows the library to focus on providing ready-made solutions for common UI scenarios, rather than offering the exhaustive, timeline-based control provided by other animation tools like GSAP, which are better suited for complex gestures or detailed timelines. The library integrates seamlessly across major frontend frameworks, providing adapter packages for React, Vue, Solid, and Svelte, enabling developers to implement these motions within their existing component structures. For instance, the integration allows for declarative specification of these animations, such as using Rise for staggered entrances, Morph for state changes, and Reveal for scroll-based visibility effects. The library addresses modern accessibility concerns, particularly reduced motion preferences. For motion types like rise and leave, Cube facilitates these preferences by converting opacity changes into fades and morphing into crossfades. The reveal motion incorporates reduced motion handling by applying these preferences when an element enters the viewport. Furthermore, the library operates without spring solvers, utilizing a fixed cubic-bezier curve, and it relies on CSS transitions for press feedback, moving away from complex gesture-based solutions for basic interaction responses. Ultimately, Cube positions itself as a focused tool for handling common UI animations by abstracting away low-level browser complexities, relying instead on the efficient Web Animations API and IntersectionObserver. |