sidebar
shadcn-vue/sidebarFreeComponent
shadcn-vue publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn-vue on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-vue.com/r/styles/new-york/sidebar.jsonSource
1<script setup lang="ts">2import type { SidebarProps } from "."3import { cn } from "@/lib/utils"4import { Sheet, SheetContent } from "@/registry/new-york/ui/sheet"5import { SIDEBAR_WIDTH_MOBILE, useSidebar } from "./utils"67defineOptions({8 inheritAttrs: false,9})1011const props = withDefaults(defineProps<SidebarProps>(), {12 side: "left",13 variant: "sidebar",14 collapsible: "offcanvas",15})1617const { isMobile, state, openMobile, setOpenMobile } = useSidebar()18</script>1920<template>21 <div22 v-if="collapsible === 'none'"23 :class="cn('flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground', props.class)"24 v-bind="$attrs"25 >26 <slot />27 </div>2829 <Sheet v-else-if="isMobile" :open="openMobile" v-bind="$attrs" @update:open="setOpenMobile">30 <SheetContent31 data-sidebar="sidebar"32 data-mobile="true"33 :side="side"34 class="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"35 :style="{36 '--sidebar-width': SIDEBAR_WIDTH_MOBILE,37 }"38 >39 <div class="flex h-full w-full flex-col">40 <slot />41 </div>42 </SheetContent>43 </Sheet>4445 <div46 v-else class="group peer hidden md:block"47 :data-state="state"48 :data-collapsible="state === 'collapsed' ? collapsible : ''"49 :data-variant="variant"50 :data-side="side"51 >52 <!-- This is what handles the sidebar gap on desktop -->53 <div54 :class="cn(55 'duration-200 relative h-svh w-(--sidebar-width) bg-transparent transition-[width] ease-linear',56 'group-data-[collapsible=offcanvas]:w-0',57 'group-data-[side=right]:rotate-180',58 variant === 'floating' || variant === 'inset'59 ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]'60 : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',61 )"62 />63 <div64 :class="cn(65 'duration-200 fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] ease-linear md:flex',66 side === 'left'67 ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'68 : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',69 // Adjust the padding for floating and inset variants.70 variant === 'floating' || variant === 'inset'71 ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+_2px)]'72// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from shadcn-vue
All 66 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn-vue | Components | Free | 2 deps · 5 files | |
| alertalert | shadcn-vue | Components | Free | no deps · 4 files | |
| alert-dialogalert-dialog | shadcn-vue | Components | Free | 2 deps · 10 files | |
| aspect-ratioaspect-ratio | shadcn-vue | Components | Free | 1 dep · 2 files | |
| attachmentattachment | shadcn-vue | Components | Free | 1 dep · 10 files | |
| avataravatar | shadcn-vue | Components | Free | 2 deps · 4 files | |
| badgebadge | shadcn-vue | Components | Free | 2 deps · 2 files | |
| breadcrumbbreadcrumb | shadcn-vue | Components | Free | 1 dep · 8 files |
