DashboardSidebarToggle

ButtonGitLab
Um Button para abrir e fechar a sidebar no mobile.

Uso

O componente DashboardSidebarToggle é usado pelos componentes DashboardNavbar e DashboardSidebar.

Ele é exibido automaticamente no mobile para abrir e fechar a sidebar, você não precisa adicioná-lo manualmente.

<template>
  <NDashboardSidebarToggle />
</template>

Ele estende o componente Button, então você pode passar qualquer propriedade como color, variant, size, etc.

<template>
  <NDashboardSidebarToggle variant="subtle" />
</template>
O botão usa por padrão color="neutral" e variant="ghost".

Exemplos

Dentro do slot toggle

Embora este componente seja exibido automaticamente no mobile, você pode usar o slot toggle dos componentes DashboardNavbar e DashboardSidebar para personalizar o botão.

<template>
  <NDashboardGroup>
    <NDashboardSidebar>
      <template #toggle>
        <NDashboardSidebarToggle variant="subtle" />
      </template>
    </NDashboardSidebar>

    <slot />
  </NDashboardGroup>
</template>
Ao usar a prop toggle-side dos componentes DashboardSidebar e DashboardNavbar, o botão será exibido no lado especificado.

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" | "accent" | "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"
disabledboolean
name string
type'button' "reset" | "submit" | "button"

The type of the button when not a link.

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

Render the button with equal padding on all sides.

blockboolean

Render the button full width.

loadingAutoboolean

Set loading state automatically based on the @click promise state

iconany

Display an icon based on the leading and trailing props.

avatar AvatarProps

Display an avatar on the left side.

leadingboolean

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

leadingIconany

Display an icon on the left side.

trailingboolean

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

trailingIconany

Display an icon on the right side.

loadingboolean

When true, the loading icon will be displayed.

loadingIconappConfig.ui.icons.loadingany

The icon when the loading prop is true.

ui { base?: any; }
Este componente também suporta todos os atributos HTML nativos de <button>.

Tema

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 '@nitro/ui/vite'

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

Changelog

No recent changes