대시보드사이드바 축소

바탕 화면에서 사이드바를 축소하는 단추입니다.

Usage

DashboardSidebarCollapse 구성 요소는 collapsible 소품이 set**인 경우 DashboardSidebar 구성 요소 **를 축소/확장하는 데 사용됩니다.

<template>
  <UDashboardSidebarCollapse />
</template>

Button 구성 요소를 확장하므로 color, variant, size 등과 같은 속성을 전달할 수 있습니다.

<template>
  <UDashboardSidebarCollapse variant="subtle" />
</template>
버튼의 기본값은 color="neutral" 및 variant="ghost"입니다.

예

xheader 슬롯 내부

이 구성 요소를 DashboardSidebar 구성 요소의 header 슬롯에 넣고 collapsed prop을 사용하여 헤더의 왼쪽 부분을 숨길 수 있습니다.

layouts/dashboard.vue
<template>
  <UDashboardGroup>
    <UDashboardSidebar collapsible>
      <template #header="{ collapsed }">
        <Logo v-if="!collapsed" />

        <UDashboardSidebarCollapse variant="subtle" />
      </template>
    </UDashboardSidebar>

    <slot />
  </UDashboardGroup>
</template>

xleading 슬롯 내

이 구성 요소를 DashboardNavbar 구성 요소의 leading 슬롯에 배치하여 제목 앞에 표시할 수 있습니다. 예를 들면 다음과 같습니다.

pages/index.vue
<script setup lang="ts">
definePageMeta({
  layout: 'dashboard'
})
</script>

<template>
  <UDashboardPanel>
    <template #header>
      <UDashboardNavbar title="Home">
        <template #leading>
          <UDashboardSidebarCollapse variant="subtle" />
        </template>
      </UDashboardNavbar>
    </template>
  </UDashboardPanel>
</template>

API

Props 코드

Prop Default Type
as
'button'
any

The element or component this component should render as when not a link.

color
'neutral'
"error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning"
variant
'ghost'
"ghost" | "solid" | "outline" | "soft" | "subtle" | "link"
side
'left'
"left" | "right"

The side of the sidebar to collapse.

autofocus
false | true | "true" | "false"
disabled
boolean
name
string
type
'button'
"reset" | "submit" | "button"

The type of the button when not a link.

label
string
activeColor
"error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning"
activeVariant
"ghost" | "solid" | "outline" | "soft" | "subtle" | "link"
size
'md'
"xs" | "sm" | "md" | "lg" | "xl"
square
boolean

Render the button with equal padding on all sides.

block
boolean

Render the button full width.

loadingAuto
boolean

Set loading state automatically based on the @click promise state

icon
any

Display an icon based on the leading and trailing props.

avatar
AvatarProps

Display an avatar on the left side.

leading
boolean

When true, the icon will be displayed on the left side.

leadingIcon
any

Display an icon on the left side.

trailing
boolean

When true, the icon will be displayed on the right side.

trailingIcon
any

Display an icon on the right side.

loading
boolean

When true, the loading icon will be displayed.

loadingIcon
appConfig.ui.icons.loading
any

The icon when the loading prop is true.

ui
{ base?: any; }
이 구성 요소는 모든 기본 <button> HTML 속성도 지원합니다.

Theme 테마

app.config.ts
export default defineAppConfig({
  ui: {
    dashboardSidebarCollapse: {
      base: 'hidden lg:flex',
      variants: {
        side: {
          left: '',
          right: ''
        }
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      ui: {
        dashboardSidebarCollapse: {
          base: 'hidden lg:flex',
          variants: {
            side: {
              left: '',
              right: ''
            }
          }
        }
      }
    })
  ]
})

변경 로그

No recent changes