---
title: "ColorModeAvatar"
description: "Avatar, который сам меняет изображение в зависимости от текущей темы (светлая или тёмная)."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/color-mode-avatar"
---
# ColorModeAvatar

> Avatar, который сам меняет изображение в зависимости от текущей темы (светлая или тёмная).

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

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

Пропсы `light` и `dark` задают источники изображения для светлой и тёмной темы.

```vue
<template>
  <B24ColorModeAvatar light="https://github.com/vuejs.png" dark="https://github.com/nuxt.png" />
</template>
```

> [!NOTE]
> Переключайте светлую и тёмную тему, чтобы увидеть разные изображения: <b24-color-mode-select size="sm">
> </b24-color-mode-select>

## API

### Пропсы

```ts
/**
 * Props for the ColorModeAvatar component
 */
interface ColorModeAvatarProps {
  light: string;
  dark: string;
  /**
   * The element or component this component should render as.
   * @default 'span'
   */
  as?: any;
  b24ui?: { root?: SlotClass; image?: SlotClass; fallback?: SlotClass; icon?: SlotClass; } | undefined;
  alt?: string | undefined;
  decoding?: "async" | "auto" | "sync" | undefined;
  height?: string | number | undefined;
  loading?: "lazy" | "eager" | undefined;
  referrerpolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | undefined;
  sizes?: string | undefined;
  srcset?: string | undefined;
  usemap?: string | undefined;
  width?: string | number | undefined;
  crossorigin?: "anonymous" | "use-credentials" | 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;
  text?: string | undefined;
  /**
   * @default 'md'
   */
  size?: "md" | "3xs" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | undefined;
  /**
   * @default 'air-secondary-no-accent'
   */
  color?: "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "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" | "air-primary-no-accent";
  chip?: boolean | ChipProps | undefined;
}
```

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

## Sitemap

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