---
title: "User"
description: "Компонент для показа данных пользователя: имени, описания и фото профиля."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/user"
---
# User

> Компонент для показа данных пользователя: имени, описания и фото профиля.

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

### Имя

Пропс `name` показывает имя пользователя.

```vue
<template>
  <B24User name="Иван Петров" />
</template>
```

### Описание

Пропс `description` показывает описание пользователя.

```vue
<template>
  <B24User name="Иван Петров" description="Инженер-программист" />
</template>
```

### Аватар

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

```vue
<template>
  <B24User name="Иван Петров" description="Инженер-программист" :avatar="{src:'/b24ui/avatar/employee.png',loading:'lazy'}" />
</template>
```

```ts
/**
 * Props for the Avatar component
 */
interface AvatarProps {
  /**
   * The element or component this component should render as.
   * @default 'span'
   */
  as?: any;
  src?: string | undefined;
  alt?: string | 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;
  b24ui?: { root?: SlotClass; image?: SlotClass; fallback?: SlotClass; icon?: SlotClass; } | 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;
}
```

### Цвет

Пропс `color` тонирует вложенный [Avatar](https://b24-ui.bx-shef.by/raw/docs/components/avatar.md). Значение `avatar.color`, отличное от `undefined`, переопределяет его.

```vue
<template>
  <B24User name="Иван Петров" description="Инженер-программист" :avatar="{src:'/b24ui/avatar/employee.png'}" color="air-primary-alert" />
</template>
```

### Чип

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

```vue
<template>
  <B24User name="Иван Петров" description="Инженер-программист" :avatar="{src:'/b24ui/avatar/employee.png'}" :chip="{color:'primary',position:'top-right'}" />
</template>
```

```ts
/**
 * Props for the Chip component
 */
interface ChipProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * Display some text inside the chip.
   */
  text?: string | number | undefined;
  /**
   * The icon displayed on the right side of the chip.
   */
  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;
  /**
   * @default 'danger'
   */
  color?: "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary" | "air-secondary-accent" | "air-secondary-accent-1" | "air-tertiary";
  /**
   * 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 'sm'
   */
  size?: "sm" | "md" | "lg" | undefined;
  /**
   * The position of the chip.
   * @default 'top-right'
   */
  position?: "top-right" | "bottom-right" | "top-left" | "bottom-left" | undefined;
  /**
   * When `true`, keep the chip inside the component for rounded elements
   * @default false
   */
  inset?: boolean | undefined;
  /**
   * When `true`, render the chip relatively to the parent.
   * @default false
   */
  standalone?: boolean | undefined;
  /**
   * When `true`, hide chip if value='0'
   * @default false
   */
  hideZero?: boolean | undefined;
  b24ui?: { root?: SlotClass; base?: SlotClass; trailingIcon?: SlotClass; } | undefined;
  /**
   * @default true
   */
  show?: boolean | undefined;
}
```

### Размер

Пропс `size` меняет размер аватара и текста пользователя.

```vue
<template>
  <B24User name="Иван Петров" description="Инженер-программист" :avatar="{src:'/b24ui/avatar/employee.png'}" chip size="xl" />
</template>
```

### Ориентация

Пропс `orientation` меняет ориентацию. По умолчанию `horizontal`.

```vue
<template>
  <B24User orientation="vertical" name="Иван Петров" description="Инженер-программист" :avatar="{src:'/b24ui/avatar/employee.png'}" />
</template>
```

### Ссылка

Можно передать любое свойство компонента [`<NuxtLink>`](https://nuxt.com/docs/api/components/nuxt-link), например `to`, `target`, `rel` и другие.

```vue
<template>
  <B24User to="https://github.com/bitrix24" target="_blank" name="Имя пользователя" description="Описание пользователя" :avatar="{src:'https://github.com/bitrix24.png'}" />
</template>
```

> [!NOTE]
> Компонент `NuxtLink` наследует все остальные атрибуты, которые вы передали компоненту `User`.

## API

### Пропсы

```ts
/**
 * Props for the User component
 */
interface UserProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  name?: string | undefined;
  description?: string | undefined;
  avatar?: Omit<AvatarProps, "size"> & { [key: string]: any; } | undefined;
  /**
   * Default `color` for the inner `B24Avatar`. A non-`undefined` `avatar.color` overrides it.
   */
  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 | Omit<ChipProps, "size" | "inset"> | undefined;
  /**
   * @default 'md'
   */
  size?: "md" | "3xs" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | undefined;
  /**
   * The orientation of the user.
   * @default 'horizontal'
   */
  orientation?: "horizontal" | "vertical" | undefined;
  to?: string | J | W | undefined;
  target?: null | "_blank" | "_parent" | "_self" | "_top" | string & {} | undefined;
  onClick?: (event: MouseEvent): void | undefined;
  b24ui?: { root?: SlotClass; wrapper?: SlotClass; name?: SlotClass; description?: SlotClass; avatar?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the User component
 */
interface UserSlots {
  avatar(): any;
  name(): any;
  description(): any;
  default(): any;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    user: {
      slots: {
        root: 'relative group/user',
        wrapper: '',
        name: 'font-(--ui-font-weight-medium)',
        description: 'text-description',
        avatar: 'shrink-0'
      },
      variants: {
        orientation: {
          horizontal: {
            root: 'flex items-center'
          },
          vertical: {
            root: 'flex flex-col'
          }
        },
        to: {
          true: {
            name: 'text-label peer-hover:text-(--ui-color-design-selection-content) peer-focus-visible:text-(--ui-color-design-selection-content) transition-colors',
            description: 'peer-hover:text-(--ui-color-design-selection-content) peer-focus-visible:text-(--ui-color-design-selection-content) transition-colors',
            avatar: 'transform transition-transform duration-200 motion-reduce:transition-none group-hover/user:scale-115 group-has-focus-visible/user:scale-115'
          },
          false: {
            name: 'text-label',
            description: ''
          }
        },
        size: {
          '3xs': {
            root: 'gap-1',
            wrapper: 'flex items-center gap-1',
            name: 'text-(length:--ui-font-size-xs)',
            description: 'text-(length:--ui-font-size-xs)'
          },
          '2xs': {
            root: 'gap-1.5',
            wrapper: 'flex items-center gap-1.5',
            name: 'text-(length:--ui-font-size-xs)',
            description: 'text-(length:--ui-font-size-xs)'
          },
          xs: {
            root: 'gap-1.5',
            wrapper: 'flex items-center gap-1.5',
            name: 'text-(length:--ui-font-size-xs)',
            description: 'text-(length:--ui-font-size-xs)'
          },
          sm: {
            root: 'gap-2',
            name: 'text-(length:--ui-font-size-xs)',
            description: 'text-(length:--ui-font-size-xs)'
          },
          md: {
            root: 'gap-2',
            name: 'text-(length:--ui-font-size-sm)',
            description: 'text-(length:--ui-font-size-xs)'
          },
          lg: {
            root: 'gap-2.5',
            name: 'text-(length:--ui-font-size-sm)',
            description: 'text-(length:--ui-font-size-sm)'
          },
          xl: {
            root: 'gap-2.5',
            name: 'text-(length:--ui-font-size-md)',
            description: 'text-(length:--ui-font-size-sm)'
          },
          '2xl': {
            root: 'gap-3',
            name: 'text-(length:--ui-font-size-md)',
            description: 'text-(length:--ui-font-size-md)'
          },
          '3xl': {
            root: 'gap-3',
            name: 'text-(length:--ui-font-size-lg)',
            description: 'text-(length:--ui-font-size-md)'
          }
        }
      },
      defaultVariants: {
        size: 'md'
      }
    }
  }
})
```

## Sitemap

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