Skip to content

framer motion exit animations not working. #1058

Answered by heyitsarpit
heyitsarpit asked this question in Help
Discussion options

You must be logged in to vote

I found the solution -
You need to put forceMount prop on the Portal and wrap it in AnimatePresence. Content and overlay will also require forceMount.

export function HamburgerSideBar() {
  const [open, setOpen] = useState(false)

  return (
    <Dialog.Root onOpenChange={(o) => setOpen(o)}>
      <Dialog.Trigger className='relative z-[51]'>
        <HamburgerButton open={open} />
      </Dialog.Trigger>
      <AnimatePresence>
        {open ? (
          <Dialog.Portal forceMount>
            <Dialog.Overlay asChild forceMount>
              <motion.div
                className='fixed inset-0 z-50 cursor-pointer bg-black/50 backdrop-blur-[10px]'
                initial={{ opacity: 0 }}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jjenzz
Comment options

@heyitsarpit
Comment options

Answer selected by heyitsarpit
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