Skip to content
On this page

Sidebar

Base dashboard sidebar menu

Usage

Basic Sidebar

preview
vue
<template>
  <p-sidebar>
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>Documents</p-nav-item>
      <p-nav-item>Contacts</p-nav-item>
      <p-nav-item>Structure</p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Fixed Sidebar

Fixed sidebar are using z-fixed for z-index value. It posible to change z-index value using CSS variable --p-sidebar-z-index. But don't forget to see the all z-index variant for layer-ordering component.

vue
<template>
  <p-sidebar fixed>
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>Documents</p-nav-item>
      <p-nav-item>Contacts</p-nav-item>
      <p-nav-item>Structure</p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Alignment

To align Sidebar, use align prop. Available value are left and right

vue
<template>
  <p-sidebar fixed align="right">
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>Documents</p-nav-item>
      <p-nav-item>Contacts</p-nav-item>
      <p-nav-item>Structure</p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Condensed

When you need less space/padding of sidebar navigation, you can set by using condensed prop.

vue
<template>
  <p-sidebar fixed>
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav condensed>
      <p-nav-item active>Documents</p-nav-item>
      <p-nav-item>Contacts</p-nav-item>
      <p-nav-item>Structure</p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Types

Sidebar has 2 types, wide and narrow. Default is wide. In variant narrow, you can place your navigation with icon-only or icon-label.

Icon Only

preview
vue
<template>
  <p-sidebar fixed variant="narrow">
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy-icon.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>
        <template #icon>
          <IconDocument />
        </template>
      </p-nav-item>
      <p-nav-item>
        <template #icon>
          <IconDocument />
        </template>
      </p-nav-item>
      <p-nav-item>
        <template #icon>
          <IconDataStructured />
        </template>
      </p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Icon with Label

vue
<template>
  <p-sidebar fixed type="narrow">
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy-icon.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>
        <template #icon>
          <IconDocument />
        </template>
        Docs
      </p-nav-item>
      <p-nav-item>
        <template #icon>
          <IconGroup />
        </template>
        Users
      </p-nav-item>
      <p-nav-item>
        <template #icon>
          <IconDataStructured />
        </template>
        Struct
      </p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Bottom Menus

If you need to place menus in the bottom, you just add bottom prop in your <p-sidebar-nav>

preview
vue
<template>
  <p-sidebar fixed type="narrow">
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy-icon.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav bottom>
      <p-nav-item active>
        <template #icon>
          <IconSettings />
        </template>
      </p-nav-item>
      <p-nav-item>
        <template #icon>
          <img src="/assets/images/icon-flag.svg"/>
        </template>
        ENG
      </p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Submenu just works in wide type. If you need collapsible menus, you just add collapsible prop in your <p-nav-sub-item>

Default Submenu

vue
<template>
  <p-sidebar fixed>
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>
        <template #icon>
          <IconDashboard />
        </template>
        Dashboard
      </p-nav-item>
      <p-nav-sub-item text="Documents">
        <template #icon>
          <IconDocument />
        </template>
        <p-sidebar-nav id="chld-1">
          <p-nav-item>
            Need Action
          </p-nav-item>
          <p-nav-item>
            In Progress
          </p-nav-item>
          <p-nav-item>
            Others
          </p-nav-item>
        </p-sidebar-nav>
      </p-nav-sub-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Collapsible Menus

vue
<template>
  <p-sidebar fixed>
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>
        <template #icon>
          <IconDashboard />
        </template>
        Dashboard
      </p-nav-item>
      <p-nav-sub-item text="Documents" collapsible>
        <template #icon>
          <IconDocument />
        </template>
        <p-sidebar-nav id="chld-1">
          <p-nav-item>
            Need Action
          </p-nav-item>
          <p-nav-item>
            In Progress
          </p-nav-item>
          <p-nav-item>
            Others
          </p-nav-item>
        </p-sidebar-nav>
      </p-nav-sub-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

Toggleable

Toggleable-feature can be used for responsive purpose. It can be toggle the sidebar via toggleable props. It also can toggle-hide or toggle-show automatically if certain breakpoint condition have been met. There are at least 4 breakpoints available: all, lg, md and sm.

preview
vue
<template>
  <p-sidebar v-model="model" toggleable="lg" fixed>
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav title="Main">
      <p-nav-item active>Documents</p-nav-item>
      <p-nav-item>Contacts</p-nav-item>
      <p-nav-item>Structure</p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

It's possible to make sidebar toggle-hide by default to make fullwidth page with no-sidebar. Just give all value in toggleable props.

preview
vue
<template>
  <p-sidebar v-model="model" toggleable="all" fixed type="narrow">
    <template #brand>
      <p-sidebar-brand>
        <img src="/assets/images/logo-privy-icon.svg" alt="" />
      </p-sidebar-brand>
    </template>
    <p-sidebar-nav>
      <p-nav-item active>
        <template #icon>
          <IconDocument />
        </template>
      </p-nav-item>
      <p-nav-item>
        <template #icon>
          <IconGroup />
        </template>
      </p-nav-item>
      <p-nav-item>
        <template #icon>
          <IconDataStructured />
        </template>
      </p-nav-item>
    </p-sidebar-nav>
  </p-sidebar>
</template>

API

Props <p-sidebar>

PropsTypeDefaultDescription
variantStringpillsSidebar variant, valid value is pills, lines and tabs
alignStringleftSidebar alignment, valid value is left and right
typeStringwideSidebar type, valid value is wide and narrow
fixedBooleanfalseActivate fixed Sidebar
toggleableString-Toggle with desired breakpoint lg, md, sm and all

Slots <p-sidebar>

NameDescription
defaultContent to place in the Sidebar
brandContent to place in the Sidebar Brand

Props <p-sidebar-brand>

PropsTypeDefaultDescription
hrefStringundefinedTarget URL of the Sidebar Brand link

Slots <p-sidebar-brand>

NameDescription
defaultContent to place in the Sidebar Brand

Props <p-sidebar-nav>

PropsTypeDefaultDescription
titleStringundefinedTitle to place in the top of sidebar navigation block
bottomBooleanfalsePlace group of sidebar navigation in the bottom of Sidebar
condensedBooleanfalseActivate condensed of group navigation with less space

Slots <p-sidebar-nav>

NameDescription
defaultContent to place in the Sidebar Nav

Events

NameArgumentsDescription
There no event here

Released under the MIT License.