Skip to content

Dropdown menu exit animation doesn't work with Framer Motion #1115

Answered by jjenzz
AnishDe12020 asked this question in Help
Discussion options

You must be logged in to vote

Looking at the framer-motion docs it seems you have put the isOpen check too high up. I believe it should be as follows:

const Component = (): JSX.Element => {
  const [isOpen, setOpen] = useState<boolean>(false);

  return (
    <DropdownMenu.Root open={isOpen} onOpenChange={setOpen}>
      <DropdownMenu.Trigger className="relative z-10 px-4 py-2 text-white rounded-lg bg-gradient-to-bl from-pink-700 to-blue-700 before:absolute before:inset-0 before:bg-gradient-to-tr before:from-pink before:opacity-0 before:-z-10 before:transition before:duration-500 before:hover:opacity-100 before:rounded-lg">
        Export
      </DropdownMenu.Trigger>
-     {isOpen && (
      <AnimatePresence>
+

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AnishDe12020
Comment options

Answer selected by AnishDe12020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants