Prodular UI

AI

Code blockAI

Monospaced code with an optional title, copy button, line numbers and diff lines. Used by Response and Tool Call.

npx prodular-ui add code-block

With title and copy

Line numbers for code people will discuss. The destructive variant is for error output.

unpaid-due-soon.sql
select vendor, sum(amount) as totalfrom ap_invoiceswhere status = 'unpaid'  and due_date < current_date + interval '14 days'group by vendororder by total desc;
ERROR: column "due_date" does not exist. Did you mean "due_on"?

Diff

Added and removed lines for changes an agent proposes.

infra/s3.tf
resource "aws_s3_bucket_lifecycle_configuration" "events_raw" {  rule {    id     = "expire-raw-events"    status = "Disabled"    status = "Enabled"    expiration {      days = 90    }  }}

Anatomy

<CodeBlock>  <CodeBlockHeader>    <CodeBlockTitle>query.sql</CodeBlockTitle>    <CodeBlockActions><CodeBlockCopyButton value={code} /></CodeBlockActions>  </CodeBlockHeader>  <CodeBlockContent>{code}</CodeBlockContent></CodeBlock>

Guidance

Use it when

  • For code, queries, config and logs in answers and tool output.
  • The ghost variant inside another container, such as a tool call, so it adds no second box.

Avoid

  • Code blocks for one short command inside a sentence. Use inline code.
  • Line numbers on snippets under five lines.

Rules for AI agents

Published in llms-full.txt and the registry, so coding agents follow them when they build with this component.

  • Always include CodeBlockCopyButton with the exact code as value.
  • Use variant="ghost" when the code sits inside a Card, ToolCall or Popover.
  • Use CodeBlockLine with variant added or removed for proposed changes, and lineNumbers with startLine to match the real file.
  • Do not hand write code blocks in Response. Fenced markdown becomes a CodeBlock automatically.

API

CodeBlock

PropTypeDefaultDescription
variant"default" | "ghost" | "destructive""default"Bordered, borderless or error.
size"default" | "sm""default"Text and padding.

CodeBlockContent

PropTypeDefaultDescription
lineNumbers / startLine / wrapboolean, number, booleanNumbering and wrapping.

CodeBlockLine

PropTypeDefaultDescription
variant"default" | "added" | "removed" | "highlighted"Diff and highlight lines.

CodeBlockCopyButton

PropTypeDefaultDescription
valuestringText copied to the clipboard.