shadcn.io is not affiliated with official shadcn/ui
Scroll Area examples · Layout
Chat Messages Scroll Area for React
A chat message list in a fixed-height scroll area, with avatars, names and timestamps.
Chat interfaces live or die by their scrolling. This example stacks eight messages in a 400px Scroll Area, each with an Avatar (image and initials fallback), the sender's name, a timestamp, and the text. The conversation scrolls inside its border while the page stays still. Use it for chat widgets, comment threads, activity feeds, and other lists of messages people scroll back through.
Preview
Installation
FAQ
What height is the message list?
ScrollArea is h-[400px], with rounded-md border bg-background. Eight messages scroll inside that box. The wrapper around the area is w-full max-w-md.
How is one message laid out?
A row with flex gap-3. Avatar is first. The name, time, and text stack in flex-1 with gap-1. The name and time share a row with flex items-baseline gap-2.
What does the avatar show?
AvatarImage uses alt set to the sender's name and src set to their image. AvatarFallback is the initials, such as HB or SC. Avatar leaves size at the default.
How are the name and time styled?
The name is a span with font-semibold text-sm. The time is a span with text-xs text-muted-foreground, a clock time such as 10:30 AM. The message is a p with text-sm.
Related
- Fixed Height ScrollArea Scroll AreaA notification list in a 200px scroll
- Dynamic Content Scroll AreaA scroll area whose list grows with a
- Scrollable Tags Scroll AreaA row of technology badges in a
- Avatar StandardA round avatar with a profile picture and
- Basic ScrollArea Scroll AreaA basic vertical scroll area for long
- Standard CardA basic card with a title, a description