I forgot to mention that by adding the "layout" prop from Framer Motion, automatic animation of layout and size is enabled when the layout changes.
๐
Just wrap your component with <AnimatePresence> from Framer Motion, and even though it is a small detail, it will be smooth enough to go ๐ง