DashboardSidebarCollapse

KnopGitHub
Een knop om de zijbalk op het bureaublad samen te vouwen.

Gebruik

De DashboardSidebarCollapse component wordt gebruikt om de DashboardSidebar component ** samen te vouwen / uit te breiden wanneer de collapsible prop is set**.

<template>
  <UDashboardSidebarCollapse />
</template>

Het breidt de Button component uit, zodat u elke eigenschap zoals color, variant, size, enz. Kunt doorgeven.

<template>
  <UDashboardSidebarCollapse variant="subtle" />
</template>
De knop is standaard ingesteld op color="neutral" en variant="ghost".

Voorbeelden

Binnen header slot

U kunt dit onderdeel in de header-sleuf van de DashboardSidebar component plaatsen en de collapsed-prop gebruiken om het linkerdeel van de header te verbergen, bijvoorbeeld:

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

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

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

Binnen leading slot

U kunt deze component in de leading-sleuf van de DashboardNavbar component plaatsen om deze vóór de titel weer te geven, bijvoorbeeld:

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; }
Dit onderdeel ondersteunt ook alle native <button> HTML-kenmerken.

Thema

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: ''
            }
          }
        }
      }
    })
  ]
})

Wijzigingsgelog

No recent changes