export const title = "Messaging components"
export const description = "Powerful and customizable React messaging components built for modern applications and websites. These messaging components are built using React Aria and styled with Tailwind CSS."
import * as Demos from "@/components/application/messaging/messaging.story.tsx";
## Installation
Messaging component depends on other components to function properly. Before using them, make sure to add the required components via CLI.
Use the following command to install them:
```bash
npx untitledui@latest add messaging
```
Copy the files below into your project:
Great! Now you can start using the messaging components in your project by just copy/pasting our examples below.
## Message status
In order to display the message status separately, you can use the `MessageStatus` component. It accepts the `status` prop which can be one of the following:
- `sent`
- `read`
- `failed`
Optionally, you can also pass the `readAt` prop to display the date and time when the message was read.
## Message action examples
Below are examples and variations of this message action component:
### Message action minimal {{ tocOnly:true }}
### Message action textarea {{ tocOnly:true }}
### Message action advanced {{ tocOnly:true }}
## Message examples
Below are examples and variations of this message component:
### Message simple {{ tocOnly:true }}
### Message reactions {{ tocOnly:true }}
### Message reply {{ tocOnly:true }}
### Message attachment {{ tocOnly:true }}
### Message audio {{ tocOnly:true }}
### Message image {{ tocOnly:true }}
### Message link preview {{ tocOnly:true }}
### Message link minimal {{ tocOnly:true }}
### Message writing {{ tocOnly:true }}
## API reference
`, map your messages inside your own `` or `` and give that list an `aria-label` such as `\"Conversation\"`.",
},
{
question: "How do I show a message as sent by the current user?",
answer: "Set `me: true` inside the message's `user` object. The bubble then aligns to the right with `self-end`, uses the primary background with a squared top-right corner, and the sender label reads \"You\" instead of `user.name`. Avatars are only rendered for messages from other people.",
},
{
question: "How do I display sent and read receipts?",
answer: "Set `status` on the message to `\"sent\"`, `\"read\"` or `\"failed\"` and the status icon renders next to the timestamp. Add `readAt` and it is appended to the tooltip on a read message. You can also render the indicator on its own with `` — the message status example above renders all three states that way.",
},
{
question: "Can messages contain images, files or voice notes?",
answer: "Yes. Pass `image` as `{ src, alt, name, size }`, `attachment` as `{ name, size, type }` where `type` is one of `\"jpg\"`, `\"txt\"`, `\"pdf\"` or `\"mp4\"` (it selects the file icon), and `audio` as `{ duration }`, which renders a waveform with a play button. `size` and `duration` are display strings, not raw byte counts, and the audio playback button is a UI shell — wire up your own player.",
},
{
question: "How do I show a typing indicator?",
answer: "Add an entry with `typing: true` and no `text` or other content, since any content would still render above the dots. `MessageItem` renders the animated three-dot bubble and hides the timestamp and status for that entry; the sender label still shows unless you set `showUserLabel={false}`.",
},
{
question: "How do I hide the repeated sender name on consecutive messages?",
answer: "Pass `showUserLabel={false}` to `MessageItem`. It defaults to `true`, so a common pattern is to only show the label on the first message in a run from the same sender.",
},
{
question: "How do I read what the user typed in the composer?",
answer: "The composers are example code rather than exported components — `MessageActionMinimal`, `MessageActionTextarea` and `MessageActionAdvanced` live in `message-action.demo.tsx`, so copy the one you want into your own project rather than importing it as part of the API. All three are uncontrolled forms with a field named `message`: they accept an `onSubmit` callback that is called with the message string after the form's default submission is prevented, and `MessageActionMinimal` additionally accepts a `size` of `\"sm\"`, `\"md\"` or `\"lg\"`, defaulting to `\"lg\"`.",
},
]}
/>