---
title: "Badge"
description: "Короткая метка статуса или категории."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/badge"
---
# Badge

> Короткая метка статуса или категории.

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

Слот по умолчанию задаёт подпись Badge.

```vue
<template>
  <B24Badge>Бейдж</B24Badge>
</template>
```

### Подпись

Пропс `label` задаёт подпись Badge.

```vue
<template>
  <B24Badge label="Бейдж" />
</template>
```

Пропс `use-link` включает подчёркивание.

```vue
<template>
  <B24Badge label="Бейдж" use-link />
</template>
```

### Цвет

Пропс `color` меняет цвет Badge.

```vue
<template>
  <B24Badge color="air-primary">Бейдж</B24Badge>
</template>
```

### Инверсия

Пропс `inverted` инвертирует цвет Badge.

> [!WARNING]
> Доступно только для цветов `air-primary*`.

```vue
<template>
  <B24Badge inverted color="air-primary">Бейдж</B24Badge>
</template>
```

### Размер

Пропс `size` меняет размер Badge.

```vue
<template>
  <B24Badge size="xl">Бейдж</B24Badge>
</template>
```

### Иконка

Пропс `icon` показывает [иконку](https://bitrix24.github.io/b24icons/icons/) внутри Badge.

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Badge :icon="RocketIcon" size="md" color="air-primary">Бейдж</B24Badge>
</template>
```

Пропс `use-close` показывает иконку закрытия.

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Badge use-close :icon="RocketIcon" size="md" color="air-primary">Бейдж</B24Badge>
</template>
```

### Аватар

Пропс `avatar` показывает [аватар](https://b24-ui.bx-shef.by/raw/docs/components/avatar.md) внутри Badge.

```vue
<template>
  <B24Badge :avatar="{src:'/b24ui/avatar/employee.png',loading:'lazy'}" size="xl" color="air-primary">
Бейдж
</B24Badge>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the Badge component
 */
interface BadgeProps {
  /**
   * The element or component this component should render as.
   * @default 'span'
   */
  as?: any;
  label?: string | number | undefined;
  /**
   * @default 'air-primary'
   */
  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-tertiary" | "air-selection";
  /**
   * If set to `true` the color is inverted.
   * Used for 'air-primary', 'air-primary-success', 'air-primary-alert', 'air-primary-copilot' and 'air-primary-warning' colors.
   * @default false
   */
  inverted?: boolean | undefined;
  /**
   * @default 'md'
   */
  size?: "xss" | "xs" | "sm" | "md" | "lg" | "xl" | undefined;
  /**
   * Render the badge with equal padding on all sides.
   * @default false
   */
  square?: boolean | undefined;
  /**
   * Shows 'underline' on hover
   * @default false
   */
  useLink?: boolean | undefined;
  /**
   * Shows a close cross on the right side, from the dictionary's `close`
   * role, so an `app.config` override reaches it.
   * @default false
   */
  useClose?: boolean | undefined;
  onCloseClick?: (event: MouseEvent): void | ((event: MouseEvent) => void)[] | undefined;
  b24ui?: { base?: SlotClass; wrapper?: SlotClass; label?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailingIcon?: SlotClass; } | 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 icon will be displayed on the right side.
   */
  trailing?: boolean | undefined;
  /**
   * Display an icon on the right side.
   */
  trailingIcon?: (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;
}
```

### Слоты

```ts
/**
 * Slots for the Badge component
 */
interface BadgeSlots {
  leading(): any;
  default(): any;
  trailing(): any;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    badge: {
      slots: {
        base: 'ui-label__scope --air select-none font-[family-name:var(--ui-font-family-secondary)] font-(--ui-label-font-weight) text-(length:--ui-label-font-size)/normal inline-flex items-center transition-all duration-200 ease-linear px-(--ui-label-inline-space) text-(--b24ui-color) bg-(--b24ui-background) border-(--b24ui-border-color) border-(length:--b24ui-border-width)',
        wrapper: 'h-(--ui-label-height) inline-flex items-center',
        label: 'max-w-full whitespace-nowrap text-ellipsis decoration-from-font',
        leadingIcon: 'shrink-0',
        leadingAvatar: 'shrink-0',
        leadingAvatarSize: '',
        trailingIcon: 'shrink-0 cursor-pointer hover:rounded-(--ui-border-radius-circle) hover:bg-current/20'
      },
      variants: {
        fieldGroup: {
          horizontal: 'focus-visible:outline-none ring ring-inset ring-0 focus-visible:ring-2 group-[.is-field-group]/items:not-only:first:rounded-e-none group-[.is-field-group]/items:not-only:last:rounded-s-none group-[.is-field-group]/items:not-last:not-first:rounded-none group-[.is-field-group]/items:not-only:first:border-e-0 group-[.is-field-group]/items:not-only:not-first:border-s-0 focus-visible:z-[1]',
          vertical: 'focus-visible:outline-none ring ring-inset ring-0 focus-visible:ring-2 not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]'
        },
        noSplit: {
          false: "group-[.is-field-group]/items:not-only:not-first:after:content-[''] group-[.is-field-group]/items:not-only:not-first:after:absolute group-[.is-field-group]/items:not-only:not-first:after:top-[7px] group-[.is-field-group]/items:not-only:not-first:after:bottom-[6px] group-[.is-field-group]/items:not-only:not-first:after:left-0 group-[.is-field-group]/items:not-only:not-first:after:w-px group-[.is-field-group]/items:not-only:not-first:after:bg-current/30"
        },
        useLink: {
          true: {
            base: 'cursor-pointer',
            wrapper: 'group',
            label: 'group-hover:underline group-hover:decoration-dashed'
          }
        },
        useClose: {
          true: 'pe-2xs',
          false: ''
        },
        leading: {
          true: 'ps-1',
          false: ''
        },
        color: {
          'air-primary': {
            base: 'style-filled'
          },
          'air-primary-success': {
            base: 'style-filled-success'
          },
          'air-primary-alert': {
            base: 'style-filled-alert'
          },
          'air-primary-copilot': {
            base: 'style-filled-copilot'
          },
          'air-primary-warning': {
            base: 'style-filled-warning'
          },
          'air-secondary': {
            base: 'style-tinted'
          },
          'air-secondary-alert': {
            base: 'style-tinted-alert'
          },
          'air-secondary-accent': {
            base: 'style-outline'
          },
          'air-secondary-accent-1': {
            base: 'style-outline-accent-1'
          },
          'air-secondary-accent-2': {
            base: 'style-outline-accent-2'
          },
          'air-tertiary': {
            base: 'style-outline-no-accent'
          },
          'air-selection': {
            base: 'style-selection'
          },
          default: {
            base: 'style-old-default'
          },
          danger: {
            base: 'style-old-danger'
          },
          success: {
            base: 'style-old-success'
          },
          warning: {
            base: 'style-old-warning'
          },
          primary: {
            base: 'style-old-primary'
          },
          secondary: {
            base: 'style-old-secondary'
          },
          collab: {
            base: 'style-old-collab'
          },
          ai: {
            base: 'style-old-ai'
          }
        },
        size: {
          xss: {
            base: 'ui-label-xss gap-0.5',
            wrapper: 'gap-0.5',
            label: 'underline-offset-1',
            leadingIcon: 'size-[12px]',
            leadingAvatarSize: '3xs',
            trailingIcon: 'size-[12px]'
          },
          xs: {
            base: 'ui-label-xs gap-0.5',
            wrapper: 'gap-0.5',
            label: 'underline-offset-1',
            leadingIcon: 'size-[12px]',
            leadingAvatarSize: '3xs',
            trailingIcon: 'size-[12px]'
          },
          sm: {
            base: 'ui-label-sm gap-1',
            wrapper: 'gap-1',
            label: 'underline-offset-1',
            leadingIcon: 'size-[14px]',
            leadingAvatarSize: '3xs',
            trailingIcon: 'size-[14px]'
          },
          md: {
            base: 'ui-label-md gap-1',
            wrapper: 'gap-1',
            label: 'underline-offset-1',
            leadingIcon: 'size-[15px]',
            leadingAvatarSize: '3xs',
            trailingIcon: 'size-[15px]'
          },
          lg: {
            base: 'ui-label-lg gap-1',
            wrapper: 'gap-1',
            label: '',
            leadingIcon: 'size-[22px]',
            leadingAvatarSize: '2xs',
            trailingIcon: 'size-[22px]'
          },
          xl: {
            base: 'ui-label-xl gap-1',
            wrapper: 'gap-1',
            label: '',
            leadingIcon: 'size-[22px]',
            leadingAvatarSize: '2xs',
            trailingIcon: 'size-[22px]'
          }
        },
        square: {
          true: {
            base: 'rounded-[calc(var(--ui-label-height)_/_4)] ',
            wrapper: 'w-(--ui-label-height)',
            label: 'overflow-hidden'
          },
          false: {
            base: 'rounded-[calc(var(--ui-label-height)_/_2)]'
          }
        },
        inverted: {
          true: {
            base: 'border-(--b24ui-color)'
          },
          false: ''
        }
      },
      compoundVariants: [
        {
          inverted: true,
          color: 'air-primary',
          class: {
            base: 'style-filled-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-success',
          class: {
            base: 'style-filled-success-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-alert',
          class: {
            base: 'style-filled-alert-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-copilot',
          class: {
            base: 'style-filled-copilot-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-warning',
          class: {
            base: 'style-filled-warning-inverted'
          }
        },
        {
          size: 'xss',
          square: true,
          class: {
            base: 'p-0 ps-0 pe-0',
            wrapper: 'px-[2px] gap-0',
            leadingIcon: 'size-[6px]'
          }
        },
        {
          size: 'xs',
          square: true,
          class: {
            base: 'p-0 ps-0 pe-0',
            wrapper: 'px-[2px] gap-0',
            leadingIcon: 'size-[10px]'
          }
        },
        {
          size: 'sm',
          square: true,
          class: {
            base: 'p-0 ps-0 pe-0',
            wrapper: 'p-[1px] gap-0',
            leadingIcon: 'size-[16px]'
          }
        },
        {
          size: 'md',
          square: true,
          class: {
            base: 'p-0 ps-0 pe-0',
            wrapper: 'p-[1px] gap-0',
            leadingIcon: 'size-4.5'
          }
        },
        {
          size: 'lg',
          square: true,
          class: {
            base: 'p-0 ps-0 pe-0',
            wrapper: 'p-[1px] gap-0',
            leadingIcon: 'size-[23px]'
          }
        },
        {
          size: 'xl',
          square: true,
          class: {
            base: 'p-0 ps-0 pe-0',
            wrapper: 'p-[1px] gap-0',
            leadingIcon: 'size-[28px]'
          }
        },
        {
          fieldGroup: [
            'horizontal',
            'vertical'
          ],
          size: [
            'xl',
            'lg',
            'md'
          ],
          class: 'rounded-(--ui-border-radius-md)'
        },
        {
          fieldGroup: [
            'horizontal',
            'vertical'
          ],
          size: 'sm',
          class: 'rounded-(--ui-border-radius-sm)'
        },
        {
          fieldGroup: [
            'horizontal',
            'vertical'
          ],
          size: 'xs',
          class: 'rounded-(--ui-border-radius-xs)'
        },
        {
          fieldGroup: [
            'horizontal',
            'vertical'
          ],
          size: 'xss',
          class: 'rounded-[5px]'
        }
      ],
      defaultVariants: {
        color: 'air-primary',
        size: 'md',
        square: false,
        inverted: false
      }
    }
  }
})
```

## Sitemap

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