Компоненты
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Calendar
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Date Picker
- Dialog
- DrawerNew
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Meter
- Number Field
- OTP FieldNew
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
AI Components
- AI Components
- Chat Conversation
- Chat Message
- Chat Response
- Chat Suggestion
- Chat Prompt Input
- Chat Attachments
- Chat Code Block
- Chat Image
- Chat Inline Citation
- Chat Reasoning
- Chat Sources
- Chat Actions
- Chat Context
- Chat Loader
- Chat Task
- Chat Tool
- Chat Web Preview
- Chat Snippet
- Chat Terminal
- Chat Stack Trace
- Chat Test Results
- Chat File Tree
- Chat Environment Variables
- Chat Audio Player
- Chat Transcription
- Chat Speech Input
- Chat Mic Selector
- Chat Voice Selector
- Chat Agent
- Chat Persona
- Chat Connection
- Chat Queue
- Chat Checkpoint
- Chat Confirmation
- Chat Artifact
- Chat JSX Preview
- Chat Schema Display
- Chat Package Info
- Chat Commit
- Chat Plan
- Chat Panel
- Chat Open In Chat
- Chat Sandbox
- Chat Model Selector
- Chat Canvas
- Chat Node
- Chat Edge
Resources
Chat Code Block
Самостоятельный блок кода с подсветкой shiki, header, copy и line numbers.
Chat.tsx
import { ChatConversation, ChatConversationContent } from "@/components/ui/chat-conversation";import { ChatMessage, ChatMessageContent } from "@/components/ui/chat-message";
export function Chat({ messages }) { return ( <ChatConversation> <ChatConversationContent> {messages.map((m) => ( <ChatMessage from={m.role} key={m.id}> <ChatMessageContent>{m.content}</ChatMessageContent> </ChatMessage> ))} </ChatConversationContent> </ChatConversation> );}import {
ChatCodeBlock,
ChatCodeBlockActions,
ChatCodeBlockCopyButton,
ChatCodeBlockFilename,
ChatCodeBlockHeader,
} from "@/components/ui/chat-code-block";
const snippet = `import { ChatConversation, ChatConversationContent } from "@/components/ui/chat-conversation";
import { ChatMessage, ChatMessageContent } from "@/components/ui/chat-message";
export function Chat({ messages }) {
return (
<ChatConversation>
<ChatConversationContent>
{messages.map((m) => (
<ChatMessage from={m.role} key={m.id}>
<ChatMessageContent>{m.content}</ChatMessageContent>
</ChatMessage>
))}
</ChatConversationContent>
</ChatConversation>
);
}`;
export default function Particle() {
return (
<div className="w-full max-w-2xl p-4">
<ChatCodeBlock code={snippet} language="tsx" showLineNumbers>
<ChatCodeBlockHeader>
<ChatCodeBlockFilename>Chat.tsx</ChatCodeBlockFilename>
<ChatCodeBlockActions>
<ChatCodeBlockCopyButton />
</ChatCodeBlockActions>
</ChatCodeBlockHeader>
</ChatCodeBlock>
</div>
);
}
Installation
pnpm dlx shadcn@latest add @jenny/chat-code-block
Подсветка через shiki (lazy-loaded — грамматика подгружается при первом рендере языка).
Usage
import {
ChatCodeBlock,
ChatCodeBlockActions,
ChatCodeBlockCopyButton,
ChatCodeBlockFilename,
ChatCodeBlockHeader,
} from "@/components/ui/chat-code-block";
<ChatCodeBlock
code={tsxSnippet}
language="tsx"
showLineNumbers
>
<ChatCodeBlockHeader>
<ChatCodeBlockFilename>App.tsx</ChatCodeBlockFilename>
<ChatCodeBlockActions>
<ChatCodeBlockCopyButton />
</ChatCodeBlockActions>
</ChatCodeBlockHeader>
</ChatCodeBlock>Когда использовать vs ChatResponse
ChatResponse— целое сообщение с markdown, code blocks внутри прокидываются автоматически через streamdown.ChatCodeBlock— самостоятельный блок (например, артефакт от tool-call или код в side-panel), которому нужны copy-кнопка и filename-header.
API
| Prop | Описание |
|---|---|
code | Исходник как строка. |
language | shiki BundledLanguage (tsx, python, rust, …). |
showLineNumbers | Включает CSS-counter с номерами строк. |