---
title: "DashboardSidebarToggle"
description: "Кнопка мобильного меню, которая показывает или скрывает навигацию бокового меню."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/dashboard-sidebar-toggle"
---
# DashboardSidebarToggle

> Кнопка мобильного меню, которая показывает или скрывает навигацию бокового меню.

## Использование

Компонент DashboardSidebarToggle используют [DashboardNavbar](https://b24-ui.bx-shef.by/raw/docs/components/dashboard-navbar.md) и [DashboardSidebar](https://b24-ui.bx-shef.by/raw/docs/components/dashboard-sidebar.md).

На мобильных устройствах он показывается автоматически и переключает боковое меню, **добавлять его вручную не нужно**.

```vue
<template>
  <B24DashboardSidebarToggle />
</template>
```

Компонент расширяет [Button](https://b24-ui.bx-shef.by/raw/docs/components/button.md), поэтому ему можно передать любое свойство: `color`, `size` и другие.

```vue
<template>
  <B24DashboardSidebarToggle color="air-primary" />
</template>
```

> [!NOTE]
> По умолчанию у кнопки `color="air-tertiary"`.

## Примеры

### В слоте `toggle`

Хотя на мобильных устройствах компонент показывается автоматически, слот `toggle` компонентов [DashboardNavbar](https://b24-ui.bx-shef.by/raw/docs/components/dashboard-navbar.md) и [DashboardSidebar](https://b24-ui.bx-shef.by/raw/docs/components/dashboard-sidebar.md) позволяет настроить кнопку.

```vue [layouts/dashboard.vue]
<template>
  <B24DashboardGroup>
    <B24DashboardSidebar>
      <template #toggle>
        <B24DashboardSidebarToggle />
      </template>
    </B24DashboardSidebar>

    <slot />
  </B24DashboardGroup>
</template>
```

```vue [pages/index.vue]
<script setup lang="ts">
definePageMeta({
  layout: 'dashboard'
})
</script>

<template>
  <B24DashboardPanel>
    <template #header>
      <B24DashboardNavbar title="Home">
        <template #toggle>
          <B24DashboardSidebarToggle />
        </template>
      </B24DashboardNavbar>
    </template>
  </B24DashboardPanel>
</template>
```

> [!TIP]
> Пропс `toggle-side` компонентов `DashboardSidebar` и `DashboardNavbar` задаёт сторону, на которой стоит кнопка.

## API

### Пропсы

```ts
/**
 * Props for the DashboardSidebarToggle component
 */
interface DashboardSidebarToggleProps {
  /**
   * @default 'air-tertiary'
   */
  color?: "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-copilot" | "air-secondary" | "air-secondary-alert" | "air-secondary-accent" | "air-secondary-accent-1" | "air-secondary-accent-2" | "air-secondary-no-accent" | "air-tertiary" | "air-tertiary-accent" | "air-tertiary-no-accent" | "air-selection" | "air-boost" | "link";
  /**
   * The side of the sidebar to toggle.
   * @default 'left'
   */
  side?: "left" | "right" | undefined;
  b24ui?: { base?: any; } | undefined;
  /**
   * Display an icon on the left side.
   */
  icon?: (props: HTMLAttributes & VNodeProps & {}, ctx: Omit<{ attrs: Attrs; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<...>>(exposed?: Exposed | undefined) => void; }, "expose">): any | undefined;
  /**
   * Display an avatar on the left side.
   */
  avatar?: AvatarProps | undefined;
  /**
   * When `true`, the loading icon will be displayed.
   */
  loading?: boolean | undefined;
  /**
   * Class to apply when the link is exact active
   */
  exactActiveClass?: string | undefined;
  /**
   * Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported.
   */
  viewTransition?: boolean | undefined;
  autofocus?: false | true | "true" | "false" | undefined;
  disabled?: boolean | undefined;
  form?: string | undefined;
  formaction?: string | undefined;
  formenctype?: string | undefined;
  formmethod?: string | undefined;
  formnovalidate?: false | true | "true" | "false" | undefined;
  formtarget?: string | undefined;
  name?: string | undefined;
  /**
   * The type of the button when not a link.
   * @default 'button'
   */
  type?: "reset" | "submit" | "button" | undefined;
  onClick?: (event: MouseEvent): void | ((event: MouseEvent) => void)[] | undefined;
  /**
   * The element or component this component should render as when not a link.
   * @default 'button'
   */
  as?: any;
  label?: string | undefined;
  activeColor?: "default" | "air-tertiary" | "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-copilot" | "air-secondary" | "air-secondary-alert" | "air-secondary-accent" | "air-secondary-accent-1" | "air-secondary-accent-2" | "air-secondary-no-accent" | "air-tertiary-accent" | "air-tertiary-no-accent" | "air-selection" | "air-boost" | "danger" | "success" | "warning" | "primary" | "secondary" | "collab" | "ai" | "link" | undefined;
  /**
   * @default 'normal'
   * @deprecated Renders nothing on the `air-*` colours, the default among
   *   them: the `depth` compound variants are keyed on the legacy colour
   *   names only.
   * @removed 3.0.0
   */
  depth?: "light" | "normal" | "dark" | undefined;
  /**
   * @deprecated Same as `depth` — no effect on the `air-*` colours.
   * @removed 3.0.0
   */
  activeDepth?: "light" | "normal" | "dark" | undefined;
  /**
   * @default 'md'
   */
  size?: "xs" | "md" | "xss" | "sm" | "lg" | "xl" | undefined;
  /**
   * Rounds the corners of the button
   * @default false
   */
  rounded?: boolean | undefined;
  /**
   * Render the button full width
   * @default false
   */
  block?: boolean | undefined;
  /**
   * Set loading state automatically based on the `@click` promise state
   * @default false
   */
  loadingAuto?: boolean | undefined;
  /**
   * Disable uppercase label
   * @default true
   */
  normalCase?: boolean | undefined;
  /**
   * Shows LoaderWaitIcon in loading mode
   * @default false
   */
  useWait?: boolean | undefined;
  /**
   * Shows LoaderClockIcon icon in loading mode
   * @default false
   */
  useClock?: boolean | undefined;
  /**
   * Shows a dropdown chevron on the right side, from the dictionary's
   * `chevronDown` role, so an `app.config` override reaches it.
   * @default false
   */
  useDropdown?: boolean | undefined;
}
```

> [!NOTE]
> See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes
> Компонент поддерживает и все нативные HTML-атрибуты `<button>`.

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    dashboardSidebarToggle: {
      base: 'lg:hidden',
      variants: {
        side: {
          left: '',
          right: ''
        }
      }
    }
  }
})
```

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
