Atoms
Message
A conversation row with avatar, alignment, header, content, and footer.
shadcn/uiBased on shadcn/ui with Formance brand styling.
Installation#
npx shadcn@latest add @formance/messageCopy and paste the following code into your project.
Update the import paths to match your project setup.
Usage#
import { Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader,} from '@/components/ui/message';<Message> <MessageAvatar> <FormanceIcon variant="emerald" size="md" /> </MessageAvatar> <MessageContent> <MessageHeader>Schema assistant</MessageHeader> <Bubble> <BubbleContent>Deposits land in bank:omnibus.</BubbleContent> </Bubble> <MessageFooter>Answered from the current schema</MessageFooter> </MessageContent></Message>Set align="end" on the messages of the current user.
Examples#
Group#
Wrap consecutive messages in MessageGroup, and consecutive bubbles of one
sender in BubbleGroup.
Avatar#
Put an Avatar in MessageAvatar. The avatar aligns to the last line of the message.
Header and footer#
Use MessageHeader for the name of the sender, and MessageFooter for a status such as the read time.
Actions#
Put icon buttons in MessageFooter. Show an error and a retry button when a message does not send.
Attachment#
Put an Attachment in MessageContent, next to the bubble.
Compound Components
Compose the pieces you need:
<Message />Root row. Set align="end" for the current user.<MessageAvatar />Avatar slot, aligned to the last line of the message.<MessageContent />Column that holds the header, bubbles, and footer.<MessageHeader />Sender name or metadata above the content.<MessageFooter />Status or metadata below the content.<MessageGroup />Stacks consecutive messages.