Sidebar
A sidebar to use as left/right overlay or static
<template>
<section>
<b-sidebar
type="is-light"
:fullheight="fullheight"
:fullwidth="fullwidth"
:overlay="overlay"
:right="right"
:open.sync="open"
>
<div class="p-1">
<img
src="/static/img/buval-logo.png"
alt="lightweight UI components for Vue.js based on Buefy and Bulma"
/>
<b-menu>
<b-menu-list label="Menu">
<b-menu-item icon="information-outline" label="Info"></b-menu-item>
<b-menu-item icon="settings">
<template slot="label" slot-scope="props">
Administrator
<b-icon class="is-pulled-right" :icon="props.expanded ? 'menu-down' : 'menu-up'"></b-icon>
</template>
<b-menu-item icon="user" label="Users"></b-menu-item>
<b-menu-item icon="cellphone-link">
<template slot="label">
Devices
<b-dropdown aria-role="list" class="is-pulled-right" position="is-bottom-left">
<b-icon icon="dots-vertical" slot="trigger"></b-icon>
<b-dropdown-item aria-role="listitem">Action</b-dropdown-item>
<b-dropdown-item aria-role="listitem">Another action</b-dropdown-item>
<b-dropdown-item aria-role="listitem">Something else</b-dropdown-item>
</b-dropdown>
</template>
</b-menu-item>
<b-menu-item icon="cash-multiple" label="Payments" disabled></b-menu-item>
</b-menu-item>
<b-menu-item icon="user" label="My Account">
<b-menu-item label="Account data"></b-menu-item>
<b-menu-item label="Addresses"></b-menu-item>
</b-menu-item>
</b-menu-list>
<b-menu-list>
<b-menu-item label="Expo" icon="link" tag="router-link" target="_blank" to="/expo"></b-menu-item>
</b-menu-list>
<b-menu-list label="Actions">
<b-menu-item label="Logout"></b-menu-item>
</b-menu-list>
</b-menu>
</div>
</b-sidebar>
<div class="block">
<b-field grouped group-multiline>
<div class="control">
<b-switch v-model="overlay">Overlay</b-switch>
</div>
<div class="control">
<b-switch v-model="fullheight">Fullheight</b-switch>
</div>
<div class="control">
<b-switch v-model="fullwidth">Fullwidth</b-switch>
</div>
<div class="control">
<b-switch v-model="right">Right</b-switch>
</div>
</b-field>
</div>
<b-button @click="open = true">Show</b-button>
</section>
</template>
<script>
export default {
data() {
return {
open: false,
overlay: true,
fullheight: true,
fullwidth: false,
right: false
};
}
};
</script>
<style>
.p-1 {
padding: 1em;
}
</style>
Static
<template>
<div class="sidebar-page">
<section class="sidebar-layout">
<b-sidebar
position="static"
:mobile="mobile"
:expand-on-hover="expandOnHover"
:reduce="reduce"
type="is-light"
open
>
<div class="p-1">
<div class="block">
<img
src="/static/img/buval-logo.png"
alt="lightweight UI components for Vue.js based on Buefy and Bulma"
/>
</div>
<b-menu class="is-custom-mobile">
<b-menu-list label="Menu">
<b-menu-item icon="info-circle" label="Info"></b-menu-item>
<b-menu-item active expanded icon="cog" label="Administrator">
<b-menu-item icon="user" label="Users"></b-menu-item>
<b-menu-item icon="phone-laptop" label="Devices"></b-menu-item>
<b-menu-item icon="money-bill" label="Payments" disabled></b-menu-item>
</b-menu-item>
<b-menu-item icon="user" label="My Account">
<b-menu-item icon="book-user" label="Account data"></b-menu-item>
<b-menu-item icon="user-tag" label="Addresses"></b-menu-item>
</b-menu-item>
</b-menu-list>
<b-menu-list>
<b-menu-item icon="plug" label="Extensions"></b-menu-item>
</b-menu-list>
<b-menu-list label="Actions">
<b-menu-item icon="sign-out" label="Logout"></b-menu-item>
</b-menu-list>
</b-menu>
</div>
</b-sidebar>
<div class="p-2">
<b-field>
<b-switch v-model="reduce">Reduced</b-switch>
</b-field>
<b-field>
<b-switch v-model="expandOnHover" :disabled="!reduce">Expand on hover</b-switch>
</b-field>
<b-field label="Mobile Layout">
<b-select v-model="mobile">
<option :value="null"></option>
<option value="reduce">Reduced</option>
<option value="hide">Hidden</option>
<option value="fullwidth">Fullwidth</option>
</b-select>
</b-field>
</div>
</section>
</div>
</template>
<script>
export default {
data() {
return {
expandOnHover: false,
mobile: "reduce",
reduce: false
};
}
};
</script>
<style lang="scss">
.sidebar-page {
display: flex;
flex-direction: column;
width: 100%;
min-height: 100%;
// min-height: 100vh;
.sidebar-layout {
display: flex;
flex-direction: row;
min-height: 100%;
// min-height: 100vh;
}
}
@media screen and (max-width: 1023px) {
.b-sidebar {
.sidebar-content {
&.is-mini-mobile {
&:not(.is-mini-expand),
&.is-mini-expand:not(:hover) {
.menu-list {
li {
a {
span:nth-child(2) {
display: none;
}
}
ul {
padding-left: 0;
li {
a {
display: inline-block;
}
}
}
}
}
.menu-label:not(:last-child) {
margin-bottom: 0;
}
}
}
}
}
}
@media screen and (min-width: 1024px) {
.b-sidebar {
.sidebar-content {
&.is-mini {
&:not(.is-mini-expand),
&.is-mini-expand:not(:hover) {
.menu-list {
li {
a {
span:nth-child(2) {
display: none;
}
}
ul {
padding-left: 0;
li {
a {
display: inline-block;
}
}
}
}
}
.menu-label:not(:last-child) {
margin-bottom: 0;
}
}
}
}
}
}
</style>
API
Sidebar
Name | Description | Type | Value | Default |
|---|---|---|---|---|
open | To control the behaviour of the sidebar programmatically, use the .sync modifier to make it two-way binding | Boolean | — | false |
type | Type (color) of the background, optional | String, | is-white, is-black, is-light,
is-dark, is-primary, is-mix, is-info,
is-success, is-warning, is-danger,
and any other colors you've set in the $colors list on Sass | — |
can-cancel | Can close Modal by clicking 'X', pressing escape or clicking outside | Boolean, Array | escape, x, outside | ['escape', 'x', 'outside'] |
on-cancel | Callback function to call after user canceled (clicked 'X' / pressed escape / clicked outside) | Function | — | — |
fullwidth | Show sidebar in fullwidth. | Boolean | - | false |
fullheight | Show sidebar in fullheight. | Boolean | - | false |
mobile | Custom layout on mobile | String | fullwidth,reduce,hidden | — |
right | Show the sidebar on right | Boolean | false | |
static | Show the sidebar in the current position | Boolean | — | false |
overlay | Show an overlay when sidebar is open | Boolean | — | false |
expand-on-hover | Expand sidebar on hover when reduced or mobile is reduce | Boolean | — | false |
reduce | Show a small sidebar | Boolean | — | false |
container | DOM element the sidebar will be created on when fixed | String | — | body |
Variables #
You can use these variables to customize, Simply set one or multiple of these variables before importing Buval. Learn how.
Name | Default |
|---|---|
$sidebar-background | $modal-background-background-color |
$sidebar-box-shadow | 5px 0px 13px 3px rgba($black, 0.1) |
$sidebar-width | 240px |
$sidebar-mobile-width | 80px |
$sidebar-mobile-breakpoint | $tablet |
