mcpField
T
tailwindcss-animations

tailwindcss-animations

github.com/josiahsiegelデザイン・UI592.4k 回インストール19 週間前に更新
リポジトリ

tailwindcss-animations について

tailwindcss-animationsは、Tailwind CSSのアニメーションとトランジション用ユーティリティを扱うスキルです。動きの追加や独自アニメーションの定義に加え、視覚効果を減らす設定にも配慮できます。

主な機能

  1. 01spin・ping・pulse・bounceの組み込み効果
  2. 02トランジションのプロパティ・時間・遅延
  3. 03拡大縮小・回転・移動・傾斜のユーティリティ
  4. 04v4でのカスタムアニメーションとイージング
  5. 05視覚効果を減らす設定へのアクセシビリティ対応

活用シーン

  1. 01ローディング表示やスケルトン効果の追加
  2. 02ホバーやボタン操作のアニメーション
  3. 03独自のフェードやスライド演出の作成
  4. 04視覚効果を減らす設定への対応

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill tailwindcss-animations

インストール後、Claude Code で/tailwindcss-animationsを入力して読み込まれたか確認します。

同梱ファイルreferences/animation-patterns.md

詳細

Tailwind CSS のアニメーションとトランジション

組み込みアニメーション

回転

ローディングインジケーター向けの連続回転です。

<svg class="animate-spin h-5 w-5 text-blue-500" viewBox="0 0 24 24">
  <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
  <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" />
</svg>
ピン

通知向けのレーダー風パルスです。

<span class="relative flex h-3 w-3">
  <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75"></span>
  <span class="relative inline-flex rounded-full h-3 w-3 bg-sky-500"></span>
</span>
パルス

スケルトンローダー向けの控えめなフェードです。

<div class="animate-pulse flex space-x-4">
  <div class="rounded-full bg-slate-200 h-10 w-10"></div>
  <div class="flex-1 space-y-2 py-1">
    <div class="h-2 bg-slate-200 rounded"></div>
    <div class="h-2 bg-slate-200 rounded w-5/6"></div>
  </div>
</div>
バウンス

注意を引く垂直方向のバウンスです。

<svg class="animate-bounce w-6 h-6 text-blue-500" fill="none" viewBox="0 0 24 24">
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 14l-7 7m0 0l-7-7m7 7V3" />
</svg>

トランジション

トランジションプロパティ
クラスCSS プロパティ
transition-noneなし
transition-allすべてのプロパティ
transition一般的なプロパティ
transition-colors色のみ
transition-opacity不透明度のみ
transition-shadowシャドウのみ
transition-transform変形のみ
トランジションの継続時間
クラス継続時間
duration-7575ms
duration-100100ms
duration-150150ms
duration-200200ms
duration-300300ms
duration-500500ms
duration-700700ms
duration-10001000ms
トランジションのタイミング関数
クラスイージング
ease-linearリニア
ease-in加速
ease-out減速
ease-in-out加速してから減速
トランジションの遅延
クラス遅延
delay-7575ms
delay-100100ms
delay-150150ms
delay-200200ms
delay-300300ms
delay-500500ms
基本的なトランジションの例

<button class="bg-blue-500 hover:bg-blue-700 transition-colors duration-200">
  Hover me
</button>


<div class="transform hover:scale-105 transition-transform duration-200">
  Card
</div>


<div class="opacity-100 hover:opacity-75 transition-opacity duration-150">
  Fade
</div>


<button class="
  bg-blue-500 hover:bg-blue-700
  transform hover:scale-105
  shadow-md hover:shadow-lg
  transition-all duration-200
">
  Full transition
</button>

変形ユーティリティ

拡大・縮小
<div class="transform scale-100 hover:scale-110 transition-transform">
  Scale up
</div>

<div class="transform scale-100 hover:scale-90 transition-transform">
  Scale down
</div>


<div class="transform hover:scale-x-110">Horizontal</div>
<div class="transform hover:scale-y-110">Vertical</div>
回転
<div class="transform hover:rotate-12 transition-transform">
  Rotate right
</div>

<div class="transform hover:-rotate-12 transition-transform">
  Rotate left
</div>

<div class="transform hover:rotate-180 transition-transform duration-500">
  Flip
</div>
移動
<div class="transform hover:translate-x-2 transition-transform">
  Move right
</div>

<div class="transform hover:-translate-y-2 transition-transform">
  Move up
</div>
傾斜
<div class="transform hover:skew-x-3 transition-transform">
  Skew horizontal
</div>

<div class="transform hover:skew-y-3 transition-transform">
  Skew vertical
</div>
変形の原点
<div class="origin-center transform hover:rotate-45">Center (default)</div>
<div class="origin-top-left transform hover:rotate-45">Top left</div>
<div class="origin-bottom-right transform hover:rotate-45">Bottom right</div>

カスタムアニメーション(v4)

@theme で定義する
@theme {
  /* Custom keyframes */
  --animate-fade-in: fade-in 0.5s ease-out;
  --animate-slide-up: slide-up 0.3s ease-out;
  --animate-shake: shake 0.5s ease-in-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
使用方法
<div class="animate-fade-in">Fades in</div>
<div class="animate-slide-up">Slides up</div>
<div class="animate-shake">Shakes on error</div>
カスタムイージング
@theme {
  --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
<div class="transition-transform ease-bounce duration-300 hover:scale-110">
  Bouncy scale
</div>

アクセシビリティ:モーションの低減

motion-safe / motion-reduce

<div class="motion-safe:animate-bounce motion-reduce:animate-none">
  Respects preferences
</div>


<button class="
  motion-safe:transition-all motion-safe:duration-200
  motion-reduce:transition-none
  hover:bg-blue-600
">
  Accessible button
</button>
モーション低減のパターン
/* Apply globally */
@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

よく使われるアニメーションパターン

ホバーカードの浮き上がり
<div class="
  transform transition-all duration-200
  hover:-translate-y-1 hover:shadow-lg
  bg-white rounded-lg p-6 shadow
">
  Card content
</div>
ボタンを押したときの効果
<button class="
  transform transition-transform duration-100
  active:scale-95
  bg-blue-500 text-white px-4 py-2 rounded
">
  Click me
</button>
ローディングドット
<div class="flex space-x-1">
  <div class="w-2 h-2 bg-blue-500 rounded-full animate-bounce [animation-delay:-0.3s]"></div>
  <div class="w-2 h-2 bg-blue-500 rounded-full animate-bounce [animation-delay:-0.15s]"></div>
  <div class="w-2 h-2 bg-blue-500 rounded-full animate-bounce"></div>
</div>
スクロール時のフェードイン(JS 使用)
<div class="opacity-0 translate-y-4 transition-all duration-500" data-animate>
  Content that fades in
</div>
// Intersection Observer to trigger animation
const observer = new IntersectionObserver((entries) => {
  entries.forEach(entry => {
    if (entry.isIntersecting) {
      entry.target.classList.remove('opacity-0', 'translate-y-4')
    }
  })
})

document.querySelectorAll('[data-animate]').forEach(el => observer.observe(el))
スケルトンローダー
<div class="animate-pulse">
  <div class="h-4 bg-gray-200 rounded w-3/4 mb-4"></div>
  <div class="h-4 bg-gray-200 rounded w-1/2 mb-4"></div>
  <div class="h-4 bg-gray-200 rounded w-5/6"></div>
</div>
ハンバーガーメニューから X へのアニメーション
<button class="group" aria-label="Toggle menu">
  <span class="block w-6 h-0.5 bg-black transition-all duration-200 group-open:rotate-45 group-open:translate-y-1.5"></span>
  <span class="block w-6 h-0.5 bg-black mt-1 transition-opacity duration-200 group-open:opacity-0"></span>
  <span class="block w-6 h-0.5 bg-black mt-1 transition-all duration-200 group-open:-rotate-45 group-open:-translate-y-1.5"></span>
</button>

入場/退場時のトランジション(JS 使用)

複雑な入場/退場時のトランジションには、Headless UI などのライブラリを使用します。

import { Transition } from '@headlessui/react'

function Modal({ isOpen, children }) {
  return (
    <Transition
      show={isOpen}
      enter="transition-opacity duration-300"
      enterFrom="opacity-0"
      enterTo="opacity-100"
      leave="transition-opacity duration-200"
      leaveFrom="opacity-100"
      leaveTo="opacity-0"
    >
      {children}
    </Transition>
  )
}

パフォーマンスのヒント

1. GPU アクセラレーション対応プロパティを優先する

<div class="transform hover:translate-x-2 transition-transform">


<div class="hover:left-2 transition-all">
2. 対象を限定したトランジションを使う

<div class="transition-colors duration-200 hover:bg-blue-500">


<div class="transition-all duration-200 hover:bg-blue-500">
3. アニメーションを短く保つ

<button class="transition-colors duration-150">


<button class="transition-colors duration-1000">
4. will-change は控えめに使う

<div class="will-change-transform animate-spin">
  Loading spinner
</div>

コメント