DashboardSidebarToggle

ButtonGitHub
A Button to toggle the sidebar on mobile.

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>
  <PDashboardSidebarToggle />
</template>

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

<template>
  <PDashboardSidebarToggle 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>
  <PDashboardGroup>
    <PDashboardSidebar>
      <template #toggle>
        <PDashboardSidebarToggle variant="subtle" />
      </template>
    </PDashboardSidebar>

    <slot />
  </PDashboardGroup>
</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
This component also supports all native <button> HTML attributes.

Theme

We use unocss-variants to customize the theme. Read more about it in the theming guide.

Below is the theme configuration skeleton for the PDashboardSidebarToggle. Since the component is provided unstyled by default, you will need to fill in these values to apply your own custom look and feel. If you prefer to use our pre-built, opinionated styling, you can instead use our UnoCSS preset, this docs is using it as well.

app.config.ts
export default defineAppConfig({
  pohon: {
    dashboardSidebarToggle: {
      base: '',
      variants: {
        side: {
          left: '',
          right: ''
        }
      }
    }
  }
};
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'

export default defineAppConfig({
  pohon: {
    dashboardSidebarToggle: {
      base: '',
      variants: {
        side: {
          left: '',
          right: ''
        }
      }
    }
  }
};

Changelog

No recent changes