Message
Sender-aware chat messages with avatars, headers and read receipts that arrive in sequence, built on UI SDK core.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/messageThis adds components/keyframery/message.tsx and its primitive to your project, and installs UI SDK, along with agent-content, message-scroller, which it builds on. The motion tokens are added to your global CSS the first time you install a component.
Usage
import {
Message,
MessageAvatar,
MessageContent,
MessageFooter,
MessageGroup,
MessageHeader,
} from "@/components/keyframery/message"Motion
| Move | What you see |
|---|---|
| Cascade | A new message’s header, content and footer rise in order, with its receipt last. |
| Unfold | The avatar pops into place as the first line arrives. |
Timing and springiness follow the motion style you set. To change how fast this message moves, pass speed:
<Message speed="fast">
…
</Message>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--message-face | Incoming bubble surface | --muted |
--message-muted | Sender and receipt | text-muted-foreground |
--message-font | Sender size | text-[12px] |
--message-gap | Avatar gap | gap-2.5 |
--message-turn-gap | Turn spacing | gap-4 |
--message-content-gap | Bubble spacing | gap-1 |
--message-avatar-size | Avatar size | size-8 |
API reference
Every part takes className and children, along with the props of the element it renders. The parts are rendered by UI SDK, so they also take render, to draw your own element, and a function of their state for className and style.
Message
Renders a <div>, and takes its props too.
Prop
Type
MessageGroup
Renders a <div>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
MessageAvatar: a<div>MessageContent: a<div>MessageFooter: a<div>MessageHeader: a<div>
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves between links, actions and other interactive content inside a message. |
Accessibility
Roles, keyboard and focus are declared on the component's UI SDK primitive, and state is announced through the matching ARIA attributes. More in Accessibility.
Built on UI SDK's core
UI SDK doesn't ship a message, so this one is defined with its core: one definePrimitive in components/keyframery/core/message-core.ts, with no React in it. UI SDK's adapters can render that same definition in Vue, Svelte, Solid and web components. To keep your own styling and take only the motion, import from @/components/keyframery/primitives/message.
Questions
How does the animated Message for UI SDK move?
Cascade: A new message’s header, content and footer rise in order, with its receipt last. Unfold: The avatar pops into place as the first line arrives.
Do I need Motion or Framer Motion for the animated Message?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
UI SDK has no message. How is this one built on UI SDK?
Its behaviour is one definition written with UI SDK's core (definePrimitive), in components/keyframery/core/message-core.ts. Its parts are rendered by UI SDK's adapter, so they take render, state-based class names and data-slot, like every UI SDK component.
What happens to the Message when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.
More in Chat
All componentsBubble
Chat bubbles that grow from their sender’s corner, with grouped messages, reply actions and delayed reactions, built on UI SDK core.
Message Scroller
A conversation scroller that follows new messages, preserves reading position and counts unread messages, composed from UI SDK scroll area and core.