question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transition not working in NextJs

See original GitHub issue

It appears like Transition classes are not there initially on any div(<Transition>) Btw I’m using ( tailwindcss(^1.8.4) , styled-components & twin-macro)

Sample code I’m trying to test on my NextJs WebApp image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:28

github_iconTop GitHub Comments

8reactions
jeroenvcommented, Feb 16, 2021

Here’s a working example for styled components and twin.macro: https://codesandbox.io/s/next-styled-components-tailwind-twin-starter-headless-ui-transition-forked-vow27?file=/pages/index.js

Isn’t perfect but works…

7reactions
idrisakmalcommented, Oct 9, 2020

Hi, not sure if its the same issue. I just faced this a minute ago, and the solution was to hoist the classes in the inner div to the <Transition>

initial:

<Transition
   show={showMenu}
   enter="transition duration-75 ease-in-out"
   enterFrom="transform translate-x-full"
   enterTo="transform translate-x-0"
   leave="transition duration-75 ease-in-out"
   leaveFrom="transform translate-x-0"
   leaveTo="transform translate-x-full"
      >
        <div className="bg-primary absolute right-0 h-screen w-full md:w-1/4 md:rounded-tl-lg shadow-xl">
              .......
        </div>

After

<Transition
   show={showMenu}
   enter="transition duration-500 ease-in-out"
   enterFrom="transform translate-x-full"
   enterTo="transform translate-x-0"
   leave="transition duration-500 ease-in-out"
   leaveFrom="transform translate-x-0"
   leaveTo="transform translate-x-full"
   className="bg-primary absolute right-0 h-screen w-full md:w-1/4 md:rounded-tl-lg shadow-xl"
>
        <div className="p-8">
              ..........
        </div>

I think this is because the <Transition> component renders the child in another div. so having your classes there might solve it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues with CSS transitions on Next.js project - Stack Overflow
I'm working on a project in Next.js (React) for the first time. It's a static site (only frontend). Somehow I run into lots...
Read more >
Advanced page transitions with Next.js and Framer Motion
Here's a look at how to use Next.js and Famer Motion to apply subtle, elegant page transitions that add personality and style to...
Read more >
nav links with css transitions not working half the time? : r/nextjs
Basically, I am trying to do a simple css animation using transitions. The project is built in nextjs and tailwind.
Read more >
Page Transition Effect in NextJS - DEV Community ‍ ‍
I was working on page transitions using React Transition Group and the <SwitchTransition> component, with GSAP to create page transitions and ...
Read more >
Page to Page loading transitions with Next.js - YouTube
GitHub : https://github.com/perkinsjr/page-to-page-loaderJoin this channel to get access to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found