Skip to content

Sidebar

The Sidebar component can be toggled to appear from the left, right, top, or bottom edge of the viewport. The component can be used to show an overlay for navigation, shopping carts, and more.

Examples

Base

The sidebar can be positioned go appear from each side of the viewport using the position prop. Using fullwidht or fullheight, the sidebar overlaps the entire viewport width or height.

Inline

When the property inline is set, the component will be rendered in place. The appearance can be triggered with the active prop as usual.

Teleport

The teleport prop allows the sidebar to be "teleported" into any DOM node outside the DOM hierarchy of that component. By default, if only a boolean is passed, the sidebar will be teleported to the document body. In addition, any other destination can be passed as a value to the teleport prop.

Dynamic Component

Instead of using the default slot, the component prop allows to pass any component that will be programmatically rendered inside the sidebar. Furthermore, an inline component created with a render function can also be passed. Props and events can be passed to the component with props and events props too.

Programmatically

This component provides a programmatic interface that can be accessed by the useOruga() composable.

A sidebar to use as overlay.

html
<o-sidebar></o-sidebar>

Props

Prop nameDescriptionTypeValuesDefault
activeWhether siedbar is active or not, use v-model:active to make it two-way bindingboolean-false
animationCustom animation (transition name)string-
From config:
sidebar: {
  animation: undefined
}
cancelableIs Sidebar cancleable by pressing escape or clicking outside.boolean | string[]escape, outside, true, false
From config:
sidebar: {
  cancelable: ["escape","outside"]
}
clipScrollSet true to remove the body scrollbar.
When false, a non-scrollable scrollbar will be kept to avoid moving the background,
but will set the body to a fixed position, which may break some layouts.
boolean-
From config:
sidebar: {
  clipScroll: false
}
componentComponent to be injected.
Close the component by emitting a 'close' event — $emit('close')
Component-
eventsEvents to be binded to the injected component{}-
expandOnHoverExpand sidebar on hover when reduced or mobile is reduceboolean-
From config:
sidebar: {
  expandOnHover: false
}
fullheightShow sidebar in fullheightboolean-
From config:
sidebar: {
  fullheight: false
}
fullwidthShow sidebar in fullwidthboolean-
From config:
sidebar: {
  fullwidth: false
}
inlineDisplay the Sidebear inlineboolean-false
mobileCustom layout on mobile"expanded" | "hidden" | "reduced"expanded, reduced, hidden
From config:
sidebar: {
  mobile: undefined
}
mobileBreakpointMobile breakpoint as max-width valuestring-
From config:
sidebar: {
  mobileBreakpoint: undefined
}
overlayShow an overlay like modalboolean-
From config:
sidebar: {
  overlay: false
}
overrideOverride existing theme classes completelyboolean-
positionSidebar position"bottom" | "left" | "right" | "top"top, right, bottom, left
From config:
sidebar: {
  position: "left"
}
propsProps to be binded to the injected componentany-
reduceShow a small sidebarboolean-
From config:
sidebar: {
  reduce: false
}
teleportAppend the component to another part of the DOM.
Set true to append the component to the body.
In addition, any CSS selector string or an actual DOM node can be used.
boolean | object | string-
From config:
sidebar: {
  teleport: false
}
trapFocusTrap focus inside the sidebarboolean-
From config:
sidebar: {
  trapFocus: true
}

Events

Event namePropertiesDescription
update:activevalue boolean - updated active propactive prop two-way binding
closevalue unknown - close event dataon component close event

Slots

NameDescriptionBindings
defaultSidebar default content, default is component propclose (...args):void - function to close the component

Class Inspector

Classes applied to the element:
Class propDescriptionPropsSuffixes
rootClassClass of the root element.
mobileClassClass of the root element when on mobile.
👉 Switch to mobile view to see it in action!
activeClassClass of the root element when active.active
teleportClassClass of the root element when teleported.teleport
inlineClassClass of the root element when inlined.inline
overlayClassClass of the overlay element.
contentClassClass of the content element.
visibleClassClass of the content element when visible.active
hiddenClassClass of the content element when hidden.active
positionClassClass of the content element with position.position
fullheightClassClass of the content element when fullheight.fullheight
fullwidthClassClass of the content element when fullwidth.fullwidth
reduceClassClass of the content element when reduced.reduce
expandOnHoverClassClass of the content element when expanded on hover.expandOnHover
scrollClipClassClass of the body when is visible and scroll is clipped.clipScroll
scrollKeepClassClass of the body when is visible and scroll is keeped.clipScroll

Sass variables

Current theme ➜ Oruga

SASS VariableDefault
$sidebar-overlayhsla(0, 0%, 4%, 0.86)
$sidebar-box-shadow5px 0px 13px 3px rgba(var(--#{$prefix}black), 0.1)
$sidebar-content-background-colorvar(--#{$prefix}grey-lighter)
$sidebar-border-radiusvar(--#{$prefix}base-border-radius)
$sidebar-border-width1px
$sidebar-border-colorrgba(0, 0, 0, 0.175)
$sidebar-reduced-width80px
$sidebar-width260px
$sidebar-zindex100

See ➜ 📄 Full scss file

Current theme ➜ Bulma

SASS VariableDefault
$sidebar-z40
$sidebar-width260px
$sidebar-height260px
$sidebar-mobile-width80px
$sidebar-colorsdv.$colors
$sidebar-background-background-colorhsla( #{css.getVar("scheme-h")}, #{css.getVar("scheme-s")}, #{css.getVar("scheme-invert-l")}, 0.86)
$sidebar-shadowcss.getVar("shadow")

See ➜ 📄 Full scss file

Current theme ➜ Bootstrap

SASS VariableDefault
$sidebar-reduced-width10rem
$sidebar-reduced-height10vh

See ➜ 📄 Full scss file

Released under the MIT License.