# SideBar
SideBar is important for a website, it helps users jump from one site section to another quickly
# Default
One of the most common features is to have the hidden sidebar to show it when the user presses a button or makes an action, to add a sidebar we have the component vs-sidebar
Links
To add an internal link using vue-routeropen in new window you can do them simply by adding the property toopen in new window as if it were a vue-routeropen in new window link
In case you need an external link or normal html, simply do it with the href property
Active Link
To make the link is in an active state we have the property v-model
<template lang="html">
<div id="parentx">
<vs-button @click="active=!active" color="primary" type="filled">Open Sidebar</vs-button>
<vs-sidebar parent="body" default-index="1" color="primary" class="sidebarx" spacer v-model="active">
<div class="header-sidebar" slot="header">
<vs-avatar size="70px" src="https://randomuser.me/api/portraits/men/85.jpg"/>
<h4>
My Name
<vs-button color="primary" icon="more_horiz" type="flat"></vs-button>
</h4>
</div>
<vs-sidebar-item index="1" icon="question_answer">
Dashboard
</vs-sidebar-item>
<vs-sidebar-item index="2" icon="gavel">
History
</vs-sidebar-item>
<vs-divider icon="person" position="left">
User
</vs-divider>
<vs-sidebar-item index="3" icon="verified_user">
Configurations
</vs-sidebar-item>
<vs-sidebar-item index="4" icon="account_box">
Profile
</vs-sidebar-item>
<vs-sidebar-item index="5" >
Card
</vs-sidebar-item>
<div class="footer-sidebar" slot="footer">
<vs-button icon="reply" color="danger" type="flat">log out</vs-button>
<vs-button icon="settings" color="primary" type="border"></vs-button>
</div>
</vs-sidebar>
</div>
</template>
<script>
export default {
data:()=>({
active:false,
})
}
</script>
<style lang="stylus">
.header-sidebar
display flex
align-items center
justify-content center
flex-direction column
width 100%
h4
display flex
align-items center
justify-content center
width 100%
> button
margin-left 10px
.footer-sidebar
display flex
align-items center
justify-content space-between
width 100%
> button
border 0px solid rgba(0,0,0,0) !important
border-left 1px solid rgba(0,0,0,.07) !important
border-radius 0px !important
</style>
# Parent
You can change the parent of the sidebar with the property parent
that as a value requires an element of the DOM (#idx, .classx) or a reference of Vuejs as $refs.myrefContent
TIP
By default the parent of the sidebar is the body
<template lang="html">
<div ref="parentSidebar" id="parentx">
<vs-button @click="active=!active" color="primary" type="filled">Open Sidebar</vs-button>
<vs-sidebar :parent="$refs.parentSidebar" default-index="1" color="primary" class="sidebarx" spacer v-model="active">
<div class="header-sidebar" slot="header">
<vs-avatar size="70px" src="https://randomuser.me/api/portraits/men/85.jpg"/>
<h4>
My Name
<vs-button color="primary" icon="more_horiz" type="flat"></vs-button>
</h4>
</div>
<vs-sidebar-item index="1" icon="question_answer">
Dashboard
</vs-sidebar-item>
<vs-sidebar-item index="2" icon="gavel">
History
</vs-sidebar-item>
<vs-divider icon="person" position="left">
User
</vs-divider>
<vs-sidebar-item index="3" icon="verified_user">
Configurations
</vs-sidebar-item>
<vs-sidebar-item index="4" icon="account_box">
Profile
</vs-sidebar-item>
<vs-sidebar-item index="5" >
Card
</vs-sidebar-item>
<div class="footer-sidebar" slot="footer">
<vs-button icon="reply" color="danger" type="flat">log out</vs-button>
<vs-button icon="settings" color="primary" type="border"></vs-button>
</div>
</vs-sidebar>
</div>
</template>
<script>
export default {
data:()=>({
active:false,
})
}
</script>
<style lang="stylus">
#parentx
overflow hidden
height 500px
position relative
.header-sidebar
display flex
align-items center
justify-content center
flex-direction column
width 100%
h4
display flex
align-items center
justify-content center
width 100%
> button
margin-left 10px
.footer-sidebar
display flex
align-items center
justify-content space-between
width 100%
> button
border 0px solid rgba(0,0,0,0) !important
border-left 1px solid rgba(0,0,0,.07) !important
border-radius 0px !important
</style>
# Static
You can also use the sidebar in static mode with the property static
TIP
when putting the sidebar in static mode its position becomes relative for better manipulation
<template lang="html">
<div class="parentx-static">
<vs-sidebar static-position default-index="1" color="primary" class="sidebarx" spacer v-model="active">
<div class="header-sidebar" slot="header">
<vs-avatar size="70px" src="https://randomuser.me/api/portraits/men/85.jpg"/>
<h4>
My Name
<vs-button color="primary" icon="more_horiz" type="flat"></vs-button>
</h4>
</div>
<vs-sidebar-item index="1" icon="question_answer">
Dashboard
</vs-sidebar-item>
<vs-sidebar-item index="2" icon="gavel">
History
</vs-sidebar-item>
<vs-divider icon="person" position="left">
User
</vs-divider>
<vs-sidebar-item index="3" icon="verified_user">
Configurations
</vs-sidebar-item>
<vs-sidebar-item index="4" icon="account_box">
Profile
</vs-sidebar-item>
<vs-sidebar-item index="5" >
Card
</vs-sidebar-item>
<div class="footer-sidebar" slot="footer">
<vs-button icon="reply" color="danger" type="flat">log out</vs-button>
<vs-button icon="settings" color="primary" type="border"></vs-button>
</div>
</vs-sidebar>
</div>
</template>
<script>
export default {
data:()=>({
active:false,
})
}
</script>
<style lang="stylus">
.parentx-static
overflow hidden
height 500px
position relative
.header-sidebar
display flex
align-items center
justify-content center
flex-direction column
width 100%
h4
display flex
align-items center
justify-content center
width 100%
> button
margin-left 10px
.footer-sidebar
display flex
align-items center
justify-content space-between
width 100%
> button
border 0px solid rgba(0,0,0,0) !important
border-left 1px solid rgba(0,0,0,.07) !important
border-radius 0px !important
</style>
# Group Collapsed
You can have groups of sub menus with the component vs-slider-group
that as a required parameter we have the title
, you can add as many groups as you need, including internally from the same component.
TIP
By default the component is closed but if you need to initialize open you can use the property open
My Name
Aplication
Aplication<template lang="html">
<div id="parentx">
<vs-button @click="active=!active" color="primary" type="filled">Open Sidebar</vs-button>
<vs-sidebar parent="body" default-index="1" color="primary" class="sidebarx" spacer v-model="active">
<div class="header-sidebar" slot="header">
<vs-avatar size="70px" src="https://randomuser.me/api/portraits/men/85.jpg"/>
<h4>
My Name
<vs-button color="primary" icon="more_horiz" type="flat"></vs-button>
</h4>
</div>
<vs-sidebar-group title="Aplication">
<vs-sidebar-item index="1" icon="question_answer">
Dashboard
</vs-sidebar-item>
<vs-sidebar-group title="Store">
<vs-sidebar-item index="2.1" icon="store">
Store
</vs-sidebar-item>
<vs-sidebar-item index="2.2" icon="nature_people">
Nature
</vs-sidebar-item>
<vs-sidebar-item index="2.3" icon="style">
Style
</vs-sidebar-item>
</vs-sidebar-group>
<vs-sidebar-item index="2" icon="gavel">
History
</vs-sidebar-item>
<vs-sidebar-item index="3" icon="https">
security
</vs-sidebar-item>
<vs-sidebar-item index="4" icon="help">
Help
</vs-sidebar-item>
</vs-sidebar-group>
<vs-divider icon="person" position="left">
User
</vs-divider>
<vs-sidebar-item index="5" icon="verified_user">
Configurations
</vs-sidebar-item>
<vs-sidebar-item index="6" icon="account_box">
Profile
</vs-sidebar-item>
<div class="footer-sidebar" slot="footer">
<vs-button icon="reply" color="danger" type="flat">log out</vs-button>
<vs-button icon="settings" color="primary" type="border"></vs-button>
</div>
</vs-sidebar>
</div>
</template>
<script>
export default {
data:()=>({
active:false,
})
}
</script>
<style lang="stylus">
.header-sidebar
display flex
align-items center
justify-content center
flex-direction column
width 100%
h4
display flex
align-items center
justify-content center
width 100%
> button
margin-left 10px
.footer-sidebar
display flex
align-items center
justify-content space-between
width 100%
> button
border 0px solid rgba(0,0,0,0) !important
border-left 1px solid rgba(0,0,0,.07) !important
border-radius 0px !important
</style>
# Open on the right
You can also choose where you'd like the sidebar to appear, right or left? By default, a sidebar will be located on the left of the screen but sometimes, a right-screened sidebar is really useful!
WARNING
A static
sidebar will not appear on the right.
<template lang="html">
<div id="parentx">
<vs-button @click="active=!active" color="primary" type="filled">Open Sidebar</vs-button>
<vs-sidebar position-right parent="body" default-index="1" color="primary" class="sidebarx" spacer v-model="active">
<div class="header-sidebar" slot="header">
<vs-avatar size="70px" src="https://randomuser.me/api/portraits/men/85.jpg"/>
<h4>
My Name
<vs-button color="primary" icon="more_horiz" type="flat"></vs-button>
</h4>
</div>
<vs-sidebar-item index="1" icon="question_answer">
Dashboard
</vs-sidebar-item>
<vs-sidebar-item index="2" icon="gavel">
History
</vs-sidebar-item>
<vs-divider icon="person" position="left">
User
</vs-divider>
<vs-sidebar-item index="3" icon="verified_user">
Configurations
</vs-sidebar-item>
<vs-sidebar-item index="4" icon="account_box">
Profile
</vs-sidebar-item>
<vs-sidebar-item index="5" >
Card
</vs-sidebar-item>
<div class="footer-sidebar" slot="footer">
<vs-button icon="reply" color="danger" type="flat">log out</vs-button>
<vs-button icon="settings" color="primary" type="border"></vs-button>
</div>
</vs-sidebar>
</div>
</template>
<script>
export default {
data:()=>({
active:false,
})
}
</script>
<style lang="stylus">
.header-sidebar
display flex
align-items center
justify-content center
flex-direction column
width 100%
h4
display flex
align-items center
justify-content center
width 100%
> button
margin-left 10px
.footer-sidebar
display flex
align-items center
justify-content space-between
width 100%
> button
border 0px solid rgba(0,0,0,0) !important
border-left 1px solid rgba(0,0,0,.07) !important
border-radius 0px !important
</style>
# Reduce and Expand
You can have a reduced sidebar with the reduce
property which by default makes the sidebar look reduced and when hover expands, if you do not want the functionality to expand when hovering you can remove it with the reduce-not-hover-expand
property
TIP
You can remove the bounce animation by opening the sidebar with the prop reduce-not-rebound
Application
Application<template lang="html">
<div id="parentx">
<vs-button @click="active=!active, notExpand = false" color="success" type="filled">Open Sidebar Reduce-expand</vs-button>
<vs-button @click="active=!active, notExpand = true" color="success" type="filled">Open Sidebar Reduce-only</vs-button>
<vs-sidebar :reduce="reduce" :reduce-not-hover-expand="notExpand" parent="body" default-index="1" color="success" class="sidebarx" spacer v-model="active">
<div class="header-sidebar" slot="header">
<vs-avatar size="70px" src="https://randomuser.me/api/portraits/men/85.jpg"/>
</div>
<vs-sidebar-group open title="Application">
<vs-sidebar-item index="1" icon="menu" @click="reduce=!reduce">
Toggle Sidebar
</vs-sidebar-item>
<vs-sidebar-item index="5" icon="verified_user">
Configurations
</vs-sidebar-item>
<vs-sidebar-group title="Store">
<vs-sidebar-item index="2.1" icon="store">
Store
</vs-sidebar-item>
<vs-sidebar-item index="2.2" icon="nature_people">
Nature
</vs-sidebar-item>
<vs-sidebar-item index="2.3" icon="style">
Style
</vs-sidebar-item>
</vs-sidebar-group>
<vs-sidebar-item index="2" icon="gavel">
History
</vs-sidebar-item>
<vs-sidebar-item index="3" icon="https">
Security
</vs-sidebar-item>
<vs-sidebar-item index="4" icon="help">
Help
</vs-sidebar-item>
</vs-sidebar-group>
<vs-divider icon="person" position="left">
User
</vs-divider>
<vs-sidebar-item index="6" icon="account_box">
Profile
</vs-sidebar-item>
<div class="footer-sidebar" slot="footer">
<vs-button icon="settings" color="primary" type="border"></vs-button>
</div>
</vs-sidebar>
</div>
</template>
<script>
export default {
data:()=>({
active:false,
notExpand: false,
reduce: true
})
}
</script>
<style lang="stylus">
.header-sidebar
display flex
align-items center
justify-content center
flex-direction column
width 100%
h4
display flex
align-items center
justify-content center
width 100%
> button
margin-left 10px
.footer-sidebar
display flex
align-items center
justify-content space-between
width 100%
> button
border 0px solid rgba(0,0,0,0) !important
border-left 1px solid rgba(0,0,0,.07) !important
border-radius 0px !important
</style>