Sidebar
Usage
사이드바 구성 요소는 페이지 내용을 푸시하는 독립형 고정 사이드바입니다. 데스크탑에서는 인라인으로 렌더링하고 축소할 수 있습니다. 모바일에서는 [Modal](/docs/components/modalxph04x, [Slideoverxph06x/docs/components/slideoverxph08x 또는 [Drawer](](]( 구성 요소를 엽니다.
header, default 및 footer 슬롯을 사용하여 사이드바 내용을 사용자 정의합니다.v-model:open 지시어는 뷰포트를 인식합니다: 데스크톱에서는 확장/축소 상태를 제어하고 모바일에서는 메뉴를 제어합니다.
<script setup lang="ts">
import type { DropdownMenuItem, NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
const colorMode = useColorMode()
const teams = ref([
{
label: 'Nuxt',
avatar: {
src: 'https://github.com/nuxt.png',
alt: 'Nuxt'
}
},
{
label: 'Vue',
avatar: {
src: 'https://github.com/vuejs.png',
alt: 'Vue'
}
},
{
label: 'UnJS',
avatar: {
src: 'https://github.com/unjs.png',
alt: 'UnJS'
}
}
])
const selectedTeam = ref(teams.value[0])
const teamsItems = computed<DropdownMenuItem[][]>(() => {
return [
teams.value.map((team, index) => ({
...team,
kbds: ['meta', String(index + 1)],
onSelect() {
selectedTeam.value = team
}
})),
[
{
label: 'Create team',
icon: 'i-lucide-circle-plus'
}
]
]
})
function getItems(state: 'collapsed' | 'expanded') {
return [
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Issues',
icon: 'i-lucide-square-dot'
},
{
label: 'Activity',
icon: 'i-lucide-square-activity'
},
{
label: 'Settings',
icon: 'i-lucide-settings',
defaultOpen: true,
children:
state === 'expanded'
? [
{
label: 'General',
icon: 'i-lucide-house'
},
{
label: 'Team',
icon: 'i-lucide-users'
},
{
label: 'Billing',
icon: 'i-lucide-credit-card'
}
]
: []
}
] satisfies NavigationMenuItem[]
}
const user = ref({
name: 'Benjamin Canac',
avatar: {
src: 'https://github.com/benjamincanac.png',
alt: 'Benjamin Canac'
}
})
const userItems = computed<DropdownMenuItem[][]>(() => [
[
{
label: 'Profile',
icon: 'i-lucide-user'
},
{
label: 'Billing',
icon: 'i-lucide-credit-card'
},
{
label: 'Settings',
icon: 'i-lucide-settings',
to: '/settings'
}
],
[
{
label: 'Appearance',
icon: 'i-lucide-sun-moon',
children: [
{
label: 'Light',
icon: 'i-lucide-sun',
type: 'checkbox',
checked: colorMode.value === 'light',
onUpdateChecked(checked: boolean) {
if (checked) {
colorMode.preference = 'light'
}
},
onSelect(e: Event) {
e.preventDefault()
}
},
{
label: 'Dark',
icon: 'i-lucide-moon',
type: 'checkbox',
checked: colorMode.value === 'dark',
onUpdateChecked(checked: boolean) {
if (checked) {
colorMode.preference = 'dark'
}
},
onSelect(e: Event) {
e.preventDefault()
}
}
]
}
],
[
{
label: 'GitHub',
icon: 'i-simple-icons-github',
to: 'https://github.com/nuxt/ui',
target: '_blank'
},
{
label: 'Log out',
icon: 'i-lucide-log-out'
}
]
])
defineShortcuts(extractShortcuts(teamsItems.value))
</script>
<template>
<div class="flex flex-1">
<USidebar
v-model:open="open"
collapsible="icon"
rail
:ui="{
container: 'h-full',
inner: 'bg-elevated/25 divide-transparent',
body: 'py-0'
}"
>
<template #header>
<UDropdownMenu
:items="teamsItems"
:content="{ align: 'start', collisionPadding: 12 }"
:ui="{ content: 'w-(--reka-dropdown-menu-trigger-width) min-w-48' }"
>
<UButton
v-bind="selectedTeam"
trailing-icon="i-lucide-chevrons-up-down"
color="neutral"
variant="ghost"
square
class="w-full data-[state=open]:bg-elevated overflow-hidden"
:ui="{
trailingIcon: 'text-dimmed ms-auto'
}"
/>
</UDropdownMenu>
</template>
<template #default="{ state }">
<UNavigationMenu
:key="state"
:items="getItems(state)"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</template>
<template #footer>
<UDropdownMenu
:items="userItems"
:content="{ align: 'center', collisionPadding: 12 }"
:ui="{ content: 'w-(--reka-dropdown-menu-trigger-width) min-w-48' }"
>
<UButton
v-bind="user"
:label="user?.name"
trailing-icon="i-lucide-chevrons-up-down"
color="neutral"
variant="ghost"
square
class="w-full data-[state=open]:bg-elevated overflow-hidden"
:ui="{
trailingIcon: 'text-dimmed ms-auto'
}"
/>
</UDropdownMenu>
</template>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { ref, computed } from 'vue'
import { useColorMode } from '@vueuse/core'
import type { DropdownMenuItem, NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
const colorMode = useColorMode()
const teams = ref([
{
label: 'Nuxt',
avatar: {
src: 'https://github.com/nuxt.png',
alt: 'Nuxt'
}
},
{
label: 'Vue',
avatar: {
src: 'https://github.com/vuejs.png',
alt: 'Vue'
}
},
{
label: 'UnJS',
avatar: {
src: 'https://github.com/unjs.png',
alt: 'UnJS'
}
}
])
const selectedTeam = ref(teams.value[0])
const teamsItems = computed<DropdownMenuItem[][]>(() => {
return [
teams.value.map((team, index) => ({
...team,
kbds: ['meta', String(index + 1)],
onSelect() {
selectedTeam.value = team
}
})),
[
{
label: 'Create team',
icon: 'i-lucide-circle-plus'
}
]
]
})
function getItems(state: 'collapsed' | 'expanded') {
return [
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Issues',
icon: 'i-lucide-square-dot'
},
{
label: 'Activity',
icon: 'i-lucide-square-activity'
},
{
label: 'Settings',
icon: 'i-lucide-settings',
defaultOpen: true,
children:
state === 'expanded'
? [
{
label: 'General',
icon: 'i-lucide-house'
},
{
label: 'Team',
icon: 'i-lucide-users'
},
{
label: 'Billing',
icon: 'i-lucide-credit-card'
}
]
: []
}
] satisfies NavigationMenuItem[]
}
const user = ref({
name: 'Benjamin Canac',
avatar: {
src: 'https://github.com/benjamincanac.png',
alt: 'Benjamin Canac'
}
})
const userItems = computed<DropdownMenuItem[][]>(() => [
[
{
label: 'Profile',
icon: 'i-lucide-user'
},
{
label: 'Billing',
icon: 'i-lucide-credit-card'
},
{
label: 'Settings',
icon: 'i-lucide-settings',
to: '/settings'
}
],
[
{
label: 'Appearance',
icon: 'i-lucide-sun-moon',
children: [
{
label: 'Light',
icon: 'i-lucide-sun',
type: 'checkbox',
checked: colorMode.value === 'light',
onUpdateChecked(checked: boolean) {
if (checked) {
colorMode.preference = 'light'
}
},
onSelect(e: Event) {
e.preventDefault()
}
},
{
label: 'Dark',
icon: 'i-lucide-moon',
type: 'checkbox',
checked: colorMode.value === 'dark',
onUpdateChecked(checked: boolean) {
if (checked) {
colorMode.preference = 'dark'
}
},
onSelect(e: Event) {
e.preventDefault()
}
}
]
}
],
[
{
label: 'GitHub',
icon: 'i-simple-icons-github',
to: 'https://github.com/nuxt/ui',
target: '_blank'
},
{
label: 'Log out',
icon: 'i-lucide-log-out'
}
]
])
defineShortcuts(extractShortcuts(teamsItems.value))
</script>
<template>
<div class="flex flex-1">
<USidebar
v-model:open="open"
collapsible="icon"
rail
:ui="{
container: 'h-full',
inner: 'bg-elevated/25 divide-transparent',
body: 'py-0'
}"
>
<template #header>
<UDropdownMenu
:items="teamsItems"
:content="{ align: 'start', collisionPadding: 12 }"
:ui="{ content: 'w-(--reka-dropdown-menu-trigger-width) min-w-48' }"
>
<UButton
v-bind="selectedTeam"
trailing-icon="i-lucide-chevrons-up-down"
color="neutral"
variant="ghost"
square
class="w-full data-[state=open]:bg-elevated overflow-hidden"
:ui="{
trailingIcon: 'text-dimmed ms-auto'
}"
/>
</UDropdownMenu>
</template>
<template #default="{ state }">
<UNavigationMenu
:key="state"
:items="getItems(state)"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</template>
<template #footer>
<UDropdownMenu
:items="userItems"
:content="{ align: 'center', collisionPadding: 12 }"
:ui="{ content: 'w-(--reka-dropdown-menu-trigger-width) min-w-48' }"
>
<UButton
v-bind="user"
:label="user?.name"
trailing-icon="i-lucide-chevrons-up-down"
color="neutral"
variant="ghost"
square
class="w-full data-[state=open]:bg-elevated overflow-hidden"
:ui="{
trailingIcon: 'text-dimmed ms-auto'
}"
/>
</UDropdownMenu>
</template>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>Variant
variant 소품을 사용하여 사이드바의 비주얼 스타일을 변경합니다. 기본값은 sidebar입니다.
<script setup lang="ts">
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'variant' | 'collapsible' | 'side'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div
class="flex flex-1"
:class="[
variant === 'inset' && 'bg-neutral-50 dark:bg-neutral-950',
side === 'right' && 'flex-row-reverse'
]"
>
<USidebar
v-model:open="open"
:variant="variant"
:collapsible="collapsible"
:side="side"
:ui="{
container: 'h-full'
}"
>
<template #header>
<UIcon name="i-logos-nuxt-icon" class="size-8" />
</template>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div
class="flex-1 flex flex-col overflow-hidden lg:peer-data-[variant=floating]:my-4 peer-data-[variant=inset]:m-4 lg:peer-data-[variant=inset]:not-peer-data-[collapsible=offcanvas]:ms-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:ring peer-data-[variant=inset]:ring-default bg-default"
>
<div
class="h-(--ui-header-height) shrink-0 flex items-center px-4"
:class="[
variant !== 'floating' && 'border-b border-default',
side === 'right' && 'justify-end'
]"
>
<UButton
:icon="side === 'left' ? 'i-lucide-panel-left' : 'i-lucide-panel-right'"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'variant' | 'collapsible' | 'side'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div
class="flex flex-1"
:class="[
variant === 'inset' && 'bg-neutral-50 dark:bg-neutral-950',
side === 'right' && 'flex-row-reverse'
]"
>
<USidebar
v-model:open="open"
:variant="variant"
:collapsible="collapsible"
:side="side"
:ui="{
container: 'h-full'
}"
>
<template #header>
<UIcon name="i-logos-nuxt-icon" class="size-8" />
</template>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div
class="flex-1 flex flex-col overflow-hidden lg:peer-data-[variant=floating]:my-4 peer-data-[variant=inset]:m-4 lg:peer-data-[variant=inset]:not-peer-data-[collapsible=offcanvas]:ms-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:ring peer-data-[variant=inset]:ring-default bg-default"
>
<div
class="h-(--ui-header-height) shrink-0 flex items-center px-4"
:class="[
variant !== 'floating' && 'border-b border-default',
side === 'right' && 'justify-end'
]"
>
<UButton
:icon="side === 'left' ? 'i-lucide-panel-left' : 'i-lucide-panel-right'"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>축소 가능
collapsible 소품을 사용하여 사이드바의 축소 동작을 변경합니다. 기본값은 offcanvas입니다.
offcanvas: 사이드바가 완전히 보이지 않습니다.icon: 사이드바가 아이콘만 너비로 축소됩니다.none: 사이드바가 접을 수 없습니다.
<script setup lang="ts">
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'variant' | 'collapsible' | 'side'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div
class="flex flex-1"
:class="[
variant === 'inset' && 'bg-neutral-50 dark:bg-neutral-950',
side === 'right' && 'flex-row-reverse'
]"
>
<USidebar
v-model:open="open"
:variant="variant"
:collapsible="collapsible"
:side="side"
:ui="{
container: 'h-full'
}"
>
<template #header>
<UIcon name="i-logos-nuxt-icon" class="size-8" />
</template>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div
class="flex-1 flex flex-col overflow-hidden lg:peer-data-[variant=floating]:my-4 peer-data-[variant=inset]:m-4 lg:peer-data-[variant=inset]:not-peer-data-[collapsible=offcanvas]:ms-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:ring peer-data-[variant=inset]:ring-default bg-default"
>
<div
class="h-(--ui-header-height) shrink-0 flex items-center px-4"
:class="[
variant !== 'floating' && 'border-b border-default',
side === 'right' && 'justify-end'
]"
>
<UButton
:icon="side === 'left' ? 'i-lucide-panel-left' : 'i-lucide-panel-right'"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'variant' | 'collapsible' | 'side'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div
class="flex flex-1"
:class="[
variant === 'inset' && 'bg-neutral-50 dark:bg-neutral-950',
side === 'right' && 'flex-row-reverse'
]"
>
<USidebar
v-model:open="open"
:variant="variant"
:collapsible="collapsible"
:side="side"
:ui="{
container: 'h-full'
}"
>
<template #header>
<UIcon name="i-logos-nuxt-icon" class="size-8" />
</template>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div
class="flex-1 flex flex-col overflow-hidden lg:peer-data-[variant=floating]:my-4 peer-data-[variant=inset]:m-4 lg:peer-data-[variant=inset]:not-peer-data-[collapsible=offcanvas]:ms-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:ring peer-data-[variant=inset]:ring-default bg-default"
>
<div
class="h-(--ui-header-height) shrink-0 flex items-center px-4"
:class="[
variant !== 'floating' && 'border-b border-default',
side === 'right' && 'justify-end'
]"
>
<UButton
:icon="side === 'left' ? 'i-lucide-panel-left' : 'i-lucide-panel-right'"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>사이드
side 소품을 사용하여 사이드바의 측면을 변경합니다. 기본값은 left입니다.
<script setup lang="ts">
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'variant' | 'collapsible' | 'side'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div
class="flex flex-1"
:class="[
variant === 'inset' && 'bg-neutral-50 dark:bg-neutral-950',
side === 'right' && 'flex-row-reverse'
]"
>
<USidebar
v-model:open="open"
:variant="variant"
:collapsible="collapsible"
:side="side"
:ui="{
container: 'h-full'
}"
>
<template #header>
<UIcon name="i-logos-nuxt-icon" class="size-8" />
</template>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div
class="flex-1 flex flex-col overflow-hidden lg:peer-data-[variant=floating]:my-4 peer-data-[variant=inset]:m-4 lg:peer-data-[variant=inset]:not-peer-data-[collapsible=offcanvas]:ms-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:ring peer-data-[variant=inset]:ring-default bg-default"
>
<div
class="h-(--ui-header-height) shrink-0 flex items-center px-4"
:class="[
variant !== 'floating' && 'border-b border-default',
side === 'right' && 'justify-end'
]"
>
<UButton
:icon="side === 'left' ? 'i-lucide-panel-left' : 'i-lucide-panel-right'"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'variant' | 'collapsible' | 'side'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div
class="flex flex-1"
:class="[
variant === 'inset' && 'bg-neutral-50 dark:bg-neutral-950',
side === 'right' && 'flex-row-reverse'
]"
>
<USidebar
v-model:open="open"
:variant="variant"
:collapsible="collapsible"
:side="side"
:ui="{
container: 'h-full'
}"
>
<template #header>
<UIcon name="i-logos-nuxt-icon" class="size-8" />
</template>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div
class="flex-1 flex flex-col overflow-hidden lg:peer-data-[variant=floating]:my-4 peer-data-[variant=inset]:m-4 lg:peer-data-[variant=inset]:not-peer-data-[collapsible=offcanvas]:ms-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:ring peer-data-[variant=inset]:ring-default bg-default"
>
<div
class="h-(--ui-header-height) shrink-0 flex items-center px-4"
:class="[
variant !== 'floating' && 'border-b border-default',
side === 'right' && 'justify-end'
]"
>
<UButton
:icon="side === 'left' ? 'i-lucide-panel-left' : 'i-lucide-panel-right'"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>Title 파일
title prop을 사용하여 사이드바 헤더의 제목을 설정합니다.
<template>
<USidebar title="Navigation">
<Placeholder class="h-full" />
</USidebar>
</template>설명
description prop을 사용하여 사이드바 헤더에 대한 설명을 설정합니다.
<template>
<USidebar title="Navigation" description="Browse your workspace">
<Placeholder class="h-full" />
</USidebar>
</template>Rail 드라이버
rail 소품을 사용하여 사이드바에 얇은 대화식 가장자리를 표시하여 클릭 시 축소된 상태를 토글합니다. 레일은 collapsible가 none가 아닌 경우에만 렌더링됩니다.
<template>
<USidebar rail collapsible="icon" title="Navigation">
<Placeholder class="h-full" />
</USidebar>
</template>close 닫기
close 소품을 사용하여 사이드바 헤더에 닫기 단추를 표시합니다. 닫기 단추는 collapsible가 none가 아닌 경우에만 렌더링됩니다.
Button 구성 요소의 모든 속성을 전달하여 사용자 정의할 수 있습니다.
<template>
<USidebar close rail collapsible="icon" title="Navigation">
<Placeholder class="h-full" />
</USidebar>
</template>Close 아이콘
close-icon 소품을 사용하여 닫기 단추 Icon를 사용자 정의합니다. 기본값은 i-lucide-x입니다.
<template>
<USidebar
close
close-icon="i-lucide-panel-right-close"
rail
collapsible="icon"
side="right"
title="Navigation"
>
<Placeholder class="h-full" />
</USidebar>
</template>Mode 모드
mode 소품을 사용하여 모바일에서 사이드바 메뉴의 모드를 변경합니다. 기본값은 slideover입니다.
<script setup lang="ts">
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'mode'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [{
label: 'Home',
icon: 'i-lucide-house',
active: true
}, {
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
}, {
label: 'Contacts',
icon: 'i-lucide-users'
}]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" :mode="mode" title="Navigation">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { NavigationMenuItem, SidebarProps } from '@nuxt/ui'
// Ignore the props for the example
defineProps<Pick<SidebarProps, 'mode'>>()
const open = ref(true)
const items: NavigationMenuItem[] = [{
label: 'Home',
icon: 'i-lucide-house',
active: true
}, {
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
}, {
label: 'Contacts',
icon: 'i-lucide-users'
}]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" :mode="mode" title="Navigation">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>
examples 예제
Control 오픈 상태
open prop 또는 v-model:open 지시어를 사용하여 열린 상태를 제어 할 수 있습니다.데스크톱에서는 확장 / 축소 상태를 제어하고 모바일에서는 시트 메뉴를 열거나 닫습니다.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
defineShortcuts({
o: () => (open.value = !open.value)
})
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" title="Navigation" collapsible="icon">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
:aria-label="open ? 'Close sidebar' : 'Open sidebar'"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import type { NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
defineShortcuts({
o: () => (open.value = !open.value)
})
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" title="Navigation" collapsible="icon">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
:aria-label="open ? 'Close sidebar' : 'Open sidebar'"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>defineShortcuts를 사용하여 사이드바의 열기 상태를 토글할 수 있습니다:kbd{value="O"}.Persist 열기 상태
VueUse의 useLocalStorage 또는 ](https://nuxt.com/docs/4.x/api/composables/use-cookie) 대신 [)를 사용하여 페이지 재로드 시 사이드바 상태를 유지합니다.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const open = useLocalStorage('sidebar-open', true)
defineShortcuts({
o: () => (open.value = !open.value)
})
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" title="Navigation" collapsible="icon">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { useLocalStorage } from '@vueuse/core'
import type { NavigationMenuItem } from '@nuxt/ui'
const open = useLocalStorage('sidebar-open', true)
defineShortcuts({
o: () => (open.value = !open.value)
})
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" title="Navigation" collapsible="icon">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>ref(true)를 useLocalStorage('sidebar-open', true)로 대체하는 것입니다.사용자 지정 너비
사이드바 너비는 --sidebar-width CSS 변수(기본값은 16rem)로 제어됩니다. 축소된 아이콘 너비는 --sidebar-width-icon(기본값은 4rem)로 제어됩니다.
CSS에서 전역적으로 또는 style 속성을 사용하여 인스턴스별로 재정의합니다.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" collapsible="icon" :style="{ '--sidebar-width': '20rem' }">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import type { NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-1">
<USidebar v-model:open="open" collapsible="icon" :style="{ '--sidebar-width': '20rem' }">
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 flex flex-col">
<div class="h-(--ui-header-height) shrink-0 flex items-center px-4 border-b border-default">
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>with 헤더
사이드바를 Header 아래에 배치하려면 ui prop을 사용하여 gap 및 container를 사용자 정의합니다.
<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-col flex-1">
<UHeader toggle-side="left" :ui="{ container: 'px-4!' }">
<template #toggle>
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</template>
</UHeader>
<div class="flex flex-1 min-h-0">
<USidebar
v-model:open="open"
collapsible="icon"
:ui="{
gap: 'h-[calc(100%-var(--ui-header-height))]',
container:
'absolute top-(--ui-header-height) bottom-0 h-[calc(100%-var(--ui-header-height))]'
}"
>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import type { NavigationMenuItem } from '@nuxt/ui'
const open = ref(true)
const items: NavigationMenuItem[] = [
{
label: 'Home',
icon: 'i-lucide-house',
active: true
},
{
label: 'Inbox',
icon: 'i-lucide-inbox',
badge: '4'
},
{
label: 'Contacts',
icon: 'i-lucide-users'
}
]
</script>
<template>
<div class="flex flex-col flex-1">
<UHeader toggle-side="left" :ui="{ container: 'px-4!' }">
<template #toggle>
<UButton
icon="i-lucide-panel-left"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</template>
</UHeader>
<div class="flex flex-1 min-h-0">
<USidebar
v-model:open="open"
collapsible="icon"
:ui="{
gap: 'h-[calc(100%-var(--ui-header-height))]',
container:
'absolute top-(--ui-header-height) bottom-0 h-[calc(100%-var(--ui-header-height))]'
}"
>
<UNavigationMenu
:items="items"
orientation="vertical"
:ui="{ link: 'p-1.5 overflow-hidden' }"
/>
</USidebar>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
</div>
</template>--ui-header-height 변수는 기본적으로 4rem로 설정되어 있으며 헤더에서 사용됩니다. navbar에서 다른 높이를 사용하는 경우 조정합니다.With AI 채팅 사용
오른쪽의 사이드바를 사용하여 ChatMessages 및 ChatPrompt와 함께 AI 채팅 패널을 만듭니다.
<script setup lang="ts">
import type { UIMessage } from 'ai'
import { isTextUIPart } from 'ai'
import { useChat } from '@ai-sdk/vue'
import { isPartStreaming } from '@nuxt/ui/utils/ai'
import { Markdown } from '@comark/vue'
import shiki from '@comark/vue/plugins/shiki'
import security from '@comark/vue/plugins/security'
const plugins = [
shiki(),
security({ blockedTags: ['script', 'style', 'iframe', 'object', 'embed', 'form'] })
]
const open = ref(true)
const input = ref('')
const initialMessages: UIMessage[] = [
{
id: '1',
role: 'user',
parts: [{ type: 'text', text: 'What is Nuxt UI?' }]
},
{
id: '2',
role: 'assistant',
parts: [
{
type: 'text',
text: 'Nuxt UI is a Vue component library built on Reka UI, Tailwind CSS, and Tailwind Variants. It provides 125+ accessible components for building modern web apps.'
}
]
}
]
const { messages, status, error, sendMessage, regenerate, stop } = useChat({
messages: initialMessages
})
function onSubmit() {
if (!input.value.trim()) return
sendMessage({ text: input.value })
input.value = ''
}
const ui = {
prose: {
p: { base: 'my-2 text-sm/6' },
li: { base: 'my-0.5 text-sm/6' },
ul: { base: 'my-2' },
ol: { base: 'my-2' },
h1: { base: 'text-xl mb-4' },
h2: { base: 'text-lg mt-6 mb-3' },
h3: { base: 'text-base mt-4 mb-2' },
h4: { base: 'text-sm mt-3 mb-1.5' },
code: { base: 'text-xs' },
pre: { root: 'my-2', base: 'text-xs/5' },
table: { root: 'my-2' },
hr: { base: 'my-4' }
}
}
</script>
<template>
<div class="flex flex-1">
<div class="flex-1 flex flex-col">
<div
class="h-(--ui-header-height) shrink-0 flex items-center justify-end px-4 border-b border-default"
>
<UButton
icon="i-lucide-panel-right"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
<USidebar
v-model:open="open"
side="right"
title="AI Chat"
close
:style="{ '--sidebar-width': '20rem' }"
:ui="{ container: 'h-full' }"
>
<UTheme :ui="ui">
<UChatMessages :messages="messages" :status="status" compact class="px-0">
<template #content="{ message }">
<template
v-for="(part, index) in message.parts"
:key="`${message.id}-${part.type}-${index}`"
>
<template v-if="isTextUIPart(part)">
<Markdown
v-if="message.role === 'assistant'"
:value="part.text"
:streaming="isPartStreaming(part)"
:plugins="plugins"
class="*:first:mt-0 *:last:mb-0"
/>
<p v-else-if="message.role === 'user'" class="whitespace-pre-wrap text-sm/6">
{{ part.text }}
</p>
</template>
</template>
</template>
</UChatMessages>
</UTheme>
<template #footer>
<UChatPrompt
v-model="input"
:error="error"
:autofocus="false"
variant="subtle"
size="sm"
@submit="onSubmit"
>
<UChatPromptSubmit size="sm" :status="status" @stop="stop()" @reload="regenerate()" />
</UChatPrompt>
</template>
</USidebar>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import type { UIMessage } from 'ai'
import { isTextUIPart } from 'ai'
import { useChat } from '@ai-sdk/vue'
import { isPartStreaming } from '@nuxt/ui/utils/ai'
import { Markdown } from '@comark/vue'
import shiki from '@comark/vue/plugins/shiki'
import security from '@comark/vue/plugins/security'
const plugins = [
shiki(),
security({ blockedTags: ['script', 'style', 'iframe', 'object', 'embed', 'form'] })
]
const open = ref(true)
const input = ref('')
const initialMessages: UIMessage[] = [
{
id: '1',
role: 'user',
parts: [{ type: 'text', text: 'What is Nuxt UI?' }]
},
{
id: '2',
role: 'assistant',
parts: [
{
type: 'text',
text: 'Nuxt UI is a Vue component library built on Reka UI, Tailwind CSS, and Tailwind Variants. It provides 125+ accessible components for building modern web apps.'
}
]
}
]
const { messages, status, error, sendMessage, regenerate, stop } = useChat({
messages: initialMessages
})
function onSubmit() {
if (!input.value.trim()) return
sendMessage({ text: input.value })
input.value = ''
}
const ui = {
prose: {
p: { base: 'my-2 text-sm/6' },
li: { base: 'my-0.5 text-sm/6' },
ul: { base: 'my-2' },
ol: { base: 'my-2' },
h1: { base: 'text-xl mb-4' },
h2: { base: 'text-lg mt-6 mb-3' },
h3: { base: 'text-base mt-4 mb-2' },
h4: { base: 'text-sm mt-3 mb-1.5' },
code: { base: 'text-xs' },
pre: { root: 'my-2', base: 'text-xs/5' },
table: { root: 'my-2' },
hr: { base: 'my-4' }
}
}
</script>
<template>
<div class="flex flex-1">
<div class="flex-1 flex flex-col">
<div
class="h-(--ui-header-height) shrink-0 flex items-center justify-end px-4 border-b border-default"
>
<UButton
icon="i-lucide-panel-right"
color="neutral"
variant="ghost"
aria-label="Toggle sidebar"
@click="open = !open"
/>
</div>
<div class="flex-1 p-4">
<Placeholder class="size-full" />
</div>
</div>
<USidebar
v-model:open="open"
side="right"
title="AI Chat"
close
:style="{ '--sidebar-width': '20rem' }"
:ui="{ container: 'h-full' }"
>
<UTheme :ui="ui">
<UChatMessages :messages="messages" :status="status" compact class="px-0">
<template #content="{ message }">
<template
v-for="(part, index) in message.parts"
:key="`${message.id}-${part.type}-${index}`"
>
<template v-if="isTextUIPart(part)">
<Markdown
v-if="message.role === 'assistant'"
:value="part.text"
:streaming="isPartStreaming(part)"
:plugins="plugins"
class="*:first:mt-0 *:last:mb-0"
/>
<p v-else-if="message.role === 'user'" class="whitespace-pre-wrap text-sm/6">
{{ part.text }}
</p>
</template>
</template>
</template>
</UChatMessages>
</UTheme>
<template #footer>
<UChatPrompt
v-model="input"
:error="error"
:autofocus="false"
variant="subtle"
size="sm"
@submit="onSubmit"
>
<UChatPromptSubmit size="sm" :status="status" @stop="stop()" @reload="regenerate()" />
</UChatPrompt>
</template>
</USidebar>
</div>
</template>API 파일
Props (### Props)
| Prop | Default | Type |
|---|---|---|
as | 'aside' | anyThe element or component this component should render as. |
variant | 'sidebar' | "floating" | "sidebar" | "inset"The visual variant of the sidebar. |
collapsible | 'offcanvas' | "offcanvas" | "icon" | "none"The collapse behavior of the sidebar.
|
side | 'left' | "left" | "right"The side to render the sidebar on. |
title | stringThe title displayed in the sidebar header. | |
description | stringThe description displayed in the sidebar header. | |
close | false | boolean | Omit<ButtonProps, LinkPropsKeys> Display a close button to collapse the sidebar.
Only renders when |
closeIcon | appConfig.ui.icons.close | anyThe icon displayed in the close button. |
rail | false | boolean Display a rail on the sidebar edge to toggle collapse.
Only renders when |
transition | true | boolean Animate the sidebar when collapsing or expanding. |
mode | 'slideover' | TThe mode of the sidebar menu on mobile. |
menu | SidebarMenu<T>The props for the sidebar menu component on mobile. | |
open | true | boolean |
ui | { root?: SlotClass; gap?: SlotClass; container?: SlotClass; inner?: SlotClass; header?: SlotClass; wrapper?: SlotClass; title?: SlotClass; description?: SlotClass; actions?: SlotClass; close?: SlotClass; body?: SlotClass; footer?: SlotClass; rail?: SlotClass; } |
슬롯
| Slot | Type |
|---|---|
header | { state: SidebarState; open: boolean; close: () => void; } |
title | { state: SidebarState; } |
description | { state: SidebarState; } |
actions | { state: SidebarState; } |
close | { ui: object; } |
default | { state: SidebarState; open: boolean; close: () => void; } |
footer | { state: SidebarState; open: boolean; close: () => void; } |
rail | { ui: object; } |
content | { close: () => void; } |
Theme (## 테마)
export default defineAppConfig({
ui: {
sidebar: {
slots: {
root: 'peer [--sidebar-width:16rem] [--sidebar-width-icon:4rem]',
gap: 'relative w-(--sidebar-width) bg-transparent',
container: 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) lg:flex',
inner: 'flex size-full flex-col overflow-hidden divide-y divide-default',
header: 'flex items-center gap-1.5 overflow-hidden px-4 min-h-(--ui-header-height)',
wrapper: 'min-w-0 flex-1',
title: 'text-highlighted font-semibold truncate',
description: 'text-muted text-sm truncate',
actions: 'flex items-center gap-1.5 shrink-0',
close: '',
body: 'flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4',
footer: 'flex items-center gap-1.5 overflow-hidden p-4',
rail: [
'absolute inset-y-0 z-20 hidden w-4 after:absolute after:inset-y-0 after:left-1/2 after:w-px lg:flex hover:after:bg-(--ui-border-accented)',
'after:transition-colors'
]
},
variants: {
transition: {
true: {
gap: 'transition-[width] duration-200 ease-out motion-reduce:transition-none',
container: 'transition-[inset-inline-start,inset-inline-end,width] duration-200 ease-out motion-reduce:transition-none'
}
},
side: {
left: {
container: 'start-0 border-e border-default',
rail: 'end-0 translate-x-1/2 rtl:-translate-x-1/2'
},
right: {
container: 'end-0 border-s border-default',
rail: '-start-px -translate-x-1/2 rtl:translate-x-1/2'
}
},
collapsible: {
offcanvas: {
root: 'group/sidebar hidden lg:block',
gap: 'data-[state=collapsed]:w-0'
},
icon: {
root: 'group/sidebar hidden lg:block',
gap: 'data-[state=collapsed]:w-(--sidebar-width-icon)',
container: 'data-[state=collapsed]:w-(--sidebar-width-icon)',
actions: 'group-data-[state=collapsed]/sidebar:hidden',
body: 'group-data-[state=collapsed]/sidebar:overflow-hidden'
},
none: {
root: 'h-full w-(--sidebar-width)'
}
},
variant: {
sidebar: {},
floating: {
container: 'p-4 border-transparent',
inner: 'rounded-lg ring ring-default shadow-lg',
rail: 'inset-y-4'
},
inset: {
container: 'py-4 border-transparent',
inner: 'divide-transparent',
rail: 'inset-y-4'
}
}
},
compoundVariants: [
{
side: 'left',
collapsible: [
'offcanvas',
'icon'
],
class: {
rail: 'cursor-w-resize rtl:cursor-e-resize data-[state=collapsed]:cursor-e-resize data-[state=collapsed]:rtl:cursor-w-resize'
}
},
{
side: 'right',
collapsible: [
'offcanvas',
'icon'
],
class: {
rail: 'cursor-e-resize rtl:cursor-w-resize data-[state=collapsed]:cursor-w-resize data-[state=collapsed]:rtl:cursor-e-resize'
}
},
{
side: 'left',
collapsible: 'none',
class: {
root: 'border-e border-default'
}
},
{
side: 'right',
collapsible: 'none',
class: {
root: 'border-s border-default'
}
},
{
side: 'left',
collapsible: 'offcanvas',
class: {
container: 'data-[state=collapsed]:-start-(--sidebar-width)'
}
},
{
side: 'right',
collapsible: 'offcanvas',
class: {
container: 'data-[state=collapsed]:-end-(--sidebar-width)'
}
},
{
variant: 'floating',
collapsible: 'icon',
class: {
gap: 'data-[state=collapsed]:w-[calc(var(--sidebar-width-icon)+--spacing(8))]',
container: 'data-[state=collapsed]:w-[calc(var(--sidebar-width-icon)+--spacing(8)+2px)]'
}
},
{
variant: 'floating',
collapsible: 'none',
class: {
root: 'p-4 border-0'
}
},
{
variant: 'inset',
collapsible: 'none',
class: {
root: 'py-4 border-0'
}
},
{
variant: 'floating',
side: 'left',
class: {
rail: 'end-4'
}
},
{
variant: 'floating',
side: 'right',
class: {
rail: 'start-[calc(--spacing(4)-1px)]'
}
}
]
}
}
})import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
sidebar: {
slots: {
root: 'peer [--sidebar-width:16rem] [--sidebar-width-icon:4rem]',
gap: 'relative w-(--sidebar-width) bg-transparent',
container: 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) lg:flex',
inner: 'flex size-full flex-col overflow-hidden divide-y divide-default',
header: 'flex items-center gap-1.5 overflow-hidden px-4 min-h-(--ui-header-height)',
wrapper: 'min-w-0 flex-1',
title: 'text-highlighted font-semibold truncate',
description: 'text-muted text-sm truncate',
actions: 'flex items-center gap-1.5 shrink-0',
close: '',
body: 'flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4',
footer: 'flex items-center gap-1.5 overflow-hidden p-4',
rail: [
'absolute inset-y-0 z-20 hidden w-4 after:absolute after:inset-y-0 after:left-1/2 after:w-px lg:flex hover:after:bg-(--ui-border-accented)',
'after:transition-colors'
]
},
variants: {
transition: {
true: {
gap: 'transition-[width] duration-200 ease-out motion-reduce:transition-none',
container: 'transition-[inset-inline-start,inset-inline-end,width] duration-200 ease-out motion-reduce:transition-none'
}
},
side: {
left: {
container: 'start-0 border-e border-default',
rail: 'end-0 translate-x-1/2 rtl:-translate-x-1/2'
},
right: {
container: 'end-0 border-s border-default',
rail: '-start-px -translate-x-1/2 rtl:translate-x-1/2'
}
},
collapsible: {
offcanvas: {
root: 'group/sidebar hidden lg:block',
gap: 'data-[state=collapsed]:w-0'
},
icon: {
root: 'group/sidebar hidden lg:block',
gap: 'data-[state=collapsed]:w-(--sidebar-width-icon)',
container: 'data-[state=collapsed]:w-(--sidebar-width-icon)',
actions: 'group-data-[state=collapsed]/sidebar:hidden',
body: 'group-data-[state=collapsed]/sidebar:overflow-hidden'
},
none: {
root: 'h-full w-(--sidebar-width)'
}
},
variant: {
sidebar: {},
floating: {
container: 'p-4 border-transparent',
inner: 'rounded-lg ring ring-default shadow-lg',
rail: 'inset-y-4'
},
inset: {
container: 'py-4 border-transparent',
inner: 'divide-transparent',
rail: 'inset-y-4'
}
}
},
compoundVariants: [
{
side: 'left',
collapsible: [
'offcanvas',
'icon'
],
class: {
rail: 'cursor-w-resize rtl:cursor-e-resize data-[state=collapsed]:cursor-e-resize data-[state=collapsed]:rtl:cursor-w-resize'
}
},
{
side: 'right',
collapsible: [
'offcanvas',
'icon'
],
class: {
rail: 'cursor-e-resize rtl:cursor-w-resize data-[state=collapsed]:cursor-w-resize data-[state=collapsed]:rtl:cursor-e-resize'
}
},
{
side: 'left',
collapsible: 'none',
class: {
root: 'border-e border-default'
}
},
{
side: 'right',
collapsible: 'none',
class: {
root: 'border-s border-default'
}
},
{
side: 'left',
collapsible: 'offcanvas',
class: {
container: 'data-[state=collapsed]:-start-(--sidebar-width)'
}
},
{
side: 'right',
collapsible: 'offcanvas',
class: {
container: 'data-[state=collapsed]:-end-(--sidebar-width)'
}
},
{
variant: 'floating',
collapsible: 'icon',
class: {
gap: 'data-[state=collapsed]:w-[calc(var(--sidebar-width-icon)+--spacing(8))]',
container: 'data-[state=collapsed]:w-[calc(var(--sidebar-width-icon)+--spacing(8)+2px)]'
}
},
{
variant: 'floating',
collapsible: 'none',
class: {
root: 'p-4 border-0'
}
},
{
variant: 'inset',
collapsible: 'none',
class: {
root: 'py-4 border-0'
}
},
{
variant: 'floating',
side: 'left',
class: {
rail: 'end-4'
}
},
{
variant: 'floating',
side: 'right',
class: {
rail: 'start-[calc(--spacing(4)-1px)]'
}
}
]
}
}
})
]
})