Multiple navigation drawers #21932
-
|
Hello community, Im porting old project from vuetify 2 to 3. My problem is this: in old app we used multiple navigation drawers inside tab components. So you have object detail with multiple tabs and some of those tabs can open right drawer. But, from what I know (i didnt create old app, Im just porting it to v3), you could have multiple drawers all over the place and everything was working as it should. Now, in v3, drawers works differently, whole layout works differently, and from my understanding, all drawers should be at the top of the app, right? Under v-app or v-layout. So, nested childs and tabs in our app can no longer have drawers, just methods to open them from the top of the app Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You're correct — Vuetify 3 changed how layouts and navigation drawers work compared to v2. In Vuetify 3, That said, you absolutely can have multiple drawers in v3. Here's how to handle your use case: Option 1: Multiple drawers at the top level, controlled from child tabs Keep all drawers in your root layout and use a store (Pinia) or provide/inject to toggle them from anywhere: <!-- App.vue / Layout -->
<v-app>
<v-navigation-drawer v-model="leftDrawer" location="left">
<!-- main nav -->
</v-navigation-drawer>
<v-navigation-drawer v-model="tabADrawer" location="right" temporary>
<!-- Tab A drawer content -->
</v-navigation-drawer>
<v-navigation-drawer v-model="tabBDrawer" location="right" temporary>
<!-- Tab B drawer content -->
</v-navigation-drawer>
<v-main>
<router-view />
</v-main>
</v-app>The Option 2: Use a nested You can nest <!-- Inside a tab component -->
<v-layout>
<v-navigation-drawer v-model="drawer" location="right" temporary>
<!-- scoped to this tab -->
</v-navigation-drawer>
<v-main>
<!-- tab content -->
</v-main>
</v-layout>This gives each tab its own layout scope with its own drawer. The nested Option 3: Single shared right drawer with dynamic content Probably the cleanest for your case — one right drawer at the top, and swap its content based on the active tab: <v-navigation-drawer v-model="rightDrawer" location="right" temporary>
<component :is="activeTabDrawerContent" />
</v-navigation-drawer>I'd recommend Option 3 for most migration scenarios since it keeps the layout simple and avoids z-index/coordination issues with multiple drawers. |
Beta Was this translation helpful? Give feedback.
You're correct — Vuetify 3 changed how layouts and navigation drawers work compared to v2.
In Vuetify 3,
v-navigation-draweris designed to work within the layout system (v-apporv-layout). The drawers register themselves with the nearest layout parent and coordinate their positions through it. This is why they're expected to be near the top of your component tree.That said, you absolutely can have multiple drawers in v3. Here's how to handle your use case:
Option 1: Multiple drawers at the top level, controlled from child tabs
Keep all drawers in your root layout and use a store (Pinia) or provide/inject to toggle them from anywhere: