DashboardSidebarToggle
DashboardSidebarToggle (대시보드 사이드바 토글)
DashboardSidebarToggle 컴포넌트는 모바일에서 사이드바를 토글하는 Button이에요. DashboardNavbar와 DashboardSidebar 컴포넌트에서 사용해요.
출처: Nuxt UI
본문
사용법 (Usage)
DashboardSidebarToggle 컴포넌트는 DashboardNavbar와 DashboardSidebar 컴포넌트에서 사용해요.
모바일에서 사이드바를 토글하기 위해 자동으로 표시되므로 수동으로 추가할 필요가 없어요.
<template>
<UDashboardSidebarToggle />
</template>
Button 컴포넌트를 확장하므로 color, variant, size 등 어떤 속성이든 전달할 수 있어요.
<template>
<UDashboardSidebarToggle variant="subtle" />
</template>
[!NOTE]
버튼의 기본값은
color="neutral",variant="ghost"예요.
예제 (Examples)
toggle 슬롯 안에서 사용
이 컴포넌트가 모바일에서 자동으로 표시되긴 하지만, DashboardNavbar와 DashboardSidebar 컴포넌트의 toggle 슬롯을 사용해 버튼을 커스터마이즈할 수 있어요.
<template>
<UDashboardGroup>
<UDashboardSidebar>
<template #toggle>
<UDashboardSidebarToggle variant="subtle" />
</template>
</UDashboardSidebar>
<slot />
</UDashboardGroup>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'dashboard'
})
</script>
<template>
<UDashboardPanel>
<template #header>
<UDashboardNavbar title="Home">
<template #toggle>
<UDashboardSidebarToggle variant="subtle" />
</template>
</UDashboardNavbar>
</template>
</UDashboardPanel>
</template>
[!TIP]
DashboardSidebar와DashboardNavbar컴포넌트의toggle-sideprop을 사용하면 지정한 쪽에 버튼이 표시돼요.
API
Props (속성)
/**
* Props for the DashboardSidebarToggle component
*/
interface DashboardSidebarToggleProps {
/**
* @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 toggle.
* @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
이 컴포넌트는 모든 네이티브
<button>HTML 속성도 지원해요.
테마 (Theme)
export default defineAppConfig({
ui: {
dashboardSidebarToggle: {
base: 'lg:hidden',
variants: {
side: {
left: '',
right: ''
}
}
}
}
})