Customize vue-advanced-chat using Named Slots
mainYou can customize the appearance and behavior of vue-advanced-chat by providing custom templates via named slots. Slots can be static (e.g., room-header) or dynamic, requiring specific IDs for rooms or messages (e.g., message_{{MESSAGE_ID}}).
Common slot categories include:
- Layout & Headers:
rooms-header,room-header,no-room-selected,messages-empty. - List Items:
room-list-item_{{ROOM_ID}},room-list-avatar_{{ROOM_ID}},room-list-info_{{ROOM_ID}}. - Messages:
message_{{MESSAGE_ID}},message-avatar_{{MESSAGE_ID}},message-failure_{{MESSAGE_ID}}. - Icons:
send-icon,paperclip-icon,search-icon,menu-icon, and various spinner icons likespinner-icon-messages. - Empty States:
rooms-empty,messages-empty.
<vue-advanced-chat>
<div slot="room-header">
This is a new room header
</div>
<div v-for="message in messages" :slot="'message_' + message._id">
<div v-if="message.system">
System message: {{ message.content }}
</div>
<div v-else>
Normal message: {{ message.content }}
</div>
</div>
<div v-for="message in messages" :slot="'message-avatar_' + message._id">
New Avatar
</div>
</vue-advanced-chat>