Offcanvas

Build hidden sidebars into your project. Sidebars can aid in enhancing user interaction or preventing further interaction.

HTML
vue
<template>
  <BButton @click="click">Show OffCanvas</BButton>
  <BOffcanvas v-model="show" />
</template>

<script setup lang="ts">
import {ref} from 'vue'

const show = ref(false)

const click = () => {
  show.value = !show.value
}
</script>

Customizing Location

Customize location with four standard options top, bottom, start, end.

HTML
vue
<template>
  <BButton @click="click('start')" class="m-2">Show start</BButton>
  <BButton @click="click('end')" class="m-2">Show end</BButton>
  <BButton @click="click('bottom')" class="m-2">Show bottom</BButton>
  <BButton @click="click('top')" class="m-2">Show top</BButton>

  <BOffcanvas v-model="show" :placement="placement" />
</template>

<script setup lang="ts">
const show = ref(false)
const placement = ref('start')

const click = (place = 'start') => {
  placement.value = place
  show.value = !show.value
}
</script>

Responsive

The responsive prop in the BOffcanvas component enables adaptive display behavior based on the viewport size. When set, the offcanvas content displays inline for viewports wider than the specified breakpoint, and as a traditional offcanvas for narrower viewports

template
<BOffcanvas responsive="md" />

Component Reference

<BOffcanvas>
PropTypeDefaultDescription
backdrop-firstbooleanfalse Animate the backdrop before the offcanvas, and on leave animate the offcanvas before the backdrop
body-attrsReadonly<AttrsValue>undefined
body-classClassValueundefined
body-scrollingbooleanfalse
footer-classstringundefined
header-classstringundefined
header-close-classClassValueundefined
header-close-labelstring'Close'
header-close-variantButtonVariant | null'secondary'
idstringundefined
initial-animationbooleanfalse When set, enables the initial animation on mount
lazybooleanfalse When set, the content will not be mounted until opened
model-valuebooleanfalse Controls the visibility of the component
no-animationbooleanfalse When set, disables the animation
no-backdropbooleanfalse
no-close-on-backdropbooleanfalse
no-close-on-escbooleanfalse
no-fadebooleanfalse Alias for `noAnimation`
no-focusbooleanfalse
no-headerbooleanfalse
no-header-closebooleanfalse
no-trapbooleanfalse Disables the focus trap feature
placementPlacement'start'
responsiveBreakpointundefined
shadowSize | booleanfalse
showbooleanfalse When set, and prop 'visible' is false on mount, will animate from closed to open on initial mount. Mainly to help with template show. Use model-value for reactive show/hide
teleport-disabledbooleanfalse
teleport-tostring | RendererElement | null | undefined'body'
titlestringundefined
trans-propsTransitionPropsundefined Transition properties
unmount-lazybooleanfalse When set and `lazy` is true, the content will be unmounted when closed
visiblebooleanfalse When 'true', open without animation
widthstringundefined
EventArgsDescription
breakpoint
value: BvTriggerableEvent - The event
opened: boolean - Whether or not the offcanvas is above the breakpoint and is open by it
Emitted when the offcanvas' breakpoint state changes
close
value: BvTriggerableEvent
esc
value: BvTriggerableEvent
hidden
value: BvTriggerableEvent
hide
value: BvTriggerableEvent
hide-prevented
show
value: BvTriggerableEvent
show-prevented
shown
value: BvTriggerableEvent
update:model-value
update:model-value: boolean
NameScopeDescription
backdrop
default
visible: boolean
placement: 'top' | 'bottom' | 'start' | 'end'
hide: (trigger?: string) => void
footer
visible: boolean
placement: 'top' | 'bottom' | 'start' | 'end'
hide: (trigger?: string) => void
header
visible: boolean
placement: 'top' | 'bottom' | 'start' | 'end'
hide: (trigger?: string) => void
header-close
title
visible: boolean
placement: 'top' | 'bottom' | 'start' | 'end'
hide: (trigger?: string) => void