Refined UI

An opinionated, customizable superset of shadcn/ui

AgentsPrimitivesSkillsSkins
Guides
  • Overview
  • Get started
  • Shadcn compatibility
  • Architecture
  • Agent surface
Agents
  • Action Bar
  • Audio Recorder
  • Audio VisualizerBetaBeta — the props contract is close to final, but small breaking changes can still land.
  • Chat Input
  • Chat Input Attachment
  • Chat Message
  • Chat Scene
  • Code Block Editor
  • Dynamic NotificationExpExperimental — the contract and the rendering can change without notice. Own the installed copy before shipping it.
  • Environment Variables
  • Inline Attachment
  • Markdown Block
  • Task List
  • Thread Rail
  • Tool Call
  • User Ask
Blocks
  • Chat
  • Theme toggle
  1. Blocks
  2. Chat
Blocks

Chat

Complete chat recipe with messages, tools, attachments, markdown, and composer.

Composition

How the block recipe nests its exported parts and installed agent primitives.

Thread recipe

The block keeps model/runtime state outside the UI and composes owned agent surfaces.

ChatBlock
├── ChatScene
│ └── ChatThread
│ ├── ChatTurn from="user"
│ │ ├── InlineAttachment
│ │ ├── ChatMessage
│ │ └── ActionBar
│ └── ChatTurn from="assistant"
│ ├── ChatThought
│ ├── ChatMessage
│ │ └── MarkdownBlock
│ └── ActionBar
└── ChatInput
└── ChatInputShell
├── ChatInputTextarea
└── ChatInputToolbar
├── ChatInputTools
└── ChatInputSubmit
Registry command
npx shadcn@latest add http://127.0.0.1:3000/r/refined/chat-block.json
See registry manifest

Usage

import { ChatBlock, type ChatBlockReply } from "@/components/refined-ui/blocks/chat";
​
type MastraTextMessageInput = {
role: "user";
content: {
format: 2;
parts: [{ type: "text"; text: string }];
};
};
​
function createMastraTextMessage(text: string): MastraTextMessageInput {
return {
role: "user",
content: {
format: 2,
parts: [{ type: "text", text }],
},
};
}
​
async function runMastraMessage(message: MastraTextMessageInput): Promise<ChatBlockReply> {
const text = message.content.parts[0].text;
const trace = "Mastra MessageFactory can map this content.format=2 message into Refined UI props.";
​
return {
assistantLabel: "Mastra",
modelLabel: "Mastra agent",
text: `Received "${text}". ${trace}`,
copyValue: `${trace}\n\n${text}`,
};
}
​
export function ChatSurface() {
return (
<ChatBlock
assistantLabel="Mastra"
modelLabel="Mastra agent"
createReply={(value) => runMastraMessage(createMastraTextMessage(value))}
/>
);
}
​

Agents used

The block command installs the recipe and these agent source files in one pass.

Block recipesrc/registry/blocks/chat.tsx
Action barsrc/registry/sources/refined/action-bar.tsxInline attachmentsrc/registry/sources/refined/inline-attachment.tsxMarkdown blocksrc/registry/sources/refined/markdown-block.tsxChat scenesrc/registry/sources/refined/chat-scene.tsx
Base UI Collapsible slotsrc/registry/sources/refined/ui/collapsible.tsx
Button slotsrc/registry/sources/refined/ui/button.tsx
Chat inputsrc/registry/sources/refined/chat-input.tsxChat messagesrc/registry/sources/refined/chat-message.tsx

On this page

  • Preview
  • Composition
  • Installation
  • Usage
  • Agents
Can you make a markdown of this note pleas

Here's the markdown version. Some handwriting is hard to read, so I marked uncertain parts with [?]. Mastra MessageFactory received content.format=2 with text parts.

MDMarkdown

Notes

Memory / Studio / Platform / Gallery

  • Design mode in foreground UI
    • Import in website / other
  • Text editor with [?] modes

Core ideas

  • Safe area for text edit
  • Resize -> mobile

Possible components / tools

  • Motion / video
  • Full-screen
  • Mini-browser
  • Animation
  • Agent slot
  • Extension
  • Demo / memory stream
  • Game slot
  • Workflow grid panel / scene / mini
  • Predefined memory for vibe

UX / Website Builder

  • You always need to branch
    • Less is more
  • Hierarchy is the key
    • Think about advanced users
    • Estimate how complex the feature is
    • Check if the user can understand it

Open Question

Should we have rules about what is beautiful design?

Ask through Mastra… type / or @
AttachMastra agent