transitions-dev
此技能提供生产就绪的 CSS 过渡效果,适用于网页应用中的通知徽章、下拉菜单、模态框和页面切换等多种 UI 元素。它提供可移植的代码片段,帮助开发者轻松集成流畅且引人入胜的动画,无需框架依赖,显著提升用户体验。
npx skills add https://github.com/jakubantalik/transitions.dev --skill transitions-devBefore / After 效果对比
1 组开发者在没有此技能之前,需要手动为每个 UI 元素编写复杂的 CSS 过渡效果,这不仅耗时,还容易出现兼容性问题和性能瓶颈,并且难以兼顾无障碍访问(如 prefers-reduced-motion),导致开发效率低下且用户体验不佳。
该 Skill 提供生产就绪且经过优化的 CSS 过渡片段,开发者可以即插即用,轻松实现各种流畅的 UI 动画。这大大减少了手动编写和调试动画的时间,确保了动画的质量、性能和无障碍性,显著提升了开发效率和用户满意度。
Transitions.dev
Eighteen portable CSS transitions, each namespaced under t-* selectors with semantic CSS custom properties. Drop-in: paste the snippet, wire the documented HTML hooks, done. No framework dependencies, no demo-specific markup, and every snippet ships a prefers-reduced-motion guard.
Quick reference
| Transition | When to use | Reference |
|---|---|---|
| Card resize | Tween a container's width or height when its layout state changes. | 01-card-resize.md |
| Number pop-in | Re-enter each digit with a blurred slide when a number updates. | 02-number-pop-in.md |
| Notification badge | Slide a small badge onto a trigger and pop the dot. | 03-notification-badge.md |
| Text states swap | Swap text in place with a blurred up-and-down transition. | 04-text-states-swap.md |
| Menu dropdown | Open an origin-aware dropdown that grows from its trigger. | 05-menu-dropdown.md |
| Modal open / close | Scale-up modal dialog with a softer scale-down on close. | 06-modal.md |
| Panel reveal | Slide a panel into a region with a cross-blur. | 07-panel-reveal.md |
| Page side-by-side | Slide between two side-by-side pages (list ↔ detail, step 1 ↔ step 2). | 08-page-side-by-side.md |
| Icon swap | Cross-fade two icons in the same slot with blur and scale. | 09-icon-swap.md |
| Success check | Compose fade + rotate + Y-bob + path stroke-draw to celebrate a completed action. | 10-success-check.md |
| Avatar group hover | Distance-falloff lift on a row of items with a bouncy spring on return. | 11-avatar-group-hover.md |
| Error state shake | Per-segment cubic-bezier shake with auto-reverting border + message. | 12-error-state-shake.md |
| Input clear with dissolve | Fly-out + per-word streak when a text field is cleared. | 13-input-clear-dissolve.md |
| Skeleton loader and reveal | Pulse a placeholder, then cross-fade + cross-blur to the loaded content. | 14-skeleton-reveal.md |
| Shimmer text | Sweep a highlight band across muted text on a loop (pure CSS). | 15-shimmer-text.md |
| Tabs sliding | Slide the active pill between tabs in a segmented control. | 16-tabs-sliding.md |
| Tooltip open/close | Delayed fade+scale in, instant out (pure CSS). | 17-tooltip.md |
| Texts reveal | Staggered blurred rise for stacked text lines, quiet fade out. | 18-texts-reveal.md |
Decision rules
When the user asks for a transition, match against the visible UI element first, then the verb:
- Trigger + small dot floating on top → notification badge.
- Trigger + surface that grows from it → dropdown (anchored, origin-aware) or modal (centered, no anchor).
- Surface that slides into a region of the page → panel reveal.
- Two screens, list ↔ detail or step 1 ↔ step 2 → page side-by-side.
- Element changes width or height → card resize.
- Element's text content changes in place → text states swap.
- Two icons in the same slot → icon swap.
- A number updates → number pop-in.
- Confirmation / success / "done" moment (checkmark, payment processed, file uploaded) → success check.
- Hovering an item in a horizontal stack (avatars, chips, segmented buttons, tag pills) → avatar group hover.
- Form validation error / "this is wrong" feedback (invalid field, wrong PIN, duplicate name) → error state shake.
- Clearing a text field (search box × button, filter reset) → input clear with dissolve.
- Placeholder that loads then swaps to real content (list row, card, profile header) → skeleton loader and reveal.
- In-progress / "thinking" text that should feel alive (loading label, streaming status) → shimmer text.
- Small horizontal set of mutually-exclusive options with a moving highlight (view switcher, segmented control, filter tabs) → tabs sliding.
- Hover/focus hint that appears over a trigger (icon tooltip, info bubble) → tooltip open / close.
- Stacked headline + supporting line entering with rhythm (hero copy, empty state, onboarding step) → texts reveal.
- No clear match → fall back to
transitions revealand let the user pick. Don't guess.
If two transitions could fit, prefer the lower-overhead one (card resize over panel reveal, dropdown over modal, success check over a full modal celebration) unless the design clearly calls for the heavier surface. The success check is animation-only — if you also need to swap from a spinner to the check, pair it with icon swap.
Commands
The skill exposes three namespaced verbs the agent should recognise in addition to direct transition requests. Every command starts with transitions so the invocation never collides with verbs from other skills installed in the same project.
transitions reveal — list every transition
Trigger phrases: transitions reveal, "reveal the transitions", "list all transitions", "what transitions are in this skill", "show the transitions catalog".
Behaviour: print the eighteen transitions as a numbered plain-text list — name, one-line summary, and the matching reference filename. Reuse the rows in ## Quick reference above; do not invent new copy. No project access.
transitions review — audit the project for fit
Trigger phrases: transitions review, "review my project", "audit my animations", "where would transitions.dev help", "find places to use this skill".
Behaviour:
- Search the workspace for indicators:
transition:declarations,@keyframes, hardcodedms/sdurations in style files, components matching the decision-rule patterns (modals, dropdowns, badges, search inputs, skeletons, tabs, tooltips, …). - For each hit, match against the decision rules and pick the single best-fit transition.
- Output a numbered list grouped by file:
path/to/Component.tsx:L42— looks like a dropdown opening, suggest menu-dropdown (05-menu-dropdown.md).- Skip ad-hoc transitions that already use a
t-*class.
- Do not edit anything. End with: "Run
transitions applyon any line to install the suggested transition."
transitions apply — install the best-fit transition
Trigger phrases: transitions apply, "apply a transition here", "add the right transition", "install transitions-dev here", "fix the animation on this element".
Behaviour:
- Read context: the currently-open file, the element nearest the cursor, surrounding CSS / JSX. If the user named a transition explicitly (e.g.
transitions apply menu-dropdown), use it. - Run the decision rules from
## Decision ruleson that context and pick one transition. If two could fit, prefer the lower-overhead one (same tie-breaker the existing rules use). - Surface a one-line proposal: "I'd apply menu-dropdown here because the element opens from a trigger and is anchored. Confirm to install?".
- On confirmation, follow the existing five-step procedure in
## Output formatverbatim (root block, snippet, hooks, reduced-motion guard, JS orchestration if needed). - If the agent can't pick a single transition with confidence, fall back to
transitions revealand ask the user to choose.
Universal install
Copy _root.css into your project once and import it (or paste its :root block into your global stylesheet). It defines the semantic tunable variables for all eighteen transitions. Every snippet reads from these names — --resize-*, --badge-*, --dropdown-*, --clear-*, --shimmer-*, --tabs-*, --tt-*, --stagger-*, and the rest.
Each reference file also restates just the variables that snippet needs, so you can install a single transition without pulling the whole block. Don't duplicate the block — if _root.css is already imported, skip re-pasting any per-snippet :root.
The --pX-* source tokens used by the live demo at transitions.dev are intentionally not exported. Tunable values are renamed to semantic names so the user owns the design vocabulary. A few transitions (input clear, shimmer text, tabs, tooltip) carry color tokens that differ by theme — each reference file documents the html[data-theme="dark"] overrides.
Output format
When inserting a transition into the user's project:
- Install the variables from
_root.cssinto the user's global stylesheet, but only if they aren't already there — or just the per-snippet:rootblock from the reference file if installing a single transition. If the universal block is already imported, do not duplicate it. - Paste the chosen transition's CSS verbatim from the relevant reference file. Do not rewrite selectors, do not collapse the transition into shorthand, do not strip
will-change. The snippets are tuned and tested. - Wire the documented HTML hooks — class names (
.t-dropdown,.t-modal,.t-success-check,.t-avatar,.t-clear,.t-skel,.t-shimmer,.t-tabs,.t-tt,.t-stagger, …) and state attributes (data-open,data-state,data-page,aria-selected,.is-open,.is-closing,.is-error,.is-shaking,.has-value,.is-clearing,.is-pulsing,.is-revealed,.is-shown,.is-hiding). - Preserve the
@media (prefers-reduced-motion: reduce)block. Every snippet ships one. Removing it makes the component fail accessibility audits. - For transitions that need JS (dropdown, modal, text swap, number pop-in, page slide, success check, avatar group hover, error state shake, input clear, skeleton reveal, tabs sliding, texts reveal), copy the small orchestration snippet from the reference file and adapt the selectors to the user's DOM. Keep the timing reads (
getComputedStyle(...)getPropertyValue("--…")) so durations stay in sync with the:rootvalues. Shimmer text and tooltip are pure CSS — no JS needed.
Keep the diff small: only edit the files needed to introduce the transition. Don't rename the user's existing variables, don't reformat unrelated CSS, don't pull in a motion library.
Common mistakes to avoid
- Stripping the close-state class cleanup on dropdown/modal — without the
setTimeoutthat removes.is-closing, the next open jumps from the closing scale instead of the resting pre-open scale. - Forgetting the reflow in the text swap, number pop-in, success check replay, and error state shake —
void el.offsetWidth(oroffsetHeight) between class/attribute removal and re-addition is what guarantees the animation replays. - Animating a single container instead of the inner pieces — for the badge, animate the dot, not the trigger; for page slide, animate the page sections, not the container.
- Replacing
transition: …withtransition: all— every snippet enumerates exact properties on purpose so unrelated style changes don't ride in for free. - Hardcoding the success check's
stroke-dasharray— the snippet ships20as a placeholder. Replace it withpath.getTotalLength()rounded up by 1 for your path, otherwise the stroke pre-reveals or over-draws. - Setting
transition-timing-functionin CSS for the avatar group hover — it has to be set inline in JS before the--shift/--scale-activewrites so the bouncy ease-out only applies onmouseleave. - Mixing
.is-errorand.is-shakinginto one class for the error state shake — keeping them orthogonal is what allows the shake to replay (remove → reflow → re-add) without flickering the whole error treatment. - Leaving the input clear glow on
mix-blend-mode: multiplyin dark mode — flip toscreen, bump--glow-opacityto ~0.85, and paint white gradients in JS. - Forgetting to write the tabs pill's first position without a transition — on first paint and resize, set
transform+widthwithtransition: none(then reflow + restore) or the pill animates in fromtranslateX(0)/width: 0.
Reference files
- 01-card-resize.md — Card resize
- 02-number-pop-in.md — Number pop-in
- 03-notification-badge.md — Notification badge
- 04-text-states-swap.md — Text states swap
- 05-menu-dropdown.md — Menu dropdown
- 06-modal.md — Modal open / close
- 07-panel-reveal.md — Panel reveal
- 08-page-side-by-side.md — Page side-by-side
- 09-icon-swap.md — Icon swap
- 10-success-check.md — Success check
- 11-avatar-group-hover.md — Avatar group hover
- 12-error-state-shake.md — Error state shake
- 13-input-clear-dissolve.md — Input clear with dissolve
- 14-skeleton-reveal.md — Skeleton loader and reveal
- 15-shimmer-text.md — Shimmer text
- 16-tabs-sliding.md — Tabs sliding
- 17-tooltip.md — Tooltip open/close
- 18-texts-reveal.md — Texts reveal
- _root.css — the universal install block on its own, ready to import directly.
用户评价 (0)
发表评价
暂无评价
统计数据
用户评分
为此 Skill 评分