Workspace shell
Keep project-level navigation beside the main page content.
Components / Navigation
A responsive app sidebar with collapsible groups and a mobile drawer.
Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.
Overview
Select a destination from the sidebar to continue.
bunx --bun @getweini/cli@latest add sidebarImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
Your dashboard content.
Your projects content.
<script setup lang="ts">
import { ref, useId } from 'vue'
import Sidebar from './components/ui/sidebar/Sidebar.vue'
import SidebarContent from './components/ui/sidebar/SidebarContent.vue'
import SidebarGroup from './components/ui/sidebar/SidebarGroup.vue'
import SidebarGroupLabel from './components/ui/sidebar/SidebarGroupLabel.vue'
import SidebarHeader from './components/ui/sidebar/SidebarHeader.vue'
import SidebarInset from './components/ui/sidebar/SidebarInset.vue'
import SidebarMenu from './components/ui/sidebar/SidebarMenu.vue'
import SidebarMenuButton from './components/ui/sidebar/SidebarMenuButton.vue'
import SidebarMenuItem from './components/ui/sidebar/SidebarMenuItem.vue'
import SidebarProvider from './components/ui/sidebar/SidebarProvider.vue'
import SidebarTrigger from './components/ui/sidebar/SidebarTrigger.vue'
const id = useId()
const current = ref('dashboard')
</script>
<template>
<SidebarProvider>
<Sidebar>
<SidebarHeader>
Atlas <SidebarTrigger aria-label="Toggle navigation">Menu</SidebarTrigger>
</SidebarHeader>
<SidebarContent aria-label="Workspace navigation">
<SidebarGroup>
<SidebarGroupLabel>Workspace</SidebarGroupLabel>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton
:href="`#${id}-dashboard`"
:active="current === 'dashboard'"
@click="current = 'dashboard'"
>
Dashboard
</SidebarMenuButton>
</SidebarMenuItem>
<SidebarMenuItem>
<SidebarMenuButton
:href="`#${id}-projects`"
:active="current === 'projects'"
@click="current = 'projects'"
>
Projects
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroup>
</SidebarContent>
</Sidebar>
<SidebarInset>
<div class="space-y-6">
<section :id="`${id}-dashboard`">
<h2>Dashboard</h2>
<p>Your dashboard content.</p>
</section>
<section :id="`${id}-projects`">
<h2>Projects</h2>
<p>Your projects content.</p>
</section>
</div>
</SidebarInset>
</SidebarProvider>
</template>A parent without href opens its child links when you click anywhere on the row. If the parent navigates, add SidebarMenuSubTrigger for a separate expand button. Mark the current child page to open its group automatically. Set the mobile breakpoint and save collapsed state in your application.
Keep project-level navigation beside the main page content.
Expand a section to reveal related routes, with the active child visible.
The provider owns state for the sidebar and inset.
<script setup lang="ts">
import { ref, useId } from 'vue'
import Sidebar from './components/ui/sidebar/Sidebar.vue'
import SidebarContent from './components/ui/sidebar/SidebarContent.vue'
import SidebarGroup from './components/ui/sidebar/SidebarGroup.vue'
import SidebarGroupLabel from './components/ui/sidebar/SidebarGroupLabel.vue'
import SidebarHeader from './components/ui/sidebar/SidebarHeader.vue'
import SidebarInset from './components/ui/sidebar/SidebarInset.vue'
import SidebarMenu from './components/ui/sidebar/SidebarMenu.vue'
import SidebarMenuButton from './components/ui/sidebar/SidebarMenuButton.vue'
import SidebarMenuItem from './components/ui/sidebar/SidebarMenuItem.vue'
import SidebarProvider from './components/ui/sidebar/SidebarProvider.vue'
import SidebarTrigger from './components/ui/sidebar/SidebarTrigger.vue'
const id = useId()
const current = ref('dashboard')
</script>
<template>
<SidebarProvider>
<Sidebar>
<SidebarHeader>
Atlas <SidebarTrigger aria-label="Toggle navigation">Menu</SidebarTrigger>
</SidebarHeader>
<SidebarContent aria-label="Workspace navigation">
<SidebarGroup>
<SidebarGroupLabel>Workspace</SidebarGroupLabel>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton
:href="`#${id}-dashboard`"
:active="current === 'dashboard'"
@click="current = 'dashboard'"
>
Dashboard
</SidebarMenuButton>
</SidebarMenuItem>
<SidebarMenuItem>
<SidebarMenuButton
:href="`#${id}-projects`"
:active="current === 'projects'"
@click="current = 'projects'"
>
Projects
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroup>
</SidebarContent>
</Sidebar>
<SidebarInset>
<div class="space-y-6">
<section :id="`${id}-dashboard`">
<h2>Dashboard</h2>
<p>Your dashboard content.</p>
</section>
<section :id="`${id}-projects`">
<h2>Projects</h2>
<p>Your projects content.</p>
</section>
</div>
</SidebarInset>
</SidebarProvider>
</template>A parent without href opens its child links from the whole row.
<script setup lang="ts">
import { ref, useId } from 'vue'
import Sidebar from './components/ui/sidebar/Sidebar.vue'
import SidebarContent from './components/ui/sidebar/SidebarContent.vue'
import SidebarGroup from './components/ui/sidebar/SidebarGroup.vue'
import SidebarGroupLabel from './components/ui/sidebar/SidebarGroupLabel.vue'
import SidebarInset from './components/ui/sidebar/SidebarInset.vue'
import SidebarMenu from './components/ui/sidebar/SidebarMenu.vue'
import SidebarMenuButton from './components/ui/sidebar/SidebarMenuButton.vue'
import SidebarMenuItem from './components/ui/sidebar/SidebarMenuItem.vue'
import SidebarMenuSub from './components/ui/sidebar/SidebarMenuSub.vue'
import SidebarProvider from './components/ui/sidebar/SidebarProvider.vue'
const id = useId()
const current = ref('profile')
</script>
<template>
<SidebarProvider>
<Sidebar>
<SidebarContent aria-label="Settings navigation">
<SidebarGroup>
<SidebarGroupLabel>Settings</SidebarGroupLabel>
<SidebarMenu>
<SidebarMenuItem default-open>
<SidebarMenuButton>Account</SidebarMenuButton>
<SidebarMenuSub>
<SidebarMenuItem>
<SidebarMenuButton
:href="`#${id}-profile`"
:active="current === 'profile'"
@click="current = 'profile'"
>
Profile
</SidebarMenuButton>
</SidebarMenuItem>
<SidebarMenuItem>
<SidebarMenuButton
:href="`#${id}-security`"
:active="current === 'security'"
@click="current = 'security'"
>
Security
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenuSub>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroup>
</SidebarContent>
</Sidebar>
<SidebarInset>
<div class="space-y-6">
<section :id="`${id}-profile`">
<h2>Profile</h2>
<p>Your profile content.</p>
</section>
<section :id="`${id}-security`">
<h2>Security</h2>
<p>Your security content.</p>
</section>
</div>
</SidebarInset>
</SidebarProvider>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
sideprop | SidebarSide | undefined | "left" | Choose the side on which this content appears. |
collapsibleprop | SidebarCollapsible | undefined | "icon" | Allow this panel to collapse. |
defaultslot | {} | Optional | Content shown inside Sidebar. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside SidebarContent. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside SidebarFooter. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside SidebarGroup. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | () => unknown | Required | Content shown inside SidebarGroupLabel. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside SidebarHeader. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside SidebarInset. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside SidebarMenu. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
hrefprop | string | undefined | Not set | URL to navigate to when this link is activated. |
asprop | "button" | Component | "a" | undefined | Not set | Choose the HTML element or Vue component used for this control. |
asChildprop | boolean | undefined | Not set | Use one child element as the control instead of adding another wrapper. |
linkprop | boolean | undefined | Not set | Destination or link behavior for this item. |
activeprop | boolean | undefined | false | Mark this item as the current active item. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
typeprop | "button" | "submit" | "reset" | undefined | "button" | Choose the native HTML control type or action behavior. |
defaultslot | (props: { active: boolean; collapsed: boolean; }) => unknown | Required | Content shown inside SidebarMenuButton. |
iconslot | ((props: { active: boolean; collapsed: boolean; }) => unknown) | undefined | Optional | Content for the icon area of SidebarMenuButton. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
openmodel | boolean | undefined | Not set | Current open state. Use v-model:open to keep it in sync with your page. |
defaultOpenprop | boolean | undefined | false | Starting open state when the parent does not control open. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
update:openevent | [open: boolean] | — | Requests a new open value from the parent. |
openChangeevent | [open: boolean] | — | Emitted after this value or state changes. |
defaultslot | {} | Optional | Content shown inside SidebarMenuItem. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | () => unknown | Required | Content shown inside SidebarMenuSub. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
labelprop | string | Required | Visible or accessible name for this item. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
collapsedmodel | boolean | undefined | Not set | Current collapsed state of this panel. |
defaultCollapsedprop | boolean | undefined | false | Starting collapsed state when the parent does not control it. |
mobileOpenmodel | boolean | undefined | Not set | Current mobile open value. Use the matching v-model binding to update it. |
defaultMobileOpenprop | boolean | undefined | false | Starting mobile open state when the parent does not control it. |
mobileprop | boolean | undefined | false | Use the mobile presentation for this component. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
update:collapsedevent | [collapsed: boolean] | — | Requests a new collapsed value from the parent. |
collapsedChangeevent | [collapsed: boolean] | — | Emitted after this value or state changes. |
update:mobileOpenevent | [open: boolean] | — | Requests a new mobile open value from the parent. |
mobileOpenChangeevent | [open: boolean] | — | Emitted after this value or state changes. |
defaultslot | (props: { collapsed: boolean; mobileOpen: boolean; mobile: boolean; toggle: () => void; }) => unknown | Required | Content shown inside SidebarProvider. |
setCollapsedexposed | (value: boolean) => void | — | Access set collapsed from a component template ref. |
setMobileOpenexposed | (value: boolean) => void | — | Access set mobile open from a component template ref. |
toggleDesktopexposed | () => void | — | Access toggle desktop from a component template ref. |
toggleMobileexposed | () => void | — | Access toggle mobile from a component template ref. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
targetprop | SidebarTriggerTarget | undefined | "auto" | Destination element or browsing context for this item. |
disabledprop | boolean | undefined | false | Prevent interaction and show the disabled state. |
typeprop | "button" | "submit" | "reset" | undefined | "button" | Choose the native HTML control type or action behavior. |
defaultslot | { expanded: boolean; } | Optional | Content shown inside SidebarTrigger. |
// packages/frameworks/vue/components/sidebar/types.ts
import type { Component } from 'vue'
export type SidebarSide = 'left' | 'right'
export type SidebarCollapsible = 'icon' | 'none'
export type SidebarTriggerTarget = 'auto' | 'desktop' | 'mobile'
export interface SidebarProviderProps {
collapsed?: boolean
defaultCollapsed?: boolean
mobileOpen?: boolean
defaultMobileOpen?: boolean
mobile?: boolean
disabled?: boolean
}
export interface SidebarProps {
side?: SidebarSide
collapsible?: SidebarCollapsible
}
export interface SidebarTriggerProps {
target?: SidebarTriggerTarget
disabled?: boolean
type?: 'button' | 'submit' | 'reset'
}
export interface SidebarMenuButtonProps {
href?: string
as?: 'button' | 'a' | Component
asChild?: boolean
link?: boolean
active?: boolean
disabled?: boolean
type?: 'button' | 'submit' | 'reset'
}
export interface SidebarMenuItemProps {
open?: boolean
defaultOpen?: boolean
disabled?: boolean
}