본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

대시보드 사이드바 접기

원문 보기 위키 갱신

대시보드 사이드바 접기 (DashboardSidebarCollapse)

데스크톱에서 사이드바를 접고 펼치는 Button 컴포넌트예요. 다만 DashboardSidebar 컴포넌트의 collapsible prop이 설정된 경우에만 접기/펼치기가 동작해요. Button을 확장하기 때문에 color, variant, size 등 어떤 속성이든 전달할 수 있어요.

출처: Nuxt UI

본문

사용법 (Usage)

DashboardSidebarCollapse 컴포넌트는 collapsible prop이 설정된 DashboardSidebar 컴포넌트를 접고/펼치는 데 사용해요.

<template>
  <UDashboardSidebarCollapse />
</template>

Button 컴포넌트를 확장하므로 color, variant, size 같은 어떤 속성이든 전달할 수 있어요.

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

[!NOTE]

이 버튼은 기본값으로 color="neutral", variant="ghost"를 사용해요.

예시 (Examples)

header 슬롯 안에서 사용하기 (Within header slot)

이 컴포넌트를 DashboardSidebar의 header 슬롯에 넣고 collapsed prop을 사용해 예를 들어 헤더의 왼쪽 부분을 숨길 수 있어요.

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

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

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

leading 슬롯 안에서 사용하기 (Within leading slot)

이 컴포넌트를 DashboardNavbar의 leading 슬롯에 넣어 제목 앞에 표시할 수 있어요.

<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

/**
 * Props for the DashboardSidebarCollapse component
 */
interface DashboardSidebarCollapseProps {
  /**
   * @default 'neutral'
   */
  color?: "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | undefined;
  /**
   * @default 'ghost'
   */
  variant?: "link" | "ghost" | "solid" | "outline" | "soft" | "subtle" | undefined;
  /**
   * The side of the sidebar to collapse.
   * @default 'left'
   */
  side?: "left" | "right" | undefined;
  ui?: { base?: any; } | undefined;
  /**
   * @default 'md'
   */
  size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
  name?: string | undefined;
  label?: string | undefined;
  /**
   * Class to apply when the link is exact active
   */
  exactActiveClass?: string | undefined;
  /**
   * Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported.
   */
  viewTransition?: boolean | undefined;
  autofocus?: false | true | "true" | "false" | undefined;
  disabled?: boolean | undefined;
  form?: string | undefined;
  formaction?: string | undefined;
  formenctype?: string | undefined;
  formmethod?: string | undefined;
  formnovalidate?: false | true | "true" | "false" | undefined;
  formtarget?: string | undefined;
  /**
   * The type of the button when not a link.
   * @default 'button'
   */
  type?: "submit" | "reset" | "button" | undefined;
  onClick?: (event: MouseEvent): void | ((event: MouseEvent) => void)[] | undefined;
  /**
   * The element or component this component should render as when not a link.
   * @default 'button'
   */
  as?: any;
  activeColor?: "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | undefined;
  activeVariant?: "link" | "ghost" | "solid" | "outline" | "soft" | "subtle" | undefined;
  /**
   * Render the button with equal padding on all sides.
   */
  square?: boolean | undefined;
  /**
   * Render the button full width.
   */
  block?: boolean | undefined;
  /**
   * Set loading state automatically based on the `@click` promise state
   */
  loadingAuto?: boolean | undefined;
  /**
   * Display an icon based on the `leading` and `trailing` props.
   */
  icon?: any;
  /**
   * Display an avatar on the left side.
   */
  avatar?: AvatarProps | undefined;
  /**
   * When `true`, the icon will be displayed on the left side.
   */
  leading?: boolean | undefined;
  /**
   * Display an icon on the left side.
   */
  leadingIcon?: any;
  /**
   * When `true`, the icon will be displayed on the right side.
   */
  trailing?: boolean | undefined;
  /**
   * Display an icon on the right side.
   */
  trailingIcon?: any;
  /**
   * When `true`, the loading icon will be displayed.
   */
  loading?: boolean | undefined;
  /**
   * The icon when the `loading` prop is `true`.
   * @default appConfig.ui.icons.loading
   */
  loadingIcon?: any;
}

[!NOTE] See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes

This component also supports all native <button> HTML attributes.

[!NOTE]

이 컴포넌트는 네이티브 <button> HTML 속성도 모두 지원해요. 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes 문서를 참고해 주세요.

테마 (Theme)

export default defineAppConfig({
  ui: {
    dashboardSidebarCollapse: {
      base: 'hidden lg:flex',
      variants: {
        side: {
          left: '',
          right: ''
        }
      }
    }
  }
})

변경 내역 (Changelog)

컴포넌트와 테마의 커밋 기록을 확인해 보세요.


사이트맵 (Sitemap)

전체 사이트맵에서 모든 페이지를 확인할 수 있어요.

더 알아보기 (Learn more)