Skip to content

Chat Message ​

ue-chat-message renders a single chat message bubble with an avatar, sender name, timestamp, message content (with URL linkification), and optional attachment previews. Messages from the current user are displayed right-aligned with reverse.

Usage ​

html
<ue-chat-message
  v-model="message"
  update-endpoint="/api/messages/:id"
  :reverse="message.user_id === currentUserId"
/>

Props ​

PropTypeDefaultDescription
modelValueObjectrequiredMessage object (see Message Shape below)
updateEndpointStringrequiredAPI endpoint called when the user toggles starring or pinning
reverseBooleanfalseAlign the bubble to the right (current user's own messages)
avatarSizeNumber40Avatar size in pixels on desktop
mobileAvatarSizeNumber20Avatar size in pixels on mobile
noStarringBooleanfalseHide the star/unstar icon
noPinningBooleanfalseHide the pin/unpin icon
contentTruncateLengthNumber50Characters shown before a "Show more" toggle appears

Message Shape ​

js
{
  id: 1,
  content: 'Hello, world!',
  created_at: '2024-01-15T10:30:00Z',
  is_read: false,
  is_starred: false,
  is_pinned: false,
  user_profile: {
    name: 'Alice',
    avatar_url: '/avatars/alice.jpg',
  },
  attachments: [], // array of filepond file objects
}

Behaviour ​

  • Long messages are truncated to contentTruncateLength characters with a "Show more / Show less" toggle.
  • URLs in message content are auto-linkified via ue-well-print.
  • Attachments are rendered with ue-filepond-preview using image-size="24".
  • Unread messages (where is_read is falsy and reverse is false) receive a visual highlight.
  • Starring and pinning patch the message via updateEndpoint and update the modelValue optimistically.