Sidebar
A sidebar to use as left/right overlay or static
Examples
Base
Show code
html
<section>
<o-field grouped>
<o-switch v-model="overlay" label="Overlay" />
<o-switch v-model="fullheight" label="Fullheight" />
<o-switch v-model="fullwidth" label="Fullwidth" />
<o-switch v-model="teleport" label="On body" />
<o-field label="Position">
<o-select v-model="position">
<option value="left">Left</option>
<option value="right">Right</option>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</o-select>
</o-field>
</o-field>
<o-button label="Show" @click="active = true" />
<o-sidebar
v-slot="{ close }"
v-model:active="active"
:fullheight="fullheight"
:fullwidth="fullwidth"
:overlay="overlay"
:position="position"
:teleport="teleport">
<o-button
v-if="fullwidth || fullheight || !overlay"
icon-left="times"
label="Close"
@click="close()" />
<img
width="128"
src="https://avatars2.githubusercontent.com/u/66300512?s=200&v=4"
alt="Lightweight UI components for Vue.js" />
<h3>Example</h3>
</o-sidebar>
</section>
javascript
import { ref } from "vue";
const active = ref(false);
const overlay = ref(true);
const fullheight = ref(true);
const fullwidth = ref(false);
const teleport = ref(false);
const position = ref<"left" | "top" | "bottom" | "right">("left");
Inline
Show code
html
<section class="sidebar-page">
<div class="sidebar-layout">
<o-sidebar
inline
:mobile="mobile"
:expand-on-hover="expandOnHover"
:reduce="reduce"
active>
<img
width="128"
src="https://avatars2.githubusercontent.com/u/66300512?s=200&v=4"
alt="Lightweight UI components for Vue.js" />
<section style="padding: 1em">
<h5>Example 1</h5>
<h5>Example 2</h5>
<h5>Example 3</h5>
<h5>Example 4</h5>
<h5>Example 5</h5>
</section>
</o-sidebar>
</div>
<div class="sidebar-layout">
<o-field>
<o-switch v-model="reduce" label="Reduced" />
</o-field>
<o-field>
<o-switch v-model="expandOnHover" label="Expand on hover" />
</o-field>
<br />
<o-field label="Mobile Layout">
<o-select v-model="mobile">
<option :value="null"></option>
<option value="reduced">Reduced</option>
<option value="hidden">Hidden</option>
<option value="fullwidth">Fullwidth</option>
</o-select>
</o-field>
</div>
</section>
javascript
import { ref } from "vue";
const mobile = ref<"reduced" | "fullwidth" | "hidden">("reduced");
const expandOnHover = ref(false);
const reduce = ref(false);
scss
.sidebar-page {
display: flex;
flex-direction: row;
width: 100%;
}
.sidebar-page .sidebar-layout {
padding: 1rem;
flex-basis: 50%;
}
Component Prop
Show code
html
<section class="odocs-spaced">
<o-button
label="Open Sidebar"
size="medium"
variant="primary"
@click="isSidebarActive = true" />
<o-sidebar
v-model:active="isSidebarActive"
:component="Form"
:fullheight="true"
:overlay="true" />
</section>
javascript
import { ref } from "vue";
import Form from "./_sidebar-form.vue";
const isSidebarActive = ref(false);
Programmatically
Show code
html
<section class="odocs-spaced">
<o-button
label="Open Sidebar (HTML)"
size="medium"
variant="primary"
@click="imageSidebar()" />
<o-button
label="Open Sidebar (Component)"
size="medium"
variant="primary"
@click="formSidebar()" />
</section>
javascript
import { h } from "vue";
import { useOruga } from "@oruga-ui/oruga-next";
import Form from "./_sidebar-form.vue";
const oruga = useOruga();
function imageSidebar(): void {
const vnode = h("p", { style: { "text-align": "center" } }, [
h("img", {
src: "https://avatars2.githubusercontent.com/u/66300512?s=200&v=4",
}),
]);
oruga.sidebar.open({
component: vnode,
fullheight: true,
overlay: true,
destroyOnHide: true,
});
}
function formSidebar(): void {
oruga.sidebar.open({
component: Form,
fullheight: true,
overlay: true,
destroyOnHide: true,
});
}
Class props
'Classes applied to the element'
Sidebar component
A sidebar to use as left/right overlay or static
html
<o-sidebar></o-sidebar>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
active | Whether siedbar is active or not, use v-model:active to make it two-way binding | boolean | - | false |
animation | Custom animation (transition name) | string | - | From config: sidebar: { |
cancelable | Is Sidebar cancleable by pressing escape or clicking outside. | boolean | string[] | escape , outside , true , false | From config: sidebar: { |
component | Component to be injected, used to open a component sidebar programmatically. Close sidebar within the component by emitting a 'close' event — emits('close') | Component | - | |
events | Events to be binded to the injected component | {} | - | |
expandOnHover | Expand sidebar on hover when reduced or mobile is reduce | boolean | - | From config: sidebar: { |
fullheight | Show sidebar in fullheight | boolean | - | From config: sidebar: { |
fullwidth | Show sidebar in fullwidth | boolean | - | From config: sidebar: { |
inline | Display the Sidebear inline | boolean | - | false |
mobile | Custom layout on mobile | "fullwidth" | "reduced" | "hidden" | fullwidth , reduced , hidden | From config: sidebar: { |
mobileBreakpoint | Mobile breakpoint as max-width value | string | - | From config: sidebar: { |
overlay | Show an overlay like modal | boolean | - | From config: sidebar: { |
override | Override existing theme classes completely | boolean | - | |
position | Sidebar position | "top" | "bottom" | "left" | "right" | top , right , bottom , left | From config: sidebar: { |
props | Props to be binded to the injected component | any | - | |
reduce | Show a small sidebar | boolean | - | From config: sidebar: { |
scroll | Use clip to remove the body scrollbar, keep to have a non scrollable scrollbar to avoid shifting background,but will set body to position fixed, might break some layouts. | "keep" | "clip" | keep , clip | From config: sidebar: { |
teleport | Append 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. | string | boolean | object | - | From config: sidebar: { |
Events
Event name | Properties | Description |
---|---|---|
update:active | value boolean - updated active prop | active prop two-way binding |
close | value unknown - close event data | on component close event |
Slots
Name | Description | Bindings |
---|---|---|
default | Sidebar default content, default is component prop | close (...args):void - function to close the component |
Sass variables
Current theme ➜ Oruga
SASS Variable | Default |
---|---|
$sidebar-overlay | hsla(0, 0%, 4%, 0.86) |
$sidebar-box-shadow | 5px 0px 13px 3px rgba(var(--#{$prefix}black), 0.1) |
$sidebar-content-background-color | var(--#{$prefix}grey-lighter) |
$sidebar-border-radius | var(--#{$prefix}base-border-radius) |
$sidebar-border-width | 1px |
$sidebar-border-color | rgba(0, 0, 0, 0.175) |
$sidebar-reduced-width | 80px |
$sidebar-width | 260px |
$sidebar-zindex | 100 |
See ➜ 📄 Full scss file
Current theme ➜ Bulma
SASS Variable | Default |
---|---|
$sidebar-colors | var.$colors |
$sidebar-z | 40 |
$sidebar-background-background-color | hsla( #{css.getVar("scheme-h")}, #{css.getVar("scheme-s")}, #{css.getVar("scheme-invert-l")}, 0.86) |
$sidebar-shadow | css.getVar("shadow") |
$sidebar-width | 260px |
$sidebar-height | 260px |
$sidebar-mobile-width | 80px |
See ➜ 📄 Full scss file
Current theme ➜ Bootstrap
SASS Variable | Default |
---|---|
$sidebar-reduced-width | 5rem |
$sidebar-reduced-height | 10vh |
See ➜ 📄 Full scss file