tailwindcss-animate
美しいアニメーションを作成するためのTailwind CSSプラグイン。
<!-- Add an animated fade and zoom entrance -->
< div class =" animate-in fade-in zoom-in " > ... </ div >
<!-- Add an animated slide to top-left exit -->
< div class =" animate-out slide-out-to-top slide-out-to-left " > ... </ div >
<!-- Control animation duration -->
< div class =" ... duration-300 " > ... </ div >
<!-- Control animation delay -->
< div class =" ... delay-150 " > ... </ div >
<!-- And so much more! -->
NPMからプラグインをインストールします。
npm install -D tailwindcss-animate
次に、Pluginをtailwind.config.js
ファイルに追加します。
// @filename tailwind.config.js
module . exports = {
theme : {
// ...
} ,
plugins : [
require ( "tailwindcss-animate" ) ,
// ...
] ,
}
delay-{amount}
ユーティリティを使用して、要素のanimation-delay
を制御します。
< button class =" animate-bounce delay-150 duration-300 ... " > Button A </ button >
< button class =" animate-bounce delay-300 duration-300 ... " > Button B </ button >
< button class =" animate-bounce delay-700 duration-300 ... " > Button C </ button >
詳細については、アニメーション遅延ドキュメントをご覧ください。
direction-{keyword}
ユーティリティを使用して、要素のanimation-delay
を制御します。
< button class =" animate-bounce direction-normal ... " > Button A </ button >
< button class =" animate-bounce direction-reverse ... " > Button B </ button >
< button class =" animate-bounce direction-alternate ... " > Button C </ button >
< button class =" animate-bounce direction-alternate-reverse ... " > Button C </ button >
詳細については、Animation Directionドキュメントをご覧ください。
duration-{amount}
ユーティリティを使用して、要素のanimation-duration
を制御します。
< button class =" animate-bounce duration-150 ... " > Button A </ button >
< button class =" animate-bounce duration-300 ... " > Button B </ button >
< button class =" animate-bounce duration-700 ... " > Button C </ button >
詳細については、アニメーション期間のドキュメントをご覧ください。
fill-mode-{keyword}
ユーティリティを使用して、要素のanimation-fill-mode
を制御します。
< button class =" animate-bounce fill-mode-none ... " > Button A </ button >
< button class =" animate-bounce fill-mode-forwards ... " > Button B </ button >
< button class =" animate-bounce fill-mode-backwards ... " > Button C </ button >
< button class =" animate-bounce fill-mode-both ... " > Button C </ button >
詳細については、アニメーションフィルモードのドキュメントをご覧ください。
repeat-{amount}
ユーティリティを使用して、要素のanimation-iteration-count
を制御します。
< button class =" animate-bounce repeat-0 ... " > Button A </ button >
< button class =" animate-bounce repeat-1 ... " > Button B </ button >
< button class =" animate-bounce repeat-infinite ... " > Button C </ button >
詳細については、Animation Iteration countドキュメントをご覧ください。
running
およびpaused
ユーティリティを使用して、要素のanimation-play-state
を制御します。
< button class =" animate-bounce running ... " > Button B </ button >
< button class =" animate-bounce paused ... " > Button A </ button >
詳細については、Animation Play Stateドキュメントをご覧ください。
ease-{keyword}
ユーティリティを使用して、要素のanimation-timing-function
を制御します。
< button class =" animate-bounce ease-linear ... " > Button A </ button >
< button class =" animate-bounce ease-in ... " > Button B </ button >
< button class =" animate-bounce ease-out ... " > Button C </ button >
< button class =" animate-bounce ease-in-out ... " > Button C </ button >
詳細については、アニメーションタイミング関数のドキュメントをご覧ください。
ユーザーがモーションの減少を好むことを指定している状況については、 motion-safe
およびmotion-reduce
バリアントを使用してアニメーションと遷移を条件付きで適用できます。
< button class =" motion-safe:animate-bounce ... " > Button B </ button >
要素を入力するには、Animation、 animate-in
ユーティリティを使用してfade-in
、 spin-in
、 zoom-in
、 slide-in-from
ユーティリティを組み合わせて使用します。
< button class =" animate-in fade-in ... " > Button A </ button >
< button class =" animate-in spin-in ... " > Button B </ button >
< button class =" animate-in zoom-in ... " > Button C </ button >
< button class =" animate-in slide-in-from-top ... " > Button D </ button >
< button class =" animate-in slide-in-from-left ... " > Button E </ button >
Enter Animationドキュメントで詳細をご覧ください。
ElementにExitアニメーションを与えるには、 animate-out
ユーティリティを使用して、いくつかのfade-out
、 spin-out
、 zoom-out
、 slide-out-from
ユーティリティと組み合わせて使用します。
< button class =" animate-out fade-out ... " > Button A </ button >
< button class =" animate-out spin-out ... " > Button B </ button >
< button class =" animate-out zoom-out ... " > Button C </ button >
< button class =" animate-out slide-out-from-top ... " > Button D </ button >
< button class =" animate-out slide-out-from-left ... " > Button E </ button >
Exit Animationドキュメントで詳細をご覧ください。
fade-in-{amount}
ユーティリティを使用して、アニメーションの開始不透明度を設定します。
< button class =" animate-in fade-in ... " > Button A </ button >
< button class =" animate-in fade-in-25 ... " > Button B </ button >
< button class =" animate-in fade-in-50 ... " > Button C </ button >
< button class =" animate-in fade-in-75 ... " > Button C </ button >
Enter Animation Opacity Documentationで詳細をご覧ください。
spin-in-{amount}
ユーティリティを使用して、アニメーションの開始回転を設定します。
< button class =" animate-in spin-in-1 ... " > Button A </ button >
< button class =" animate-in spin-in-6 ... " > Button B </ button >
< button class =" animate-in spin-in-75 ... " > Button C </ button >
< button class =" animate-in spin-in-90 ... " > Button C </ button >
詳細については、Enter Animation Rotateドキュメントをご覧ください。
zoom-in-{amount}
ユーティリティを使用して、アニメーションの開始スケールを設定します。
< button class =" animate-in zoom-in ... " > Button A </ button >
< button class =" animate-in zoom-in-50 ... " > Button B </ button >
< button class =" animate-in zoom-in-75 ... " > Button C </ button >
< button class =" animate-in zoom-in-95 ... " > Button C </ button >
Enter Animationスケールのドキュメントで詳細をご覧ください。
slide-in-from-{direction}-{amount}
ユーティリティを使用して、アニメーションの開始翻訳を設定します。
< button class =" animate-in slide-in-from-top ... " > Button A </ button >
< button class =" animate-in slide-in-from-bottom-48 ... " > Button B </ button >
< button class =" animate-in slide-in-from-left-72 ... " > Button C </ button >
< button class =" animate-in slide-in-from-right-96 ... " > Button C </ button >
詳細については、Enter Animation Translateドキュメントをご覧ください。
fade-out-{amount}
ユーティリティを使用して、アニメーションのエンディングの不透明度を設定します。
< button class =" animate-out fade-out ... " > Button A </ button >
< button class =" animate-out fade-out-25 ... " > Button B </ button >
< button class =" animate-out fade-out-50 ... " > Button C </ button >
< button class =" animate-out fade-out-75 ... " > Button C </ button >
Exit Animation Opacity Documentationで詳細をご覧ください。
spin-out-{amount}
ユーティリティを使用して、アニメーションの終了回転を設定します。
< button class =" animate-out spin-out-1 ... " > Button A </ button >
< button class =" animate-out spin-out-6 ... " > Button B </ button >
< button class =" animate-out spin-out-75 ... " > Button C </ button >
< button class =" animate-out spin-out-90 ... " > Button C </ button >
Exit Animation Rotateドキュメントで詳細をご覧ください。
zoom-out-{amount}
ユーティリティを使用して、アニメーションの終了スケールを設定します。
< button class =" animate-out zoom-out ... " > Button A </ button >
< button class =" animate-out zoom-out-50 ... " > Button B </ button >
< button class =" animate-out zoom-out-75 ... " > Button C </ button >
< button class =" animate-out zoom-out-95 ... " > Button C </ button >
Exit Animationスケールのドキュメントで詳細をご覧ください。
slide-out-to-{direction}-{amount}
ユーティリティを使用して、アニメーションのエンディング翻訳を設定します。
< button class =" animate-out slide-out-to-top ... " > Button A </ button >
< button class =" animate-out slide-out-to-bottom-48 ... " > Button B </ button >
< button class =" animate-out slide-out-to-left-72 ... " > Button C </ button >
< button class =" animate-out slide-out-to-right-96 ... " > Button C </ button >
Exit Animation翻訳ドキュメントで詳細をご覧ください。