framer-motion-gestures — Claude Code skill: Framer Motion gestures
A skill covering Framer Motion gesture animations: drag, pan, tap, hover and focus. Useful when you build interactive elements and need the prop details at hand.
npx skills add C-Jeril/framer-motion-skills --skill framer-motion-gestures -a claude-codeWhat framer-motion-gestures does
The skill walks through enabling gestures in Framer Motion. Dragging comes from the drag prop set to "x", "y" or true, and movement bounds go through dragConstraints as an object with left, right, top, bottom or as a ref to a container. Bounce at the edges is handled by dragElastic, momentum after release by dragMomentum and dragTransition with a spring config.
Beyond drag, it covers whileTap, whileHover and whileFocus, plus the onDrag, onDragStart, onDragEnd, onHoverStart and onHoverEnd callbacks. Those callbacks receive point, velocity and offset from the start. Pan is described as lower-level pointer tracking without momentum, which separates it from drag with its visual feedback and constraints.
A Do Not section lists the usual breakage: drag without dragConstraints when the element should stay in bounds, excessive dragElastic, and animating conflicting properties such as scale and x at the same time. Drag events only fire after the pointer crosses a movement threshold, so a silent handler on small movements is worth checking. The skill ships inside the framer-motion-skills set, alongside skills for core animation, variants and layout animations.
What it helps with
- enable dragging on a single axis
- keep a draggable element inside its container
- add bounce-back when the element passes the bounds
- tune a spring for momentum after release
- attach animation to tap, hover or focus
Example prompts for the agent
- Make a card draggable on the x axis with constraints from the container
- Add whileTap and whileHover scaling to this button
- Set up dragTransition with a spring for the draggable block
How to install framer-motion-gestures
1Skills CLI (Vercel)
npx skills add C-Jeril/framer-motion-skills --skill framer-motion-gestures -a claude-code2Manually: put the files in place
~/.claude/skills/framer-motion-gestures/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/framer-motion-gestures/
1Skills CLI (Vercel)
npx skills add C-Jeril/framer-motion-skills --skill framer-motion-gestures -a codex2Manually: put the files in place
.agents/skills/framer-motion-gestures/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add C-Jeril/framer-motion-skills --skill framer-motion-gestures -a cursor2Manually: put the files in place
.cursor/skills/framer-motion-gestures/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install C-Jeril/framer-motion-skills framer-motion-gestures2Manually: put the files in place
.github/skills/framer-motion-gestures/SKILL.md1Skills CLI (Vercel)
npx skills add C-Jeril/framer-motion-skills --skill framer-motion-gestures -a gemini-cli2Platform CLI
gemini skills install https://github.com/C-Jeril/framer-motion-skills --path skills/framer-motion-gesturesManually: put the files in place
.devin/skills/framer-motion-gestures/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add C-Jeril/framer-motion-skills --skill framer-motion-gestures -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about framer-motion-gestures
How do I install framer-motion-gestures in Claude?
Run npx skills add C-Jeril/framer-motion-skills --skill framer-motion-gestures -a claude-code. The skill lands in ~/.claude/skills/framer-motion-gestures/SKILL.md.
What does framer-motion-gestures do?
It gives the agent a reference for Framer Motion gestures: the drag props, constraints and momentum, plus whileTap, whileHover and whileFocus with their callbacks.
How is pan different from drag here?
Drag is dragging with visual feedback, momentum and constraints. Pan is described as lower-level pointer tracking without momentum.
Source text
SKILL.md · MIT
---
name: framer-motion-gestures
description: Official Framer Motion skill for gesture animations — drag, pan, tap, hover, focus, touch animations. Use when building interactive elements with drag, pan, tap, hover, or touch gestures, or when asking about Framer Motion drag constraints, gesture handlers, or interactive animations.
license: MIT
---
# Framer Motion Gestures
## When to Use This Skill
Apply when implementing gesture-driven animations: drag, pan, tap, hover, focus, or touch interactions. When the user asks about drag-and-drop, interactive elements, or gesture-based UI in Framer Motion.
**Related skills:** For core animation use **framer-motion-core**; for variants use **framer-motion-variants**; for layout animations use **framer-motion-layout**.
## Drag
Enable dragging with the `drag` prop:
```jsx
<motion.div
drag="x"
dragConstraints={{ left: -100, right: 100 }}
whileDrag={{ scale: 1.1, cursor: "grabbing" }}
/>
```
### Drag Props
| Prop | Type | Description |
|------|------|-------------|
| **drag** | `bool \| "x" \| "y"` | Enable drag on axis |
| **dragConstraints** | `object \| RefObject` | Movement constraints |
| **dragMomentum** | `boolean` | Continue momentum after release (default: true) |
| **dragElastic** | `number \| object` | Elasticity of bounds (default: 0) |
| **dragTransition** | `Transition` | Spring config for momentum |
| **whileDrag** | `MotionProps` | Animation while dragging |
| **onDrag** | `function` | Callback during drag |
| **onDragStart** | `function` | Callback when drag starts |
| **onDragEnd** | `function` | Callback when drag ends |
### Drag Constraints
```jsx
<motion.div
drag
dragConstraints={{
left: -100,
right: 100,
top: -50,
bottom: 50
}}
/>
```
### Ref-based Constraints
```jsx
function Draggable() {
const constraintsRef = useRef(null);
return (
<>
<motion.div
ref={constraintsRef}
style={{
width: 500,
height: 500,
backgroundColor: "#eee"
}}
/>
<motion.div
drag
dragConstraints={constraintsRef}
/>
</>
);
}
```
## Pan
Pan is similar to drag but for pointer/touch:
```jsx
<motion.div
drag="x"
onDrag={(e, info) => {
console.log("Position:", info.point);
console.log("Velocity:", info.velocity);
}}
/>
```
### Pan vs Drag
- **Drag**: Mouse/touch with visual feedback, momentum, and constraints
- **Pan**: Lower-level pointer tracking without momentum
## Tap (whileTap)
Animation when pressed:
```jsx
<motion.button
whileTap={{ scale: 0.95, opacity: 0.8 }}
whileHover={{ scale: 1.05 }}
>
Click me
</motion.button>
```
## Hover (whileHover)
Animation on hover:
```jsx
<motion.div
whileHover={{ scale: 1.1, backgroundColor: "#ff0000" }}
style={{ width: 100, height: 100, backgroundColor: "#00ff00" }}
/>
```
### onHoverStart / onHoverEnd
```jsx
<motion.div
onHoverStart={() => console.log("Hover started")}
onHoverEnd={() => console.log("Hover ended")}
/>
```
## Focus (whileFocus)
Animation when focused (keyboard):
```jsx
<motion.input
whileFocus={{ scale: 1.05, borderColor: "#00ff00" }}
style={{ borderWidth: 2 }}
/>
```
## Drag with Spring Physics
```jsx
<motion.div
drag="x"
dragConstraints={{ left: -200, right: 200 }}
dragTransition={{
type: "spring",
stiffness: 300,
damping: 20,
mass: 1
}}
/>
```
## Drag Controls with Constraints
```jsx
function DraggableBox() {
const constraintsRef = useRef(null);
return (
<>
<motion.div
ref={constraintsRef}
style={{
width: 500,
height: 500,
backgroundColor: "#f0f0f0"
}}
/>
{[1, 2, 3].map(i => (
<motion.div
key={i}
drag
dragConstraints={constraintsRef}
dragMomentum={false}
whileDrag={{ scale: 1.1 }}
/>
))}
</>
);
}
```
## Swipe Detection
```jsx
function Swipeable() {
const x = useMotionValue(0);
const { scrollYProgress } = useScroll();
const opacity = useTransform(x, [-100, 0, 100], [0, 1, 0]);
return (
<motion.div
style={{ x, opacity }}
drag="x"
dragConstraints={{ left: 0, right: 0 }}
dragElastic={1}
/>
);
}
```
## Gesture State Info
Callbacks receive `PointInfo` and `DragInfo`:
```jsx
onDrag={(e, info) => {
info.point // { x, y } position
info.velocity // { x, y } velocity
info.offset // { x, y } offset from start
}}
```
## Best practices
- ✅ Use **dragConstraints** to keep elements within bounds.
- ✅ Use **dragElastic** for bounce-back effects.
- ✅ Use **whileDrag** for visual feedback during drag.
- ✅ Use **dragMomentum** for natural continuation.
- ✅ Use **dragTransition** with spring for physics-based drag.
- ✅ Use refs for constraints when dragging within a container.
## Do Not
- ❌ Use `drag` without `dragConstraints` if the element should stay within bounds.
- ❌ Forget that drag events only fire after the pointer moves a threshold.
- ❌ Use excessive `dragElastic` — it can cause visual glitches.
- ❌ Animate conflicting properties during drag (e.g., scale and x).
### Learn More
https://www.framer.com/motion/gestures/
https://www.framer.com/motion/drag/
© C-Jeril · MIT · C-Jeril/framer-motion-skills