Loopkit

npm versionLicense

Lightweight, zero-dependency SVG animation engine. Define animations as plain JS objects, get smooth requestAnimationFrame-driven playback. Built as a Lottie alternative for short decorative animations.

$ npm install loopkit

Playground

Pick an example or edit the schema JSON below. The animation updates in real-time.

Quick Start

import { createAnimation } from 'loopkit';

const anim = createAnimation(document.getElementById('cover'), {
  width: 460,
  height: 280,
  background: '#f0fdf4',
  stagger: 0.3,
  trigger: 'autoplay',
  hold: 2,
  elements: [
    {
      type: 'rect',
      style: { x: 40, y: 40, width: 200, height: 80, fill: '#34d399', rx: 8 },
      animate: {
        width: [0, 200],
        opacity: [0, 1],
        sequence: 0,
        duration: 0.6,
        easing: 'ease-out',
      },
    },
  ],
});

Element Types

rect

Rectangles, lines, bars, progress indicators. Supports rx for rounded corners.

text

SVG text with fontSize, color, fontWeight, textAnchor. Color maps to fill.

circle

Circles with cx, cy, r. Supports scale animation that multiplies the radius.

badge

Composite element: shape + centered text. Circle or pill (isLabel). Scale animates the group.

Features

Schema in, animation out

Declarative JSON schema defines elements and keyframes. No imperative animation code.

Zero dependencies

Pure TypeScript, under 5KB minified. No React, no framework lock-in.

Smooth transitions

Starts at final frame, fades out before restarting, settles smoothly on hover leave.

Two trigger modes

Autoplay loops infinitely. Hover loops while hovered, settles on leave.

SSR support

renderToString() outputs SVG at final frame. No DOM needed.

Color interpolation

Hex color animation with RGB lerp. Detected automatically from # prefix.

React Integration

import { createAnimation } from 'loopkit';
import { useEffect, useRef } from 'react';

function AnimatedCover({ schema }) {
  const ref = useRef(null);

  useEffect(() => {
    if (!ref.current) return;
    const anim = createAnimation(ref.current, schema);
    return () => anim.destroy();
  }, [schema]);

  return <div ref={ref} className="w-full aspect-3/2" />;
}

How It Works

1

Define a schema

Write a plain JS/JSON object with canvas dimensions, element types (rect, text, circle, badge), and animation keyframes.

2

Mount with createAnimation()

Pass a DOM container and your schema. The engine creates an SVG, applies the final frame immediately (no flash), and starts playback.

3

Control playback

Use play(), pause(), reset(), settle(), and destroy() to control the animation lifecycle. Trigger modes handle autoplay and hover automatically.

Schema-Driven SVG Animation

Loopkit follows a declarative model: you define what elements look like and how they animate, the engine handles rendering and timing. Each element has a style (resting state) and an optional animate config with [from, to] keyframe pairs. The engine interpolates between values using requestAnimationFrame.

FAQ

Varstatt Toolkit

Each tool works standalone, runs entirely in your browser, and requires no signup.

Built & Maintained by Varstatt

Varstatt is a one-person product studio run by Jurij Tokarski, product engineer since 2011. These tools are free and open — no signup, no catch.