Skip to content

Commit e2695ee

Browse files
committed
feat(Drawer): add nested prop
Resolves #4320
1 parent cad7c45 commit e2695ee

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<UDrawer :ui="{ content: 'h-full', overlay: 'bg-inverted/30' }">
3+
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up" />
4+
5+
<template #footer>
6+
<UDrawer nested :ui="{ content: 'h-full', overlay: 'bg-inverted/30' }">
7+
<UButton color="neutral" variant="outline" label="Open nested" />
8+
9+
<template #content>
10+
<Placeholder class="flex-1 m-4" />
11+
</template>
12+
</UDrawer>
13+
</template>
14+
</UDrawer>
15+
</template>

‎docs/content/3.components/drawer.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,17 @@ name: 'drawer-responsive-example'
328328
---
329329
::
330330

331+
### Nested drawers :badge{label="Soon" class="align-text-top"}
332+
333+
You can nest drawers within each other by using the `nested` prop.
334+
335+
::component-example
336+
---
337+
prettier: true
338+
name: 'drawer-nested-example'
339+
---
340+
::
341+
331342
### With footer slot
332343

333344
Use the `#footer` slot to add content after the Drawer's body.

‎playground/app/pages/components/drawer.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ const inset = ref(false)
2828
</template>
2929
</UDrawer>
3030

31+
<UDrawer title="Drawer with nested" :inset="inset" :ui="{ content: 'h-full' }" should-scale-background>
32+
<UButton color="neutral" variant="outline" label="Open nested" />
33+
34+
<template #footer>
35+
<UDrawer :inset="inset" nested :ui="{ content: 'h-full' }">
36+
<UButton color="neutral" variant="outline" label="Open nested" />
37+
38+
<template #content>
39+
<Placeholder class="flex-1 m-4" />
40+
</template>
41+
</UDrawer>
42+
</template>
43+
</UDrawer>
44+
3145
<UDrawer title="Drawer with bottom direction" direction="bottom" :inset="inset">
3246
<UButton color="neutral" variant="outline" label="Open on bottom" />
3347

‎src/runtime/components/Drawer.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export interface DrawerProps extends Pick<DrawerRootProps, 'activeSnapPoint' | '
3737
* @defaultValue true
3838
*/
3939
portal?: boolean | string | HTMLElement
40+
/**
41+
* Whether the drawer is nested in another drawer.
42+
* @defaultValue false
43+
*/
44+
nested?: boolean
4045
class?: any
4146
ui?: Drawer['slots']
4247
}
@@ -57,7 +62,7 @@ export interface DrawerSlots {
5762
<script setup lang="ts">
5863
import { computed, toRef } from 'vue'
5964
import { VisuallyHidden, useForwardPropsEmits } from 'reka-ui'
60-
import { DrawerRoot, DrawerTrigger, DrawerPortal, DrawerOverlay, DrawerContent, DrawerTitle, DrawerDescription, DrawerHandle } from 'vaul-vue'
65+
import { DrawerRoot, DrawerRootNested, DrawerTrigger, DrawerPortal, DrawerOverlay, DrawerContent, DrawerTitle, DrawerDescription, DrawerHandle } from 'vaul-vue'
6166
import { reactivePick } from '@vueuse/core'
6267
import { useAppConfig } from '#imports'
6368
import { usePortal } from '../composables/usePortal'
@@ -90,7 +95,7 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.drawer || {}
9095
</script>
9196

9297
<template>
93-
<DrawerRoot v-bind="rootProps">
98+
<component :is="nested ? DrawerRootNested : DrawerRoot" v-bind="rootProps">
9499
<DrawerTrigger v-if="!!slots.default" as-child :class="props.class">
95100
<slot />
96101
</DrawerTrigger>
@@ -144,5 +149,5 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.drawer || {}
144149
</slot>
145150
</DrawerContent>
146151
</DrawerPortal>
147-
</DrawerRoot>
152+
</component>
148153
</template>

0 commit comments

Comments
 (0)