Communitygithub.com

マイクロインタラクション(UIモーション)

ホバー/プレス効果、トグルのアニメーション、いいねボタン、トースト/スナックバーのスライドイン、ドロワー/モーダルのアニメーション、リストの並べ替えや追加/削除、共有要素レイアウトトランジション、UIフィードバックの洗練など、Framer Motion(motion/react)とモダンCSSを使用したUIモーションをカバーします。

マイクロインタラクション(UIモーション) とは?

このスキルは、UIモーションに特化した包括的なガイドです。Framer Motion(motion/react)とモダンCSSを用いて、ホバー効果、プレスフィードバック、トグル、トースト、ドロワー、リストアニメーションといったマイクロインタラクションを実装するための原則と実践的なコード例を提供します。アニメーションの持続時間は100〜250msに抑え、`transform`と`opacity`のみをアニメートすることでパフォーマンスを最適化します。また、`AnimatePresence`による出入りアニメーション、`layout`プロパティによるレイアウトアニメーション、`layoutId`による共有要素トランジションなど、Framer Motionの高度な機能を解説します。さらに、`@starting-style`や`transition-behavior: allow-discrete`を使用したピュアCSSでのアニメーション手法、`prefers-reduced-motion`を尊重したアクセシビリティ対応、デモ用のスタンドアロンHTMLファイルの生成と検証方法まで網羅しています。開発者やAIエージェントが、レスポンシブで生き生きとしたUIフィードバックを効率的に実装するための実用的なリファレンスです。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/nehakanjamala/personal_website/tree/HEAD/.agents/skills/micro-interaction

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

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

ドキュメント

マイクロインタラクション(UIモーション) は何をしますか?

インターフェースをレスポンシブで生き生きと感じさせる、小さく機能的なモーション:ホバー/プレス/フォーカスフィードバック、トグル、トースト、ドロワー、リスト/レイアウトアニメーション。目標はフィードバックと継続性であり、装飾ではありません。

使用する場面

  • ホバー/プレス/フォーカスフィードバック、トグル、チェックボックス、いいね/ハートボタン
  • トースト/スナックバー、ドロワー、モーダル、ツールチップ、アコーディオン(入場/退場)
  • リストの追加/削除/並べ替え、共有要素(「マジックムーブ」)レイアウトトランジション
  • ローディング → 成功 → エラーの状態遷移

原則(すべてに適用)

  • 持続時間: UIマイクロインタラクションは 100~250ms で行います。クリック応答で約400msを超えると、遅く感じられます。
  • transform と opacity のみをアニメーションする — これらはGPUコンポジットされます(レイアウト/ペイントが発生しない)。width/height/top/left のアニメーションは避け、代わりに scale またはレイアウトアニメーションを使用します。
  • プレスフィードバックは 即座に 与える: タップ時に scale: 0.96、高速なスプリングを使用。
  • 非対称なタイミング: 入場はやや遅め(イーズアウト)、退場は速め(イーズイン)。要素は優雅に到着し、すぐに退場します。
  • prefers-reduced-motion を尊重する: 必須でないモーションは制限し、不透明度の変更は残し、大きな動きは削除します。
  • イージングのデフォルト: 入場はイーズアウト cubic-bezier(0.16, 1, 0.3, 1)、上品なオーバーシュートは cubic-bezier(0.34, 1.56, 0.64, 1)、標準的な移動は cubic-bezier(0.4, 0, 0.2, 1)。

Framer Motion (motion/react) の基本

v11以降、パッケージは motion/react としてインポートされます(framer-motion という名前も引き続き使用可能)。

ジェスチャーとスプリング

import { motion } from "motion/react";

<motion.button
  whileHover={{ scale: 1.03 }}
  whileTap={{ scale: 0.96 }}
  whileFocus={{ boxShadow: "0 0 0 3px rgba(59,130,246,.5)" }}
  transition={{ type: "spring", stiffness: 400, damping: 30 }}
/>

スプリングの直感: stiffness が高いほど速く、damping が高いほどバウンドが少なくなります。stiffness: 400, damping: 30 はスナップの効いたUIのデフォルト値です。目に見えるバウンドが必要な場合は、ダンピングを低くします(例: damping: 12)。

AnimatePresence による入退場

退場アニメーションには、条件付きでレンダリングされる子要素をラップする AnimatePresence が必要で、それぞれに安定した key が必要です。

import { AnimatePresence, motion } from "motion/react";

<AnimatePresence>
  {open && (
    <motion.div
      key="panel"
      initial={{ opacity: 0, y: 8 }}
      animate={{ opacity: 1, y: 0 }}
      exit={{ opacity: 0, y: 8 }}
      transition={{ duration: 0.2, ease: [0.16, 1, 0.3, 1] }}
    />
  )}
</AnimatePresence>

トーストやリストの場合は、mode="popLayout" を使用すると、削除されたアイテムが退場中にスペースを占有しなくなります。

レイアウトアニメーション(スーパーパワー)

layout は、あらゆるレイアウト変更(位置/サイズ)を自動的にアニメーション化します(トランスフォームを使用)。並べ替え、カードの展開、グリッド↔リストの切り替えに最適です。

<motion.li layout transition={{ type: "spring", stiffness: 500, damping: 40 }} />

コンポーネント間の共有要素トランジション: 2つの要素に同じ layoutId を与えると、Framer Motionは一方がマウントされ、他方がアンマウントされる間にそれらの間をアニメーションします。

{!open && <motion.div layoutId="card" onClick={() => setOpen(true)} />}
<AnimatePresence>
  {open && <motion.div layoutId="card" />} {/* ソースから「マジックムーブ」 */}
</AnimatePresence>

注意点: 単純な layout 要素は、スケール中に border-radius やテキストを歪めます。カウンタースケールする必要がある直接の子要素に layout を追加し、borderRadius/boxShadow をモーション値として使用するか、位置のみをアニメーションする layout="position" を使用することを推奨します。

ピュアCSSパス(JS不要、離散プロパティを含む)

モダンCSSは、ライブラリなしで入退場や display のトグルをアニメーション化できます。

.toast {
  transition: opacity 0.2s ease, transform 0.2s ease;
  /* display:none との間や初期レンダリングからのアニメーションを許可 */
  transition-behavior: allow-discrete;
}
.toast[hidden] { display: none; }

/* 最初のレンダリング時 / 入場時にこれらの値からアニメーション */
@starting-style {
  .toast { opacity: 0; transform: translateY(8px); }
}

@starting-style は「開く前」の値を定義し、要素が最初に表示されるときにアニメーションで入場できるようにします。transition-behavior: allow-discrete は display(およびポップオーバー/ダイアログの overlay)が退場アニメーションに参加できるようにし、要素が削除される前にアニメーションが実行されます。Chrome/Edge/Safariでベースライン対応。古いブラウザ向けにアニメーションなしのフォールバックを提供します。

常に縮小モーションガードを含めます:

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

状態、単なる装飾ではない

ローディング → 成功 → エラーは、一連の連続したモーションであるべきです(例: ボタンがスピナーからチェックマークに変化する)。ジャンプカットではなく、要素をマウントしたまま状態間をアニメーションさせ、視線が同じオブジェクトを追跡できるようにします。

納品と検証(スタンドアロンHTML)

パッケージ化されたヘルパー (scripts/): scripts/seek-shot.sh anim.html 0 1.5 3 で ?t=N ハーネスをフリーズし、各瞬間をスクリーンショット; scripts/contact-sheet.sh sheet.png frame-*.png でそれらをタイル状に並べ、一目でレビューできます。scripts/README.md を参照。

自己完結型のインタラクションデモ(トグル、いいねボタン、トースト、ドロワー)の場合、成果物は ブラウザで直接開ける1つのHTMLファイル です。ピュアCSSのインタラクションはそのまま提供します。Framer Motionデモの場合は、React + motion をCDN(esm.sh)から読み込み、1つのインラインモジュールにまとめます。ビルドステップは不要です。1ファイルが適切なレベルです。バンドラーに頼らないでください。

出力契約:

  • 1つの .html ファイル: マークアップと、CSSトランジション/@starting-style または CDNから motion をインポートするインライン <script type="module"> を含む。
  • スクリーンショット用の 解決済み最終状態 に到達する方法 — インタラクションは時間駆動ではなく状態駆動であるため、時計ではなく状態をフリーズします。

シークハーネス — 決定論的な状態を固定する。 マイクロインタラクションの「フレーム」はその状態(アイドル/ホバー/プレス/オープン)です。?state=open はロード時に対象の状態を適用し、スクリーンショットが安定した状態をキャプチャできるようにします:

<script>
  const s = new URLSearchParams(location.search).get("state");
  if (s) document.documentElement.dataset.state = s;   // CSSは [data-state="open"] をキーにする
  // Framer Motion: s から制御プロパティを設定(例: const [open]=useState(s==="open"))
  // CSS @keyframes ループの場合は、フリーズ: el.style.animationDelay=(-N)+"s"; el.style.animationPlayState="paused";
  window.__ready = true;
</script>

検証ループ — レンダリング → 状態設定 → スクリーンショット → チェック: 意味のある各状態(?state=idle、?state=hover、?state=open)を開き、スクリーンショットを撮り、忠実度(プレスフィードバックが即座に読めるか、退場がアンマウント前に実行されるか)とアーティファクト(layout による border-radius/テキストの歪み、退場後にトーストがスペースを保持する、FOUC、ジャンク)をチェックします。任意のヘッドレスツールで動作します:

npx playwright screenshot --wait-for-timeout=400 "file://$PWD/demo.html?state=open" open.png

完了前のチェックリスト:

  1. スタンドアロンで開く — コンソールエラーなし、CDN React/motion(使用している場合)が解決される。
  2. ?state=(または制御プロパティ)のフリーズで、決定論的な安定状態が得られる。
  3. 複数の状態(アイドル/アクティブ/オープン)でスクリーンショットを撮り、概要と一致し、アーティファクトがない。
  4. prefers-reduced-motion が尊重されている — 大きな動きは削除され、不透明度/フィードバックは維持される。
  5. イージングが意図的である — 入場はイーズアウト、退場はイーズイン、持続時間は100~250msの範囲。

クイックリファレンス

ニーズアプローチ
プレスフィードバックwhileTap={{ scale: 0.96 }} スプリング 400/30
入退場AnimatePresence + initial/animate/exit
並べ替え / リサイズlayout プロパティ(スプリング)
マジックムーブ共有 layoutId
トーストスタックAnimatePresence mode="popLayout"
JSなし入場@starting-style + トランジション
display:noneへのアニメーションtransition-behavior: allow-discrete
アクセシビリティ常に prefers-reduced-motion ガード

参考ファイル

  • references/framer-motion-recipes.md — バリアントとスタガー、AnimatePresence モード、layout/layoutId マジックムーブ、Reorder ドラッグ並べ替え、ドラッグ制約、ジェスチャー構成、および useReducedMotion。
  • references/css-recipes.md — @starting-style、transition-behavior: allow-discrete、ポップオーバー/ダイアログの退場アニメーション、キーフレームスピナー/トグル、@property によるアニメーション可能なカスタムプロパティ、および prefers-reduced-motion パターン。

Individual skills in this repo

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

nehakanjamala/personal_website

This skill should be used when the user asks to "fix janky CSS animation", "make animation 60fps", "stop layout thrashing", "animate width/height/top/left smoothly", "convert animation to transform", "animate box-shadow performantly", "animate height auto", "FLIP animation", or "why is my scroll/hover animation choppy".

nehakanjamala/personal_website

This skill should be used when the user asks to "respect prefers-reduced-motion", "honor reduced motion", "make my animations accessible", "fix vestibular / motion-sickness issues", "add a useReducedMotion hook", "gate GSAP / Framer Motion / Lenis for reduced motion", or "meet WCAG 2.3.3 / C39". Provides tiered (not all-or-nothing) reduced-motion patterns in CSS and JS.

nehakanjamala/personal_website

Create, modify, debug, and deploy Apify Actors, and write their input and output schemas. Use when building an Actor from scratch, changing or troubleshooting Actor code, generating or updating .actor schema files, or pushing an Actor to the Apify platform. To wrap an existing non-Actor project, use apify-actorization instead.

nehakanjamala/personal_website

Convert existing projects into Apify Actors - serverless cloud programs. Actorize JavaScript/TypeScript (SDK with Actor.init/exit), Python (async context manager), or any language (CLI wrapper). Use when migrating code to Apify, wrapping CLI tools as Actors, or adding Actor SDK to existing projects.

nehakanjamala/personal_website

Deprecated. Output schema generation moved to the apify-actor-development skill; prefer that skill whenever it is available.

nehakanjamala/personal_website

Design and build an official Apify integration for a company's product - workflow-automation apps (Zapier/n8n-style), AI agent plugins (coding-agent skills+MCP bundles or OpenClaw/Hermes-style harnesses), AI framework packages (LangChain/LlamaIndex-style), or direct application clients via apify-client. Use when planning, creating, or reviewing an integration that exposes Apify Actors, runs, datasets, or key-value stores inside another product.

nehakanjamala/personal_website

Universal AI-powered web scraper for any platform. Scrape data from Instagram, Facebook, TikTok, YouTube, LinkedIn, X/Twitter, Google Maps, Google Search, Google Trends, Reddit, Airbnb, Yelp, and 15+ more platforms. Use for lead generation, brand monitoring, competitor analysis, influencer discovery, trend research, content analytics, audience analysis, review analysis, SEO intelligence, recruitment, or any data extraction task.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a glassmorphism effect", "frosted glass UI", "Apple liquid glass style", "frosted blur card", "translucent glass panel animation", "make a frosted nav bar", "build a glass modal/dialog", "animate a glass card on hover", or "add a refracting liquid-glass hero". Covers frosted translucent panels with backdrop-filter blur, edge/specular highlights, SVG liquid-glass refraction, motion on hover/scroll/enter, and accessible reduced-transparency fallbacks.

nehakanjamala/personal_website

This skill should be used when the user asks to "build a scroll animation", "add ScrollTrigger", "pin a section while scrolling", "scrub an animation to scroll", "create a hero timeline", "do a horizontal scroll section", "split text and animate words", "animate a layout change with GSAP Flip", "sync ScrollTrigger with Lenis", "Lenis smooth scroll jittery", "ScrollTrigger markers drift", "ScrollTrigger pins break with Lenis/Locomotive", or "set up smooth scroll with GSAP pinning". Covers GSAP timelines, ScrollTrigger, SplitText, Flip, and Lenis/Locomotive smooth-scroll sync for code-driven web motion.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a Lottie animation", "play a .lottie or .json animation", "integrate a Bodymovin/After Effects animation on web or mobile", "control Lottie playback / segments", "make a scroll-driven Lottie", "recolor a Lottie at runtime", or "export an AE animation to Lottie". Covers dotLottie/lottie-web integration, playback control, interactivity, theming, and the AE export checklist.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate page or route transitions", "add a page transition or crossfade between views", "animate route changes in Next.js App Router", "use the View Transitions API", "AnimatePresence exit doesn't fire on navigation", or "Framer Motion exit animation not working / exit animation before unmount in Next.js". Covers enter/exit page-transition animation with the View Transitions API and Framer Motion, for Next.js App Router and general SPA routing.

nehakanjamala/personal_website

Scrape web pages using Scrapling with anti-bot bypass (like Cloudflare Turnstile), stealth headless browsing, spiders framework, adaptive scraping, and JavaScript rendering. Use when asked to scrape, crawl, or extract data from websites; web_fetch fails; the site has anti-bot protections; write Python code to scrape/crawl; or write spiders.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate an SVG", "make a line draw itself on", "do a stroke draw-on / signature animation", "morph one shape into another", "move an element along a path", "animate an icon/logo", or "animate an SVG gradient or filter". Covers stroke-dashoffset draw-on, path morphing, motion-along-path, and animated icons/gradients/filters via CSS, SMIL, and GSAP.

関連スキル