Skip to content

secondsky/claude-skills / plugins/auto-animate/skills/auto-animate

auto-animate

Verified

AutoAnimate (@formkit/auto-animate) zero-config animations for React. Use for list transitions, accordions, toasts, or encountering SSR errors, animation libraries complexity.

templates/react-basic.tsx

View on GitHub
// AutoAnimate - Basic React Example
// @formkit/auto-animate v0.10.0

import { useAutoAnimate } from "@formkit/auto-animate/react";
import { useState } from "react";

/**
 * Example: Simple List Animation with AutoAnimate
 *
 * Key Features:
 * - Zero config - just add the ref
 * - Automatically animates add/remove/move
 * - Respects prefers-reduced-motion
 * - Works with any list structure
 */

interface Item {
  id: number;
  text: string;
}

export function BasicListExample() {
  // 1. Get the ref from useAutoAnimate hook
  const [parent] = useAutoAnimate();

  // 2. Set up state
  const [items, setItems] = useState<Item[]>([
    { id: 1, text: "Item 1" },
    { id: 2, text: "Item 2" },
    { id: 3, text: "Item 3" },
  ]);

  // 3. Functions to modify the list
  const addItem = () => {
    const newId = Math.max(...items.map(item => item.id), 0) + 1;
    setItems([...items, { id: newId, text: `Item ${newId}` }]);
  };

  const removeItem = (id: number) => {
    setItems(items.filter(item => item.id !== id));
  };

  const shuffleItems = () => {
    setItems([...items].sort(() => Math.random() - 0.5));
  };

  return (
    <div className="space-y-4 p-6">
      {/* Controls */}
      <div className="flex gap-2">
        <button
          onClick={addItem}
          className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"
        >
          Add Item
        </button>
        <button
          onClick={shuffleItems}
          className="px-4 py-2 bg-purple-600 text-white rounded hover:bg-purple-700"
        >
          Shuffle
        </button>
      </div>

      {/* 4. Attach ref to parent element - that's it! */}
      <ul ref={parent} className="space-y-2">
        {items.map((item) => (
          <li
            key={item.id}
            className="flex items-center justify-between p-4 bg-white border rounded shadow-sm"
          >
            <span>{item.text}</span>
            <button
              onClick={() => removeItem(item.id)}
              className="px-3 py-1 bg-red-500 text-white rounded hover:bg-red-600"
            >
              Remove
            </button>
          </li>
        ))}
      </ul>
    </div>
  );
}

/**
 * CRITICAL:
 * - ✅ Always use unique, stable keys for list items
 * - ✅ Attach ref to immediate parent of animated children
 * - ✅ Parent element must always be in DOM (not conditionally rendered)
 * - ✅ AutoAnimate respects prefers-reduced-motion automatically
 */

/**
 * Common Mistakes:
 *
 * ❌ Wrong: Conditional parent
 * {showList && <ul ref={parent}>...</ul>}
 *
 * ✅ Correct: Always-rendered parent, conditional children
 * <ul ref={parent}>{showList && items.map(...)}</ul>
 *
 * ❌ Wrong: Missing or non-unique keys
 * {items.map((item, index) => <li key={index}>...)}
 *
 * ✅ Correct: Unique, stable keys
 * {items.map(item => <li key={item.id}>...)}
 */
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall