DashboardSidebarToggle

ButtonGitHub
Customize the toggle button to open the sidebar. { color: 'neutral', variant: 'ghost' }

Usage

The DashboardSidebarToggle component is used by the DashboardNavbar and DashboardSidebar components.

It is automatically displayed on mobile to toggle the sidebar, you don't have to add it manually.

<template>
  <UDashboardSidebarToggle />
</template>

It extends the Button component, so you can pass any property such as color, variant, size, etc.

<template>
  <UDashboardSidebarToggle variant="subtle" />
</template>
The button defaults to color="neutral" and variant="ghost".

Examples

Within toggle slot

Even though this component is automatically displayed on mobile, you can use the toggle slot of the DashboardNavbar and DashboardSidebar components to customize the button.

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

    <slot />
  </UDashboardGroup>
</template>
When using the toggle-side prop of the DashboardSidebar and DashboardNavbar components, the button will be displayed on the specified side.

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' "link" | "ghost" | "solid" | "outline" | "soft" | "subtle"
side'left' "left" | "right"

The side of the sidebar to toggle.

name string
label string
to string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric

Route Location the link should navigate to when clicked on.

autofocus false | true | "true" | "false"
disabledboolean
type'button' "reset" | "submit" | "button"

The type of the button when not a link.

downloadany
hreflang string
media string
ping string
target null | string & {} | "_blank" | "_parent" | "_self" | "_top"

Where to display the linked URL, as the name for a browsing context.

referrerpolicy "" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url"
activeboolean

Force the link to be active independent of the current route.

trailingSlash "append" | "remove"

An option to either add or remove trailing slashes in the href for this specific link. Overrides the global trailingSlash option if provided.

activeColor "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning"
activeVariant "link" | "ghost" | "solid" | "outline" | "soft" | "subtle"
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

icon string | object

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.

leadingIcon string | object

Display an icon on the left side.

trailingboolean

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

trailingIcon string | object

Display an icon on the right side.

loadingboolean

When true, the loading icon will be displayed.

loadingIconappConfig.ui.icons.loading string | object

The icon when the loading prop is true.

ui { base?: ClassNameValue; label?: ClassNameValue; leadingIcon?: ClassNameValue; leadingAvatar?: ClassNameValue; leadingAvatarSize?: ClassNameValue; trailingIcon?: ClassNameValue; }
This component also supports all native <button> HTML attributes.

Theme

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

5b177 — feat: extend native HTML attributes (#5348)

5cb65 — feat: import @nuxt/ui-pro components