published fresh until

shadcn: how do I get my agent to build a chat UI with its components?

Summary As of November 2026, the shadcn chat rule composes MessageScroller, Message, Bubble, Attachment, Marker, Trace and CodeBlock. Preserve its nesting and enable live-edge following with autoScroll

Not for shadcn form validation; see shadcn-field-react-hook-form-zod-form

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, use shadcn’s MessageScroller composition for streaming chat. Do first: follow the nesting in the Message Scroller docs, then install the parts named in the chat rule.

The problem

Left alone, agents build a chat screen from a div with overflow-y-auto, manual scroll-to-bottom code and bg-primary bubbles. It tends to jump while streaming and is hard to restyle.

What the source says

The shadcn skill in shadcn-ui/ui (MIT) has a chat rule. Its install line: npx shadcn@latest add message-scroller message bubble attachment marker trace code-block. Its rules:

  • A scrolling conversation uses MessageScroller (provider, viewport, content, items, a jump button); every direct child of the content is wrapped in a MessageScrollerItem. Not a raw overflow container, not ScrollArea.
  • A message row is Message with align="end" for the current user; group rows from one sender with MessageGroup.
  • The coloured surface is Bubble plus BubbleContent, never a div with bg-muted; reactions use BubbleReactions.
  • File cards are Attachment, with state wired to the real upload status.
  • Status lines and date dividers are Marker.
  • What an assistant did (reasoning, tool calls, sources) is a TraceLine inside a Trace; a pending approval is rendered outside the trace as an item with Approve and Deny.
  • Code and tool output use CodeBlock. Streaming, anchoring and jump-to-latest are said to be built in.

The skill's allowed-tools permits npx shadcn@latest CLI commands.

How to describe it to the agent

Build the support chat screen using the shadcn skill's chat rule. Use MessageScrollerProvider with autoScroll around MessageScroller, Message and Bubble for rows (align end for the user), Marker for the date divider, Attachment for uploads and Trace for tool steps. Do not hand-roll scrolling or bubbles. Show me the component tree before writing styles.

Mistakes to check

  • The old overflow-div pattern is still in the file after the agent adds the new components.
  • Items are not wrapped in MessageScrollerItem, so anchoring breaks.
  • Approvals shown as trace rows.

Limits

This is a UI shell: it does not call a model. autoScroll follows the live edge and releases when the reader scrolls away; returning with the jump button resumes following (scroll behavior).

Sources

Started from a post by @shadcn/ui maintainers, packaged by the editor. Original post

Subjects

More in agent skills

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# shadcn: how do I get my agent to build a chat UI with its components?
Summary: As of November 2026, the shadcn chat rule composes MessageScroller, Message, Bubble, Attachment, Marker, Trace and CodeBlock. Preserve its nesting and enable live-edge following with `autoScroll`
Copy for agent
get the whatworks thread shadcn-chat-ui-message-scroller-rule and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread shadcn-chat-ui-message-scroller-rule
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks