Communitygithub.com

アニメーションコンポーネントライブラリ

Magic UI(150以上のTypeScript/Tailwind/Motionコンポーネント)とReact Bits(90以上の軽量アニメーションコンポーネント)を組み合わせた、事前構築済みのアニメーションReactコンポーネントコレクション。ランディングページやマーケティングサイト、ダッシュボード、インタラクティブなUIを構築する際に、アニメーションを手動で実装する代わりに使用します。

アニメーションコンポーネントライブラリ とは?

このスキルは、Magic UIとReact Bitsという2つの主要なアニメーションReactコンポーネントライブラリに関する専門知識を提供します。Magic UIは150以上のTypeScriptコンポーネントを提供し、Tailwind CSSとFramer Motionをベースに、shadcn/uiとのシームレスな統合に最適化されています。React Bitsは90以上の軽量アニメーションコンポーネントを提供し、視覚効果、背景、マイクロインタラクションに重点を置き、パフォーマンスとカスタマイズの容易さを重視しています。両ライブラリとも最新のReactパターンに従い、TypeScriptをサポートし、一般的なデザインシステムと統合できます。このスキルは、事前構築済みのアニメーションコンポーネントを使用して、Framer MotionやGSAPでアニメーションを手動で実装する手間を省き、開発を大幅に加速したい開発者に最適です。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/kschiavo-beep/claude-skills/tree/HEAD/.claude/skills/animated-component-libraries

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

アニメーションコンポーネントライブラリ は何をしますか?

概要

このスキルは、事前構築済みのアニメーションReactコンポーネントライブラリ、特にMagic UIとReact Bitsに関する専門知識を提供します。これらのライブラリは、本番環境で使用可能なアニメーションコンポーネントを提供し、モダンでインタラクティブなWebアプリケーションの開発を大幅に加速します。

Magic UI は、Tailwind CSSとFramer Motionをベースにした150以上のTypeScriptコンポーネントを提供し、shadcn/uiとのシームレスな統合を想定して設計されています。コンポーネントはコピーペーストですぐに使用でき、カスタマイズ性も高いです。

React Bits は、最小限の依存関係で90以上のアニメーションReactコンポーネントを提供し、視覚効果、背景、マイクロインタラクションに重点を置いています。コンポーネントはパフォーマンスとカスタマイズの容易さを重視しています。

両ライブラリとも、最新のReactパターンに従い、TypeScriptをサポートし、人気のあるデザインシステムと統合できます。

コアコンセプト

Magic UI アーキテクチャ

Magic UIコンポーネントは、以下の3つの基本技術に基づいて構築されています。

  1. Tailwind CSS: tailwind.config.js で完全にカスタマイズ可能なユーティリティファーストなスタイリング
  2. Framer Motion: 物理ベースのアニメーションとジェスチャー認識
  3. shadcn/ui 統合: CLIインストールとコンポーネント構造に関するshadcnの規約に従います

インストール方法:

# shadcn CLIを使用(推奨)
npx shadcn@latest add https://magicui.design/r/animated-beam

# 手動インストール
# 1. コンポーネントコードを components/ui/ にコピー
# 2. motionをインストール: npm install motion
# 3. 必要なCSSアニメーションを globals.css に追加
# 4. cn() ユーティリティが lib/utils.ts に存在することを確認

コンポーネント構造:

// すべてのMagic UIコンポーネントは以下のパターンに従います:
import { cn } from "@/lib/utils"
import { motion } from "motion/react"

interface ComponentProps extends React.ComponentPropsWithoutRef<"div"> {
  customProp?: string
  className?: string
}

export function MagicComponent({ className, customProp, ...props }: ComponentProps) {
  return (
    <motion.div
      className={cn("base-styles", className)}
      {...props}
    >
      {/* コンポーネントの内容 */}
    </motion.div>
  )
}

React Bits アーキテクチャ

React Bitsは、軽量でスタンドアロンなコンポーネントを重視しています:

  1. 自己完結型: 各コンポーネントの外部依存関係は最小限
  2. CSS-in-JS オプション: 多くのコンポーネントがインラインスタイルまたはCSSモジュールを使用
  3. パフォーマンス優先: 60fpsのアニメーションに最適化
  4. WebGL サポート: 一部のコンポーネント(Particles、Plasma)は高度なエフェクトにWebGLを使用

インストール:

# 手動コピーペースト(主要な方法)
# reactbits.devからコンポーネントファイルをプロジェクトにコピー

# 主要な依存関係(必要に応じてインストール):
npm install framer-motion  # アニメーションを多用するコンポーネント用
npm install ogl           # WebGLコンポーネント(Particles、Plasma)用

コンポーネントカテゴリ:

  • テキストアニメーション: BlurText、CircularText、CountUp、SpinningText
  • インタラクティブ要素: MagicButton、Magnet、Dock、Stepper
  • 背景: Aurora、Plasma、Particles
  • リストとレイアウト: AnimatedList、Bento Grid

一般的なパターン

1. Magic UI: アニメーション背景パターン

SVGベースのパターンで動的な背景効果を作成します:

import { GridPattern } from "@/components/ui/grid-pattern"
import { AnimatedGridPattern } from "@/components/ui/animated-grid-pattern"
import { cn } from "@/lib/utils"

export default function HeroSection() {
  return (
    <div className="relative flex h-[500px] w-full items-center justify-center overflow-hidden rounded-lg border">
      {/* 静的グリッドパターン */}
      <GridPattern
        squares={[
          [4, 4], [5, 1], [8, 2], [5, 3], [10, 10], [12, 15]
        ]}
        className={cn(
          "[mask-image:radial-gradient(400px_circle_at_center,white,transparent)]",
          "fill-gray-400/30 stroke-gray-400/30"
        )}
      />

      {/* アニメーションインタラクティブグリッド */}
      <AnimatedGridPattern
        numSquares={50}
        maxOpacity={0.5}
        duration={4}
        repeatDelay={0.5}
        className={cn(
          "[mask-image:radial-gradient(500px_circle_at_center,white,transparent)]",
          "inset-x-0 inset-y-[-30%] h-[200%] skew-y-12"
        )}
      />

      <h1 className="relative z-10 text-6xl font-bold">
        あなたのコンテンツをここに
      </h1>
    </div>
  )
}

2. React Bits: テキストリビールアニメーション

BlurTextでスクロールトリガーのテキスト表示を実装:

import BlurText from './components/BlurText'

export default function MarketingSection() {
  return (
    <section className="py-20">
      {/* 単語ごとの表示 */}
      <BlurText
        text="あなたのアイデアを現実に変えましょう"
        delay={100}
        animateBy="words"
        direction="top"
        className="text-5xl font-bold text-center mb-8"
      />

      {/* カスタムイージングによる文字ごとの表示 */}
      <BlurText
        text="指先で感じるピクセルパーフェクトなアニメーション"
        delay={50}
        animateBy="characters"
        direction="bottom"
        threshold={0.3}
        stepDuration={0.4}
        animationFrom={{ filter: 'blur(20px)', opacity: 0, y: 50 }}
        animationTo={{ filter: 'blur(0px)', opacity: 1, y: 0 }}
        className="text-2xl text-gray-600 text-center"
      />
    </section>
  )
}

3. Magic UI: エフェクト付きボタンコンポーネント

シマーエフェクトとボーダービームエフェクトでインタラクティブなボタンを作成:

import { ShimmerButton } from "@/components/ui/shimmer-button"
import { BorderBeam } from "@/components/ui/border-beam"
import { Button } from "@/components/ui/button"
import { Card } from "@/components/ui/card"

export default function CTASection() {
  return (
    <div className="flex gap-4 items-center">
      {/* シマーボタン */}
      <ShimmerButton
        shimmerColor="#ffffff"
        shimmerSize="0.05em"
        shimmerDuration="3s"
        borderRadius="100px"
        background="rgba(0, 0, 0, 1)"
        className="px-8 py-3"
      >
        はじめる
      </ShimmerButton>

      {/* アニメーション枠線付きカード */}
      <Card className="relative w-[350px] overflow-hidden">
        <div className="p-6">
          <h3 className="text-2xl font-bold">プレミアムプラン</h3>
          <p className="text-gray-600">すべての機能を解放</p>
          <Button className="mt-4">購読する</Button>
        </div>
        <BorderBeam duration={8} size={100} />
      </Card>
    </div>
  )
}

4. React Bits: インタラクティブドックナビゲーション

拡大効果のあるmacOSスタイルのドックを実装:

import Dock from './components/Dock'
import { VscHome, VscArchive, VscAccount, VscSettingsGear } from 'react-icons/vsc'
import { useNavigate } from 'react-router-dom'

export default function AppNavigation() {
  const navigate = useNavigate()

  const dockItems = [
    {
      icon: <VscHome size={24} />,
      label: 'ダッシュボード',
      onClick: () => navigate('/dashboard')
    },
    {
      icon: <VscArchive size={24} />,
      label: 'プロジェクト',
      onClick: () => navigate('/projects')
    },
    {
      icon: <VscAccount size={24} />,
      label: 'プロフィール',
      onClick: () => navigate('/profile')
    },
    {
      icon: <VscSettingsGear size={24} />,
      label: '設定',
      onClick: () => navigate('/settings')
    }
  ]

  return (
    <div className="fixed bottom-4 left-1/2 -translate-x-1/2">
      <Dock
        items={dockItems}
        spring={{ mass: 0.15, stiffness: 200, damping: 15 }}
        magnification={80}
        distance={250}
        panelHeight={70}
        baseItemSize={55}
      />
    </div>
  )
}

5. React Bits: CountUpを使ったアニメーション統計表示

ダッシュボードやランディングページにアニメーションする数値を表示:

import CountUp from './components/CountUp'

export default function Statistics() {
  return (
    <div className="grid grid-cols-1 md:grid-cols-3 gap-8 py-16">
      {/* 収益カウンター */}
      <div className="stat-card text-center">
        <CountUp
          start={0}
          end={1000000}
          duration={3}
          separator=","
          prefix="$"
          className="text-6xl font-bold text-blue-600"
        />
        <p className="text-xl text-gray-600 mt-2">総収益</p>
      </div>

      {/* 稼働率 */}
      <div className="stat-card text-center">
        <CountUp
          end={99.9}
          duration={2.5}
          decimals={1}
          suffix="%"
          className="text-6xl font-bold text-green-600"
        />
        <p className="text-xl text-gray-600 mt-2">稼働率</p>
      </div>

      {/* 顧客数 */}
      <div className="stat-card text-center">
        <CountUp
          end={10000}
          duration={2}
          separator=","
          className="text-6xl font-bold text-purple-600"
        />
        <p className="text-xl text-gray-600 mt-2">ご利用のお客様</p>
      </div>
    </div>
  )
}

6. Magic UI: 無限スクロール用Marqueeコンポーネント

無限にスクロールするコンテンツ表示を作成:

import { Marquee } from "@/components/ui/marquee"

const testimonials = [
  { name: "山田太郎", text: "素晴らしい製品です!", avatar: "/avatar1.jpg" },
  { name: "佐藤花子", text: "期待を超えていました", avatar: "/avatar2.jpg" },
  { name: "鈴木一郎", text: "強くお勧めします", avatar: "/avatar3.jpg" }
]

export default function Testimonials() {
  return (
    <section className="py-20">
      <h2 className="text-4xl font-bold text-center mb-12">
        お客様の声
      </h2>

      {/* 水平Marquee */}
      <Marquee pauseOnHover className="[--duration:40s]">
        {testimonials.map((item, idx) => (
          <div key={idx} className="mx-4 w-[350px] rounded-lg border p-6">
            <p className="text-lg mb-4">"{item.text}"</p>
            <div className="flex items-center gap-3">
              <img src={item.avatar} alt={item.name} className="w-10 h-10 rounded-full" />
              <p className="font-semibold">{item.name}</p>
            </div>
          </div>
        ))}
      </Marquee>

      {/* 垂直Marquee */}
      <Marquee vertical reverse className="h-[400px] mt-8">
        {testimonials.map((item, idx) => (
          <div key={idx} className="my-4 w-full max-w-md rounded-lg border p-6">
            <p>{item.text}</p>
          </div>
        ))}
      </Marquee>
    </section>
  )
}

7. React Bits: WebGL背景エフェクト

高性能なアニメーション背景を追加:

import Particles from './components/Particles'
import Plasma from './components/Plasma'
import Aurora from './components/Aurora'

// パーティクルエフェクト
function ParticlesHero() {
  return (
    <section style={{ position: 'relative', height: '100vh' }}>
      <Particles
        particleCount={200}
        particleColors={['#FF6B6B', '#4ECDC4', '#45B7D1']}
        particleSpread={10}
        speed={0.12}
        moveParticlesOnHover={true}
        particleHoverFactor={2}
        particleBaseSize={100}
        sizeRandomness={1.2}
        alphaParticles={true}
        cameraDistance={20}
        className="particles-bg"
      />
      <div className="relative z-10 flex items-center justify-center h-full">
        <h1 className="text-7xl font-bold text-white">
          未来へようこそ
        </h1>
      </div>
    </section>
  )
}

// プラズマエフェクト
function PlasmaBackground() {
  return (
    <div className="relative min-h-screen">
      <Plasma
        color1="#FF0080"
        color2="#7928CA"
        color3="#00DFD8"
        speed={0.8}
        blur={30}
        className="plasma-bg"
      />
      <div className="relative z-10 p-8">
        <h1>プラズマ背景のコンテンツ</h1>
      </div>
    </div>
  )
}

// オーロラエフェクト
function AuroraHero() {
  return (
    <div className="relative min-h-screen">
      <Aurora
        colors={['#FF00FF', '#00FFFF', '#FFFF00']}
        speed={0.5}
        blur={80}
      />
      <main className="relative z-10">
        <h1>サイバーパンクオーロラエフェクト</h1>
      </main>
    </div>
  )
}

統合パターン

shadcn/uiとの統合

Magic UIコンポーネントは、shadcn/uiとシームレスに連携するように設計されています:

# shadcn/uiコンポーネントのインストール
npx shadcn@latest add button card

# Magic UIコンポーネントのインストール
npx shadcn@latest add https://magicui.design/r/shimmer-button

# コンポーネントでの併用
import { Button } from "@/components/ui/button"
import { Card } from "@/components/ui/card"
import { ShimmerButton } from "@/components/ui/shimmer-button"
import { BorderBeam } from "@/components/ui/border-beam"

必要なユーティリティ関数 (lib/utils.ts):

import clsx, { ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

Framer Motionとの統合

両ライブラリとも、アニメーションにFramer Motionを活用しています:

import { motion } from "framer-motion"
import { Magnet } from './components/Magnet'

// React BitsのMagnetとFramer Motionのジェスチャーを組み合わせる
export default function InteractiveCard() {
  return (
    <Magnet magnitude={0.4} maxDistance={180}>
      <motion.div
        whileHover={{ scale: 1.05 }}
        whileTap={{ scale: 0.95 }}
        className="card p-6 rounded-xl shadow-lg"
      >
        <h3>インタラクティブカード</h3>
        <p>磁気的な引き寄せとスケールアニメーションを組み合わせます</p>
      </motion.div>
    </Magnet>
  )
}

React Routerとの統合

アニメーションコンポーネントとルーティングを組み合わせる:

import { AnimatePresence, motion } from "framer-motion"
import { useLocation, Routes, Route } from "react-router-dom"
import { Dock } from './components/Dock'

export default function App() {
  const location = useLocation()

  return (
    <>
      {/* アニメーションページ遷移 */}
      <AnimatePresence mode="wait">
        <Routes location={location} key={location.pathname}>
          <Route path="/" element={
            <motion.div
              initial={{ opacity: 0, y: 20 }}
              animate={{ opacity: 1, y: 0 }}
              exit={{ opacity: 0, y: -20 }}
              transition={{ duration: 0.3 }}
            >
              <h1>ホームページ</h1>
            </motion.div>
          } />
        </Routes>
      </AnimatePresence>

      {/* 固定ドックナビゲーション */}
      <Dock
        items={[
          { icon: <span>🏠</span>, label: 'ホーム', onClick: () => {} },
          { icon: <span>📁</span>, label: 'プロジェクト', onClick: () => {} },
          { icon: <span>📞</span>, label: 'お問い合わせ', onClick: () => {} },
        ]}
        panelHeight={68}
        baseItemSize={50}
        magnification={70}
      />
    </>
  )
}

パフォーマンスの考慮事項

魔法UIの最適化

  • motion の代わりに motion.div を使用してバンドルサイズを削減
  • 不必要な再レンダリングを避けるために、コンポーネント定義の外でアニメーション設定を抽出
  • アニメーションのパフォーマンスを確保するため、will-change と transform-gpu を活用
  • ウィンドウに表示されていないコンポーネントには、IntersectionObserver ベースの遅延読み込みを実装

React Bitsの最適化

  • WebGLコンポーネントがオフスクリーンの場合は、自動的にフレームレートを低下させる
  • トランジションが完了したコンポーネントには、shouldAnimate プロパティを使用してアニメーションを無効化
  • 多数のパーティクルや背景コンポーネントには、Canvasベースのレンダリングを活用
  • コンポーネントのメモ化(useMemo、React.memo)を使用して計算負荷の高いレンダリングを削減

これら2つのライブラリでカバーされない特定のアニメーションニーズについては、GSAPやThree.jsなどの特殊なアニメーションライブラリの使用を検討してください。しかし、ほとんどの標準的なUIアニメーションシナリオでは、Magic UIとReact Bitsが、Framer MotionやCSSアニメーションを使ってスクラッチでコンポーネントを構築するよりも、より包括的で手頃なソリューションを提供します。

Individual skills in this repo

This repo contains 2 individual skills — each has its own dedicated page.

関連スキル