I really think it is inevitable to have some downtimes during your programming career. It is like everything else. When that happens, I like to take a good trip, and completely leave my computer behind. I try to completely disconnect with my work and my working tools during my vacations. That helps a lot.
Though, there is some techniques to reduce the risk and the number of passion losses. First, try to get some new challenges at your work, and if not possible at your work, get some in personal projects. Second, try to work on the biggest technology stack you can. It's great being able to switch to some back-end language if you're tired of front-end Javascript development for example.
But most importantly, keep in mind that it is totally normal, and that we all have that kind of moments. We are humans, not robots ! Sharing it with your colleagues can be a very healthy way of dealing with the problem, if you get along with them well.
If none of theses solutions are working, I guess there is still the possibility (if you're an experienced programmer) to switch to a more management and project owning related position in your company or another one. That would open a whole new horizon of skills to master, while staying in your field of competences.
Wishing you best,