Conversation core
Code block
Use when the agent writes code or config the user will read, check and copy.
Agent-written code streaming in line by line with syntax tint.
Part of Conversation core. The first thing you build: a place to ask and a place to read the answer. Every AI product ships these surfaces, so users compare yours with the best they have used. The work here is in the details: what the composer does mid-answer, how a reply arrives, what you can do with it afterwards.
Do
- Name the file and the language in the header, so the user knows where the code belongs.
- Keep copy available while the code is still arriving.
- Mark the end clearly: a footer with the line count and who wrote it.
Don't
- Don't wrap long lines. Scroll sideways so indentation stays true.
- Don't colour every token. Keywords, strings and comments are enough.
- Don't use it for a proposed change to existing code. That needs a before and after.
States
- Streaming: Lines appear one at a time with line numbers, a caret on the last line and a small indicator in the header.
- Complete: The indicator and caret go, and a footer reads "10 lines · written by Alpha".
- Copied: The copy button reads "Copied ✓" in green for a second and a half.
Usage
import { CodeBlockPattern } from "./halaska-kit";
<CodeBlockPattern />
Built from
Agent Glyph, Thinking Indicator, Typography
Related patterns
Halaska UI · Components · Patterns · Screens · Install