Skip to content
Discussion options

You must be logged in to vote

styled-components v6 works with Framer Motion. As noted in the thread, use .withConfig to ensure motion props are forwarded:

const AnimatedItem = styled(motion.li).withConfig({
  shouldForwardProp: () => true,
})`
  margin: 0;
`;

Alternatively, with Framer Motion v11+, use motion.create():

const MotionDiv = motion.create(MyStyledComponent);

The key is ensuring that Framer Motion animation props (animate, initial, exit, etc.) are not filtered out by styled-components default prop filtering.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by quantizor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants