NuxtUi SaaS template with nested layout/page transitions?
I want to have transitions between pages with a consistent top navigation, and a consistent side navigation with transitions on the docs page. Im struggling to find any information or get it working myself. The best I managed was a full layout transition when going to the docs page and then consistent page transitions, or consistent top-nav with a single layout and then the side navigation also transitions.
How is this supposed to work?!
https://codesandbox.io/p/github/mikenewbon/saas/main
3 Replies
Hi @MikeNewbon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources, I can help you understand how to implement nested layouts with transitions in Nuxt. The key is to use nested routes with
<NuxtPage> components rather than trying to use multiple layouts simultaneously.
Solution: Nested Routes Approach
The recommended approach is to create a parent page that acts as a "pseudo-layout" containing your shared sidebar, and use <NuxtPage> to render child routes. This is explained in the nested routes documentation.
Here's how to structure it:
Directory Structure:
pages/docs.vue (acts as a layout with sidebar):
Configure transitions in nuxt.config.ts:
Add CSS for transitions in app.vue:
How This Works
1. Top navigation stays consistent because it's in your main layout (default.vue)
2. Sidebar stays consistent on docs pages because it's in the parent docs.vue page
3. Only the nested content transitions when navigating between /docs/getting-started and /docs/api
4. Full layout transition occurs when navigating from home to docs (if you want this)
This approach is confirmed by a Stack Overflow answer where a user solved a similar problem: "The solution is to use nested routes... we're using profile here as a page, but it acts like a layout, where we put a <NuxtPage> instead of a <slot>."
Note: As mentioned in the transitions documentation, "If you are changing layouts as well as page, the page transition you set here will not run. Instead, you should set a layout transition."
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@152169570218672130> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Hey what worked! I had to move the navigation setup into the pseudo docs layout (page) but now the transitions work perfectly!