Shows a block of code with a header, copy, and line numbers.
import { Button } from "@/components/vip-ui/button"; export function SaveButton() { const save = () => saveChanges(); return <Button onPress={save}>Save changes</Button>;}The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
CodeBlockOwns the code, the wrap state, and the expanded state.
CodeBlockHeaderOptionalCodeBlockTitleOptionalCodeBlockActionsOptionalCodeBlockWrapOptionalCodeBlockCopy
CodeBlockBodyPass highlighter output as children. Without children, it shows the code as plain text.
import { NextResponse } from "next/server";import { listProjects } from "@/lib/projects"; export async function GET() { const projects = await listProjects(); const active = projects.filter((project) => project.status === "active"); return NextResponse.json(active);}Set maxLines to collapse long code.
curl --request POST "https://api.atlas.dev/v2/projects/atlas-2026/events?include=members,invites,activity&expand=owner,plan" --header "Authorization: Bearer $ATLAS_TOKEN" --data '{"name":"Invite sent","source":"dashboard"}'Pass the output of your highlighter as the children of CodeBlockBody.
import { useState } from "react";
import { Button } from "@/components/vip-ui/button";
export function PublishButton() {
const [publishing, setPublishing] = useState(false);
return (
<Button
isPending={publishing}
onPress={() => {
setPublishing(true);
publish().finally(() => setPublishing(false));
}}
>
Publish release
</Button>
);
}Set isStreaming while the code arrives. Also install Response and Button.
Here is the route handler for project search.
import { NextResponse } from "next/server";CodeBlock
- code: stringRequired
- The code text. The copy button writes it as given.
- language: string
- The language name. It shows in the default header when you do not render a title.
- lineNumbers: boolean = true
- Shows a gutter with line numbers. The numbers are not copied or selected. Ignored when you pass children.
- highlight: number[]
- Highlights these 1-based line numbers. Ignored when you pass children.
- wrap: boolean
- Wraps long lines, controlled.
- defaultWrap: boolean = false
- Wraps long lines at first, uncontrolled.
- onWrapChange: (wrap: boolean) => void
- Receives the new wrap state from the toggle.
- maxLines: number
- Collapses the body at this many lines and adds a Show more button.
- isStreaming: boolean = false
- Marks the frame busy and keeps the gutter wide while the code arrives.
CodeBlockBody
- children: ReactNode
- Highlighted output from your highlighter. Without it, the body shows the code as plain text.
CodeBlockHeader
Holds the title and actions. It shows the language name and the default actions when you pass no children.
- children: ReactNode
- Replaces the default title and action row with custom content.
CodeBlockTitle
Names the code in the header. A string also names the code region for assistive technology.
- children: ReactNode
- The title text, usually the file name.
CodeBlockActions
Holds the header actions. It renders the wrap toggle and the copy button by default.
- children: ReactNode
- Replaces the default wrap and copy actions.
CodeBlockWrap
Toggles line wrapping. It takes the ToggleButton props and is icon-only.
CodeBlockCopy
Copies the code from the frame. It takes the CopyButton props except value.