DashboardsidebarToggle

Un botón para alternar la barra lateral en el móvil.

xph0000xUso

El componente DashboardSidebarToggle lo utilizan los componentes DashboardNavbar y DashboardSidebar.

Se muestra automáticamente en el móvil para alternar la barra lateral, **no tienes que agregarlo manualmente **.

<template>
  <UDashboardSidebarToggle />
</template>

Extiende el componente Button, por lo que puede pasar cualquier propiedad como color, variant, size, etc.

<template>
  <UDashboardSidebarToggle variant="subtle" />
</template>
El botón por defecto es color="neutral" y variant="ghost".

Ejemplos

Dentro de la ranura toggle

A pesar de que este componente se muestra automáticamente en el móvil, puede utilizar la ranura toggle de los componentes DashboardNavbar y DashboardSidebar para personalizar el botón.

<template>
  <UDashboardGroup>
    <UDashboardSidebar>
      <template #toggle>
        <UDashboardSidebarToggle variant="subtle" />
      </template>
    </UDashboardSidebar>

    <slot />
  </UDashboardGroup>
</template>
Cuando se utiliza el soporte toggle-side de los componentes DashboardSidebar y DashboardNavbar, el botón se mostrará en el lado especificado.

API

Accesorios

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 toggle.

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; }
Este componente también soporta todos los atributos HTML <button> nativos.

Temas

app.config.ts
export default defineAppConfig({
  ui: {
    dashboardSidebarToggle: {
      base: 'lg:hidden',
      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: {
        dashboardSidebarToggle: {
          base: 'lg:hidden',
          variants: {
            side: {
              left: '',
              right: ''
            }
          }
        }
      }
    })
  ]
})

Changelog (Edición española)

No recent changes