kliping.pro
  • Docs
  • Directory
  • Colors
  • Typeset
Docs
    • Accordion
    • Action Bar
    • Alert
    • Alert Dialog
    • Angle Slider
    • Aspect Ratio
    • Attachment
    • Avatar
    • Avatar Group
    • Badge
    • Badge Overflow
    • Banner
    • Breadcrumb
    • Bubble
    • Button
    • Button Group
    • Calendar
    • Card
    • Carousel
    • Chart
    • Checkbox
    • Checkbox Group
    • Chip
    • Circular Progress
    • Client Only
    • Collapsible
    • Color Picker
    • Color Swatch
    • Combobox
    • Combobox Advanced
    • Command
    • Compare Slider
    • Composition
    • Context Menu
    • Cropper
    • Data Grid
    • Data Table
    • Data Table Advanced
    • Date Picker
    • Dialog
    • Direction Provider
    • Drawer
    • Dropdown Menu
    • Editable
    • Empty
    • Field
    • File Upload
    • Form
    • FPS
    • Gauge
    • Hitbox
    • Hover Card
    • Input
    • Input Group
    • Input OTP
    • Item
    • Kanban
    • Kbd
    • Kbd Advanced
    • Key Value
    • Label
    • List
    • Listbox
    • Map
    • Marker
    • Marquee
    • Mask Input
    • Masonry
    • Media Player
    • Mention
    • Menubar
    • Message
    • Message Scroller
    • Native Select
    • Navigation Menu
    • Number Field
    • Pagination
    • Pending
    • Phone Input
    • Pin Input
    • Popover
    • Portal
    • Presence
    • Progress
    • QR Code
    • Questionnaire
    • Radio Group
    • Range Calendar
    • Rating
    • Relative Time Card
    • Resizable
    • Responsive Dialog
    • Scroll Area
    • Scroll Spy
    • Scroller
    • Segmented Input
    • Select
    • Selection Toolbar
    • Separator
    • Sheet
    • Sidebar
    • Skeleton
    • Slider
    • Software Purchase Card
    • Sonner
    • Sortable
    • Speed Dial
    • Spinner
    • Stack
    • Stat
    • Status
    • Stepper
    • Stepper Advanced
    • Swap
    • Switch
    • Table
    • Tabs
    • Tags Input
    • Tags Input Advanced
    • Textarea
    • Time Picker
    • Timeline
    • Toast
    • Toggle
    • Toggle Group
    • Tooltip
    • Tour
    • Typography
    • Visually Hidden
    • Visually Hidden Input

Message

PreviousNext

Menampilkan satu pesan dalam percakapan, lengkap dengan avatar, header, footer, dan perataan yang bisa diatur.

@meME
Deploying to prod real quick.
@rabbitR
It's 4:55 PM. On a Friday.
@meME
It's a one-line change.
Delivered
@rabbitR
It's always a one-line change 😭.
Alright, let me take a look.
👍
Oliver is typing...

Komponen Message menata satu pesan di dalam percakapan. Ia mengurus avatar, perataan, header, dan footer yang mengelilingi badan pesan.

Untuk aplikasi AI, komponen Message bisa Anda pakai menampilkan langkah penalaran, pemanggilan tool, dan balasan asisten.

Installation ​

pnpm dlx shadcn-vue@latest add message

Salin dan tempel kode sumber di GitHub ke project Anda.

Sesuaikan path import dengan struktur project Anda.

Usage ​

vue
<script setup lang="ts">
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Bubble, BubbleContent } from "@/components/ui/bubble"
import { Message, MessageAvatar, MessageContent } from "@/components/ui/message"
</script>

<template>
  <Message>
    <MessageAvatar>
      <Avatar>
        <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
        <AvatarFallback>CN</AvatarFallback>
      </Avatar>
    </MessageAvatar>
    <MessageContent>
      <Bubble>
        <BubbleContent>How can I help you today?</BubbleContent>
      </Bubble>
    </MessageContent>
  </Message>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Catatan: Message yang mengurus tata letak barisnya — avatar, perataan, header, dan footer. Badan pesan yang terlihat ditampilkan di dalamnya memakai Bubble.

Composition ​

Susunan berikut adalah cara membangun sebuah message:

text
Message
├── MessageAvatar
└── MessageContent
    ├── MessageHeader
    ├── Bubble
    └── MessageFooter

Pakai MessageGroup untuk menumpuk pesan berurutan dari pengirim yang sama:

text
MessageGroup
├── Message
└── Message

Features ​

  • Perataan awal dan akhir untuk baris pengirim dan penerima, lewat prop align.
  • Slot avatar yang menempel di bagian bawah pesan tanpa bertabrakan dengan footer.
  • Slot header dan footer untuk nama pengirim, status, dan aksi pesan.
  • Footer mengikuti sisi pesan; aksinya tetap sejajar pada baris align="end".
  • Pembungkus grup untuk menumpuk pesan berurutan dari pengirim yang sama.
  • Pembungkus polimorfik lewat as atau as-child.
  • Style tiap bagian bisa disesuaikan lewat prop class.

Examples ​

Avatar ​

Pakai MessageAvatar untuk menampilkan avatar di samping pesan. Isi align="end" pada pesan agar avatarnya berada di sisi akhir.

@avatarR
The build failed during dependency installation.
@avatarR
Can you share the exact error?
@avatarR
Here's the error from the logs
Something went wrong with the build. The libraries are not installed correctly. Try running the build again.
alignDescription
startAlign the message to the start of the conversation.
endAlign the message to the end of the conversation.

Grup ​

Pakai MessageGroup untuk menumpuk pesan berurutan dari pengirim yang sama. Tampilkan MessageAvatar kosong pada pesan-pesan sebelumnya supaya sejajar dengan avatar di pesan terakhir.

I checked the registry addresses.
@avatarCN
The component and example JSON now live under the UI registry.

Header dan Footer ​

Pakai MessageHeader untuk nama pengirim, dan MessageFooter untuk metadata seperti status terkirim atau sudah dibaca.

Olivia
I already checked the logs.
Send the report to the team. Ping @shadcn if you need help.
Read Yesterday

Aksi ​

Letakkan aksi tingkat pesan di dalam MessageFooter, misalnya tombol salin, coba lagi, atau umpan balik.

The install failure is coming from the workspace package.
Okay drop me a link. Taking a look...
Failed to send

Accessibility ​

Message hanyalah pembungkus tata letak. Aksesibilitasnya datang dari konten yang Anda letakkan di dalamnya.

Beri label pada aksi yang hanya berupa ikon ​

Tombol aksi di MessageFooter biasanya hanya berupa ikon, jadi berilah masing-masing sebuah aria-label.

vue
<MessageFooter>
  <Button variant="ghost" size="icon" aria-label="Copy">
    <CopyIcon />
  </Button>
</MessageFooter>
1
2
3
4
5

Pembaruan Status ​

Untuk pesan yang masih berjalan, pakai Marker dengan role="status" supaya teknologi bantu membacakan pembaruannya begitu muncul.

vue
<Message>
  <Marker role="status">
    <MarkerIcon>
      <Spinner />
    </MarkerIcon>
    <MarkerContent>Checking the logs...</MarkerContent>
  </Marker>
</Message>
1
2
3
4
5
6
7
8

API Reference ​

Semua bagian Message menghasilkan <div> secara bawaan. Pakai as untuk memilih elemen lain, atau as-child untuk menggabungkan atribut dan style komponen ke satu elemen atau komponen di dalam slot bawaannya.

Message ​

Pembungkus baris pesan.

PropTypeDefaultDescription
align"start" | "end""start"The alignment of the message in the conversation.
asstring | Component"div"The element or component to render.
as-childbooleanfalseRender the default slot as the root and merge props onto it.
classstring-Additional classes to apply to the row.

MessageGroup ​

Mengelompokkan pesan berurutan dari pengirim yang sama.

PropTypeDefaultDescription
asstring | Component"div"The element or component to render.
as-childbooleanfalseRender the default slot as the root and merge props onto it.
classstring-Additional classes to apply to the group root.

MessageAvatar ​

Slot avatar yang menempel di bagian bawah pesan. Kalau pesannya punya MessageFooter, avatarnya bergeser naik agar tetap sejajar dengan badan pesan, bukan dengan footer.

PropTypeDefaultDescription
asstring | Component"div"The element or component to render.
as-childbooleanfalseRender the default slot as the root and merge props onto it.
classstring-Additional classes to apply to the avatar wrapper.

MessageContent ​

Membungkus header, badan pesan, dan footer.

PropTypeDefaultDescription
asstring | Component"div"The element or component to render.
as-childbooleanfalseRender the default slot as the root and merge props onto it.
classstring-Additional classes to apply to the content wrapper.

MessageHeader ​

Menampilkan konten di atas pesan, misalnya nama pengirim. Mengikuti sisi pesannya.

PropTypeDefaultDescription
asstring | Component"div"The element or component to render.
as-childbooleanfalseRender the default slot as the root and merge props onto it.
classstring-Additional classes to apply to the header.

MessageFooter ​

Menampilkan konten di bawah pesan, misalnya status atau aksi. Mengikuti sisi pesannya.

PropTypeDefaultDescription
asstring | Component"div"The element or component to render.
as-childbooleanfalseRender the default slot as the root and merge props onto it.
classstring-Additional classes to apply to the footer.
PreviousMenubarNext Message Scroller

On This Page

InstallationUsageCompositionFeaturesExamplesAvatarGrupHeader dan FooterAksiAccessibilityBeri label pada aksi yang hanya berupa ikonPembaruan StatusAPI ReferenceMessageMessageGroupMessageAvatarMessageContentMessageHeaderMessageFooter
Dirilis di bawah lisensi MIT. Ditulis ulang untuk Vue dari shadcn-vue, shadcn-ui-blocks, dan shadcn-hooks. Hak cipta © 2026 Kliping