Reflex custom component motion
Project description
Reflex Motion
A Reflex wrapper for Framer Motion, a production-ready motion library for React.
Installation
pip install reflex-motion
Usage
Right now Reflex Motion is a simple wrapper around Framer Motion. It provides a single component, motion
, which is a drop-in replacement for motion.div
from Framer Motion.
motion(
rx.button(
"Bounce me!",
),
while_hover={"scale": 1.2},
while_tap={"scale": 0.9},
transition={"type": "spring", "stiffness": 400, "damping": 17},
)
There are a few different props motion supports:
Props
inital: The initial state of the animation. This is the state the animation will start in when the component is first rendered.
animate: The state the animation will end in. This is the state the animation will end in when the component is first rendered.
while_hover: The state the animation will be in while the user is hovering over the component.
while_tap: The state the animation will be in while the user is tapping on the component.
while_in_view: The state the animation will be in while the component is in view.
while_focus: The state the animation will be in while the component is focused.
Animation Props
Name | Key | Values | Description |
---|---|---|---|
Translate | 'x', 'y', 'z' | int | The amount to translate the component by. |
Scale | 'scale', 'scale_x', 'scale_y' | int | The amount to scale the component by. |
Rotate | 'rotate', 'rotate_x', 'rotate_y', 'rotate_z' | int | The amount to rotate the component by. |
Skew | 'skew', 'skew_x', 'skew_y' | int | The amount to skew the component by. |
Additionally you can pass in any Reflex style prop (css prop).
Transitions
transition: The transition to use when animating between states. This can be a single transition or an array of transitions.
Name | Key | Values | Description |
---|---|---|---|
Type | 'tpye' | tween', 'spring', 'keyframes' | The type of transition to use. |
Easing | 'ease' | 'linear', 'ease_in', 'ease_out', 'ease_in_out', 'circ_in', 'circ_out', 'circ_in_out', 'back_in', 'back_out', 'back_in_out' | The easing function to use for the transition. |
Duration | 'duration' | int | The duration of the transition in milliseconds. |
Delay | 'delay' | int | The delay before the transition starts in milliseconds. |
Additonally you can pass in any of the Animation Props and Reflex style prop (css prop).
Examples
Transition
motion(
rx.button(
"Spin me!",
variant="soft",
),
initial={"scale": 1},
while_hover={"scale": 1.2, "rotate": 45},
while_tap={"scale": 0.9},
transition={"type": "spring", "stiffness": 260, "damping": 20},
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file reflex-motion-0.0.1.tar.gz
.
File metadata
- Download URL: reflex-motion-0.0.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d404d270ae725fce8c8a2dd7c1dba4bbc4e821ac5858b25419cc27e56449e38 |
|
MD5 | 93845e7a2e123a83558596e29d27d1ff |
|
BLAKE2b-256 | 8a8c85f74b9e5729448c7fc81f958f2a53d0757d31b80fcc88b13efb3c30018b |
File details
Details for the file reflex_motion-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: reflex_motion-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c76b47920ab6d979f9e93728108d97c9da41dad3fc239493f53fba17ae43202 |
|
MD5 | f900a6cda8820adb5fee869445bbeb36 |
|
BLAKE2b-256 | 4b9e5c7c2f414fd77c3c3e229a2175223f3c89c8cca05c6ebefd1bd7c2d2ab2e |