v2.1.8
/
  • Get Started
  • Components
  • Composables
  • Typography
  • GitHub
  • Layout
  • App
  • Container
  • Error
  • SidebarLayout
  • Element
  • Advice
  • Alert
  • Avatar
  • AvatarGroup
  • Badge
  • Banner
  • Button
  • Calendar
  • Card
  • Chip
  • Collapsible
  • Countdown
  • FieldGroup
  • Kbd
  • Progress
  • Separator
  • Skeleton
  • Form
  • Checkbox
  • CheckboxGroup
  • ColorPicker
  • FileUpload
  • Form
  • FormField
  • Input
  • InputDate
  • InputMenu
  • InputNumber
  • InputTags
  • InputTime
  • PinInput
  • RadioGroup
  • Range
  • Select
  • SelectMenu
  • Switch
  • Textarea
  • Data
  • Accordion
  • DescriptionList
  • Empty
  • Table
  • TableWrapper
  • Timeline
  • User
  • Navigation
  • Breadcrumb
  • CommandPalette
  • Link
  • NavigationMenu
  • Pagination
  • Stepper
  • Tabs
  • Overlay
  • ContextMenu
  • DropdownMenu
  • Modal
  • Popover
  • Slideover
  • Toast
  • Tooltip
  • Page
  • PageCard
  • PageColumns
  • PageGrid
  • PageLinks
  • PageList
  • Dashboard
  • DashboardGroup
  • DashboardSearch
  • DashboardSearchButton
  • AI Chat
  • soonChatMessage
  • soonChatMessages
  • soonChatPalette
  • soonChatPrompt
  • soonChatPromptSubmit
  • Content
  • ContentSearch
  • ContentSearchButton
  • ContentSurround
  • ContentToc
  • Color Mode
  • ColorModeAvatar
  • ColorModeButton
  • ColorModeImage
  • ColorModeSelect
  • ColorModeSwitch
  • i18n
  • LocaleSelect
  • b24icons
  • b24jssdk
Use our Nuxt starter
v2.1.8
  • Docs
  • Components
  • Composables
  • Typography

ChatMessage

A chat message component with icon, avatar, and action buttons.
GitHub
Nuxt UI
We are still updating this page. Some data may be missing here — we will complete it shortly.

Usage 2.2+

The ChatMessage component renders an <article> element for a user or assistant chat message.

Hello! Tell me more about building AI chatbots with Bitrix24 UI.
Use the ChatMessages component to display a list of chat messages.

Parts

Use the parts prop to display the message content using the AI SDK v5 format.

Hello! Tell me more about building AI chatbots with Bitrix24 UI.
{
  "wait": "Loading client-side content..."
}
The parts prop is the recommended format for AI SDK v5. Each part has a type (e.g., 'text') and corresponding content.

Side

Use the side prop to display the message on the left or right.

Hello! Tell me more about building AI chatbots with Bitrix24 UI.
{
  "wait": "Loading client-side content..."
}
When using the ChatMessages component, the side prop is set to left for assistant messages and right for user messages.

Variant

Use the variant prop to change style of the message.

Hello! Tell me more about building AI chatbots with Bitrix24 UI.
{
  "wait": "Loading client-side content..."
}
When using the ChatMessages component, the variant prop is set to message for assistant messages and message for user messages.

Icon

Use the icon prop to display an Icon component next to the message.

Hello! Tell me more about building AI chatbots with Bitrix24 UI.
{
  "wait": "Loading client-side content..."
}

Avatar

Use the avatar prop to display an Avatar component next to the message.

Hello! Tell me more about building AI chatbots with Bitrix24 UI.
{
  "wait": "Loading client-side content..."
}

You can also use the avatar.icon prop to display an icon as the avatar.

Bitrix24 UI offers several features for building AI chatbots including the ChatMessage, ChatMessages, and ChatPrompt components. Best practices include using the Chat class from AI SDK v5, implementing proper message styling with variants, and utilizing the built-in actions for message interactions. The components are fully customizable with theming support and responsive design.
{
  "wait": "Loading client-side content..."
}

Actions

Use the actions prop to display actions below the message that will be displayed when hovering over the message.

Bitrix24 UI offers several features for building AI chatbots including the ChatMessage, ChatMessages, and ChatPrompt components. Best practices include using the Chat class from AI SDK v5, implementing proper message styling with variants, and utilizing the built-in actions for message interactions. The components are fully customizable with theming support and responsive design.
{
  "wait": "Loading client-side content..."
}

API

Props

Prop Default Type
as'article'any

The element or component this component should render as.

idstring

A unique identifier for the message.

role"system" | "user" | "assistant"

The role of the message.

partsUIMessagePart<UIDataTypes, UITools>[]

The parts of the message. Use this for rendering the message in the UI.

System messages should be avoided (set the system prompt on the server instead). They can have text parts.

User messages can have text parts and file parts.

Assistant messages can have text, reasoning, tool invocation, and file parts.

  • type: "text"
  • text: string

    The text content.

  • state?: "done" | "streaming"

    The state of the text part.

  • providerMetadata?: SharedV2ProviderMetadata

    The provider metadata.

  • toolName: string

    Name of the tool that is being called.

  • toolCallId: string

    ID of the tool call.

  • title?: string
  • providerExecuted?: boolean

    Whether the tool call was executed by the provider.

  • input: unknown
  • output?: undefined
  • errorText?: undefined
  • callProviderMetadata?: SharedV2ProviderMetadata
  • preliminary?: boolean
  • sourceId: string
  • url: string
  • mediaType: string
  • filename?: string
  • rawInput?: unknown
  • id?: string
  • data: unknown
iconIconComponent
avatar AvatarProps & { [key: string]: any; }
  • as?: any

    The element or component this component should render as. Defaults to 'span'.

  • src?: string
  • alt?: string
  • icon?: IconComponent

    Display an icon on the left side.

  • text?: string
  • size?: "2xs" | "md" | "3xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl"

    Defaults to 'md'.

  • chip?: boolean | ChipProps
  • class?: any
  • style?: any
  • b24ui?: { root?: ClassNameValue; image?: ClassNameValue; fallback?: ClassNameValue; icon?: ClassNameValue; }
  • crossorigin?: "" | "anonymous" | "use-credentials"
  • decoding?: "async" | "auto" | "sync"
  • height?: Numberish
  • loading?: "lazy" | "eager"
  • referrerpolicy?: HTMLAttributeReferrerPolicy
  • sizes?: string
  • srcset?: string
  • usemap?: string
  • width?: Numberish
variant'message' "message" | "event" | "system"
side'left' "left" | "right"
actions (Omit<ButtonProps, "onClick"> & { onClick?: ((e: MouseEvent, message: UIMessage<unknown, UIDataTypes, UITools>) => void) | undefined; })[]

Display a list of actions under the message. The label will be used in a tooltip. { size: 'sm', color: 'air-secondary-no-accent' }

  • as?: any

    The element or component this component should render as when not a link. Defaults to 'button'.

  • icon?: IconComponent

    Display an icon on the left side.

  • avatar?: AvatarProps

    Display an avatar on the left side.

  • class?: any
  • b24ui?: { base?: ClassNameValue; baseLoading?: ClassNameValue; baseLoadingWaitIcon?: ClassNameValue; baseLoadingClockIcon?: ClassNameValue; baseLoadingSpinnerIcon?: ClassNameValue; baseLine?: ClassNameValue; label?: ClassNameValue; labelInner?: ClassNameValue; leadingIcon?: ClassNameValue; leadingAvatar?: ClassNameValue; leadingAvatarSize?: ClassNameValue; trailingIcon?: ClassNameValue; safeList?: ClassNameValue; }
  • type?: "reset" | "submit" | "button"

    The type of the button when not a link. Defaults to 'button'.

  • loading?: boolean

    When true, the loading icon will be displayed.

  • referrerpolicy?: HTMLAttributeReferrerPolicy
  • to?: string | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric

    Route Location the link should navigate to when clicked on.

  • autofocus?: Booleanish
  • disabled?: boolean
  • name?: string
  • download?: any
  • hreflang?: string
  • media?: string
  • ping?: string
  • target?: (string & {}) | "_blank" | "_parent" | "_self" | "_top" | null

    Where to display the linked URL, as the name for a browsing context.

  • active?: boolean

    Force the link to be active independent of the current route.

  • isAction?: boolean

    When true, uses special underlined styling.

  • trailingSlash?: "append" | "remove"

    An option to either add or remove trailing slashes in the href for this specific link. Overrides the global trailingSlash option if provided.

  • label?: string
  • 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"

    Defaults to 'air-secondary-no-accent'.

  • "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" | "activeColor?: air-primary" | "link"
  • depth?: "light" | "normal" | "dark"

    Defaults to 'normal'.

  • activeDepth?: "light" | "normal" | "dark"
  • size?: "md" | "xs" | "sm" | "lg" | "xl" | "xss"

    Defaults to 'md'.

  • rounded?: boolean

    Rounds the corners of the button Defaults to false.

  • block?: boolean

    Render the button full width Defaults to false.

  • loadingAuto?: boolean

    Set loading state automatically based on the @click promise state Defaults to false.

  • normalCase?: boolean

    Disable uppercase label Defaults to true.

  • useWait?: boolean

    Shows LoaderWaitIcon in loading mode Defaults to false.

  • useClock?: boolean

    Shows LoaderClockIcon icon in loading mode Defaults to false.

  • useDropdown?: boolean

    Shows icons.ChevronDownSIcon on the right side Defaults to false.

compactfalseboolean

Render the message in a compact style. This is done automatically when used inside a UChatPalette.

metadataunknown

The metadata of the message.

b24ui { root?: ClassNameValue; container?: ClassNameValue; leading?: ClassNameValue; leadingIcon?: ClassNameValue; leadingAvatar?: ClassNameValue; leadingAvatarSize?: ClassNameValue; content?: ClassNameValue; actions?: ClassNameValue; }

Slots

Slot Type
leading{ avatar: (AvatarProps & { [key: string]: any; }) | undefined; b24ui: object; }
contentChatMessageProps
actions{ actions: (Omit<ButtonProps, "onClick"> & { onClick?: ((e: MouseEvent, message: UIMessage<unknown, UIDataTypes, UITools>) => void) | undefined; })[] | undefined; }

Theme

app.config.ts
export default defineAppConfig({
  b24ui: {
    chatMessage: {
      slots: {
        root: 'group/message relative w-full',
        container: 'relative flex items-start',
        leading: 'inline-flex items-center justify-center min-h-6',
        leadingIcon: 'shrink-0 text-(--ui-color-design-plain-content-icon-secondary)',
        leadingAvatar: 'shrink-0',
        leadingAvatarSize: '',
        content: 'relative text-pretty min-w-0 *:first:mt-0 *:last:mb-0',
        actions: 'opacity-0 group-hover/message:opacity-100 absolute bottom-0 flex items-center transition-opacity'
      },
      variants: {
        variant: {
          message: {
            content: 'bg-inverted text-inverted'
          },
          event: {
            content: 'bg-default ring ring-default'
          },
          system: {
            content: 'bg-elevated/50'
          }
        },
        side: {
          left: {
            container: 'rtl:justify-end'
          },
          right: {
            container: 'ltr:justify-end ms-auto max-w-[75%]'
          }
        },
        leading: {
          true: ''
        },
        actions: {
          true: ''
        },
        compact: {
          true: {
            root: 'scroll-mt-3',
            container: 'gap-1.5 pb-3',
            leadingIcon: 'size-5',
            leadingAvatarSize: '2xs'
          },
          false: {
            root: 'scroll-mt-4 sm:scroll-mt-6',
            container: 'gap-3 pb-8',
            leadingIcon: 'size-8',
            leadingAvatarSize: 'md'
          }
        }
      },
      compoundVariants: [
        {
          compact: true,
          actions: true,
          class: {
            container: 'pb-8'
          }
        },
        {
          leading: true,
          compact: false,
          side: 'left',
          class: {
            actions: 'left-11'
          }
        },
        {
          leading: true,
          compact: true,
          side: 'left',
          class: {
            actions: 'left-6.5'
          }
        },
        {
          variant: [
            'message',
            'event',
            'system'
          ],
          compact: false,
          class: {
            content: 'px-4 py-3 rounded-lg min-h-12',
            leading: 'mt-2'
          }
        },
        {
          variant: [
            'message',
            'event',
            'system'
          ],
          compact: true,
          class: {
            content: 'px-2 py-1 rounded-lg min-h-8',
            leading: 'mt-1'
          }
        },
        {
          variant: 'message',
          side: 'left',
          class: {
            content: 'w-full'
          }
        }
      ],
      defaultVariants: {
        variant: 'message'
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'

export default defineConfig({
  plugins: [
    vue(),
    bitrix24UIPluginVite({
      b24ui: {
        chatMessage: {
          slots: {
            root: 'group/message relative w-full',
            container: 'relative flex items-start',
            leading: 'inline-flex items-center justify-center min-h-6',
            leadingIcon: 'shrink-0 text-(--ui-color-design-plain-content-icon-secondary)',
            leadingAvatar: 'shrink-0',
            leadingAvatarSize: '',
            content: 'relative text-pretty min-w-0 *:first:mt-0 *:last:mb-0',
            actions: 'opacity-0 group-hover/message:opacity-100 absolute bottom-0 flex items-center transition-opacity'
          },
          variants: {
            variant: {
              message: {
                content: 'bg-inverted text-inverted'
              },
              event: {
                content: 'bg-default ring ring-default'
              },
              system: {
                content: 'bg-elevated/50'
              }
            },
            side: {
              left: {
                container: 'rtl:justify-end'
              },
              right: {
                container: 'ltr:justify-end ms-auto max-w-[75%]'
              }
            },
            leading: {
              true: ''
            },
            actions: {
              true: ''
            },
            compact: {
              true: {
                root: 'scroll-mt-3',
                container: 'gap-1.5 pb-3',
                leadingIcon: 'size-5',
                leadingAvatarSize: '2xs'
              },
              false: {
                root: 'scroll-mt-4 sm:scroll-mt-6',
                container: 'gap-3 pb-8',
                leadingIcon: 'size-8',
                leadingAvatarSize: 'md'
              }
            }
          },
          compoundVariants: [
            {
              compact: true,
              actions: true,
              class: {
                container: 'pb-8'
              }
            },
            {
              leading: true,
              compact: false,
              side: 'left',
              class: {
                actions: 'left-11'
              }
            },
            {
              leading: true,
              compact: true,
              side: 'left',
              class: {
                actions: 'left-6.5'
              }
            },
            {
              variant: [
                'message',
                'event',
                'system'
              ],
              compact: false,
              class: {
                content: 'px-4 py-3 rounded-lg min-h-12',
                leading: 'mt-2'
              }
            },
            {
              variant: [
                'message',
                'event',
                'system'
              ],
              compact: true,
              class: {
                content: 'px-2 py-1 rounded-lg min-h-8',
                leading: 'mt-1'
              }
            },
            {
              variant: 'message',
              side: 'left',
              class: {
                content: 'w-full'
              }
            }
          ],
          defaultVariants: {
            variant: 'message'
          }
        }
      }
    })
  ]
})

DashboardSearchButton

A pre-styled button that opens the Dashboard Search modal.

ChatMessages

A chat messages list component designed for seamless integration with the Vercel AI SDK.

On this page

  • Usage
    • Parts
    • Side
    • Variant
    • Icon
    • Avatar
    • Actions
  • API
    • Props
    • Slots
  • Theme
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24