Skip to content

Sidebar

Collapsible vertical sidebar with header, nav items, and footer slots.

Open state

Tailwind v4
vue
<script setup>
import { ref } from 'vue'
const open = ref(true)
</script>

<template>
  <div style="display: flex; height: 100vh;">
    <Sidebar v-model="open">
      <template #header>
        <span>My App</span>
      </template>
      <SidebarItem href="#" :active="true">Dashboard</SidebarItem>
      <SidebarItem href="#">Reports</SidebarItem>
      <SidebarItem href="#">Settings</SidebarItem>
      <template #footer>
        <SidebarItem href="#">Log out</SidebarItem>
      </template>
    </Sidebar>
    <main>
      <button @click="open = !open">Toggle</button>
    </main>
  </div>
</template>

Collapsed state

Setting v-model to false collapses to collapsedWidth (default 0).

Sidebar is collapsed to 56px icon-only width.
Tailwind v4
vue
<Sidebar :model-value="false" :collapsed-width="56">
  <SidebarItem href="#" :active="true">
    <template #icon>◆</template>
    Home
  </SidebarItem>
  <SidebarItem href="#">
    <template #icon>⚙</template>
    Settings
  </SidebarItem>
</Sidebar>

Overlay (mobile)

Pass :overlay="true" to render the sidebar as a fixed overlay with a blanket behind it. Clicking the blanket closes it.

Tailwind v4
vue
<script setup>
import { ref } from 'vue'
const open = ref(false)
</script>

<template>
  <button @click="open = true">Open sidebar</button>
  <Sidebar v-model="open" :overlay="true">
    <template #header>
      <span>Menu</span>
    </template>
    <SidebarItem href="#" :active="true">Home</SidebarItem>
    <SidebarItem href="#">About</SidebarItem>
    <SidebarItem href="#">Contact</SidebarItem>
  </Sidebar>
</template>
PropTypeDefaultDescription
modelValuebooleantrueControls open/closed state — use with v-model
widthnumber240Width in px when open
collapsedWidthnumber0Width in px when collapsed
overlaybooleanfalseRenders as a fixed overlay with a backdrop; clicking the backdrop closes it
SlotDescription
headerContent at the top of the sidebar (logo, app name)
defaultNav items — use SidebarItem
footerContent at the bottom (user profile, logout)

SidebarItem Props

PropTypeDefaultDescription
hrefstringRenders as <a> when provided, otherwise <button>
activebooleanfalseHighlights the item with primary blue background
iconstringShort text/emoji icon (prefer the #icon slot for SVG icons)

SidebarItem Slots

SlotDescription
iconIcon content (SVG or text) shown before the label
defaultItem label

Private — Jetpack Labs internal use only