-
I am trying out framer motion library with theme-ui. They have some examples that animate React components based on attribute selector. https://codesandbox.io/s/framer-motion-2-scale-correction-z4tgr?from-embed=&file=/src/styles.css This part:
And JS:
I have found out framer motion wouldn't animate I am wondering if there is a way to do attribute selection in Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Selecting on data attributes should just work (TM). sx={{
'[data-my-attribute="hello"]': { color: "blue" }
}} Here's a CodeSandbox for you: https://codesandbox.io/s/gracious-zhukovsky-4ikim?file=/src/App.tsx
Sidenote: I think animating Later, if you need dynamic, frequently changing values in your styles (e.g. animations), you can set a CSS Custom Property inside of a |
Beta Was this translation helpful? Give feedback.
Selecting on data attributes should just work (TM).
Here's a CodeSandbox for you: https://codesandbox.io/s/gracious-zhukovsky-4ikim?file=/src/App.tsx
Sidenote: I think animating
sx
is technically possible to do with some more fiddling, but it's a really bad idea anyway -- each unique style object given tosx
will create a new className and append a style tag to your DOM.Later, if you need dynamic, frequently changing values in your styles (e.g. animations), you can set a…