Swing
Send buttons. Pulls back a little, follows through.
See you at training
- Sport
- Golf
- Move
- Pulls back a little, follows through.
- For
- Send buttons
backswing 170ms · follow-through 760ms · reduced: press
01 Install
npx shadcn@latest add https://moveui-red.vercel.app/r/swing.jsonIt brings the tokens with it. The first time, import the tokens once in your root layout:
import "@/components/moveui/tokens.css";Not using shadcn? Copy the files below into components/moveui/, and tokens.css next to them.
02 Use it
import "@/components/moveui/swing/swing.css";
<button
className="ml-swing"
onClick={(e) => { e.currentTarget.setAttribute("data-swing", ""); send(); }}
onAnimationEnd={(e) => { if (e.target === e.currentTarget) e.currentTarget.removeAttribute("data-swing"); }}
>
Send <span className="ml-swing__icon" aria-hidden="true">➤</span>
</button>03 Or ask your agent
Paste this into Claude Code, Cursor or any coding agent. It installs the piece and wires it in.
Add the Move UI "Swing" piece to this project. It's for: Send buttons.
1. Install it: npx shadcn@latest add https://moveui-red.vercel.app/r/swing.json
2. If the project doesn't import the Move UI tokens yet, add this once to the root layout: import "@/components/moveui/tokens.css";
3. Use it like this, adapted to where it belongs in my code:
import "@/components/moveui/swing/swing.css";
<button
className="ml-swing"
onClick={(e) => { e.currentTarget.setAttribute("data-swing", ""); send(); }}
onAnimationEnd={(e) => { if (e.target === e.currentTarget) e.currentTarget.removeAttribute("data-swing"); }}
>
Send <span className="ml-swing__icon" aria-hidden="true">➤</span>
</button>
Keep its reduced-motion behaviour and keyboard support. Don't hardcode durations, easing or colours: they come from the --ml-* tokens.
Docs: https://moveui-red.vercel.app/pieces/swingWant your agent to know the whole library and its motion rules? Add the Move UI skill to your project:
npx shadcn@latest add https://moveui-red.vercel.app/r/skill.json04 Code
/*
Swing (golf): pulls back a little, then follows through. For send buttons.
Put .ml-swing on the button and .ml-swing__icon on its icon. Set [data-swing] on click:
the button takes a small backswing and comes through; the icon winds back, then is struck up and
out on an arc and comes back in once it has gone (--ml-dur-flight). Remove [data-swing] on
animationend. The button must not clip its overflow. Reduced motion: a quick press, no flight.
*/
.ml-swing { transform-origin: 50% 100%; }
.ml-swing__icon { display: inline-block; }
.ml-swing[data-swing] { animation: ml-swing-body var(--ml-dur-flight) both; }
.ml-swing[data-swing] .ml-swing__icon { animation: ml-swing-icon var(--ml-dur-flight) both; }
@keyframes ml-swing-body {
0% { transform: none; animation-timing-function: var(--ml-ease-out); }
/* the backswing */
22% { transform: translateX(-3px) rotate(-1.5deg); animation-timing-function: cubic-bezier(0.7, 0, 0.3, 1); }
/* through the ball */
36% { transform: translateX(2px) rotate(0.8deg); animation-timing-function: var(--ml-ease-out); }
60%, 100% { transform: none; }
}
@keyframes ml-swing-icon {
0% { transform: none; animation-timing-function: var(--ml-ease-out); }
22% { transform: translate(-4px, 1px) rotate(-28deg); animation-timing-function: cubic-bezier(0.7, 0, 0.3, 1); }
34% { transform: none; animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1); }
/* the flight: up and away on an arc */
62% { opacity: 0; transform: translate(42px, -30px) rotate(24deg) scale(0.8); }
/* back in the bag: in from below */
63% { opacity: 0; transform: translateY(10px); animation-timing-function: var(--ml-ease-settle); }
100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
@keyframes ml-swing-body { 50% { transform: scale(0.97); } }
@keyframes ml-swing-icon { 50% { opacity: 0.4; } }
}
