Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Allow defining animation duration with CSS variable #2784

Open
benface opened this issue Sep 3, 2024 · 0 comments
Open

[FEATURE] Allow defining animation duration with CSS variable #2784

benface opened this issue Sep 3, 2024 · 0 comments
Labels
feature New feature or request

Comments

@benface
Copy link

benface commented Sep 3, 2024

Is your feature request related to a problem? Please describe.
When the duration of an animation should be dynamic and depend on the viewport size or any other media query or CSS condition (container query, presence of a class or attribue on an ancestor, etc.), it would be super mega useful if we could tell Motion to use the value of a CSS variable / custom property as the duration.

Describe the solution you'd like
With Tailwind classes, for example:

<motion.div
  transition={{ duration: 'var(--duration)' }}
  className="[--duration:2s] sm:[--duration:1s]"
/>

Describe alternatives you've considered
Of course, it's always possible to get the current viewport size in JS, or read any CSS condition in user-land. But this seems like the kind of convenience feature that I would expect from Motion, in particular since custom properties are supported in animate.

Additional context
Nothing I can think of. Thank you 🫶

@benface benface added the feature New feature or request label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant