side picks the edge. start and end follow the writing direction.
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VButton, VDrawer, VTypography } from 'vectis-ui'
import type { DrawerSide } from 'vectis-ui'
const SIDES: DrawerSide[] = ['start', 'end', 'top', 'bottom']
const opened = ref<DrawerSide | null>(null)
</script>
<template>
<div class="row">
<VButton
v-for="side in SIDES"
:key="side"
variant="outline"
tone="neutral"
@click="opened = side"
>
{{ side }}
</VButton>
</div>
<VDrawer
v-for="side in SIDES"
:key="side"
:side="side"
:open="opened === side"
:title="`From ${side}`"
subtitle="The drawer slides in from this edge."
@update:open="(value) => !value && (opened = null)"
>
<VTypography>
In a right-to-left page, start is the right edge and end the left one.
</VTypography>
</VDrawer>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-2);
}
</style>
Size
size sets the width of a drawer on a side, or the height of one at the top or bottom. extent replaces it with any CSS length. A strip of the page always stays uncovered.
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VButton, VDrawer, VTypography } from 'vectis-ui'
import type { DrawerSize } from 'vectis-ui'
const SIZES: DrawerSize[] = ['sm', 'md', 'lg']
const opened = ref<string | null>(null)
</script>
<template>
<div class="row">
<VButton
v-for="size in SIZES"
:key="size"
variant="outline"
tone="neutral"
@click="opened = size"
>
{{ size }}
</VButton>
<VButton variant="outline" tone="neutral" @click="opened = 'extent'">extent="50vw"</VButton>
</div>
<VDrawer
v-for="size in SIZES"
:key="size"
:size="size"
:open="opened === size"
:title="`Size ${size}`"
@update:open="(value) => !value && (opened = null)"
>
<VTypography>On a narrow screen the drawer leaves a strip of the page uncovered.</VTypography>
</VDrawer>
<VDrawer
extent="50vw"
:open="opened === 'extent'"
title="Half the viewport"
@update:open="(value) => !value && (opened = null)"
>
<VTypography>The extent is a CSS length, in any unit.</VTypography>
</VDrawer>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-2);
}
</style>
Navigation
The body scrolls while the header and footer stay visible. Close the drawer when an item is selected.