Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-code-block.json --yes

Code block

Pro

A short value or command in the theme's mono, in a grey box, with a copy button beside it that copies it and says so, for React and Tailwind CSS. Part of Goop Pro.

Pick a command, a file, a tall file or a long line; turn the title bar, line numbers, wrapping, highlighted lines and a height limit on and off; copy the code and paste it anywhere. The code is our own sample, its colours a stand-in for your own highlighter's: nothing runs, and only the plain code reaches your clipboard.

When to use

  • A short value or command in the theme's mono, in a grey box, with a copy button beside it that copies it and says so.
  • Also called: code snippet or syntax highlighting.

Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Code block on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

Terminal
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-code-block.json --yes
PROMPT
Add the Goop Code block to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { CodeBlock } from '@/components/ui/goop/code-block';

function SiteFeed() {
  return (
    <div className="flex flex-col gap-2">
      <CodeBlock code="https://feeds.fieldwork.example/north-gate" copyLabel="Copy feed link" />
      <CodeBlock code="fieldwork sync --site north-gate --crew yard" wrap copyLabel="Copy the sync command" />
      <CodeBlock title="crew.ts" language="ts" lineNumbers maxHeight="sm" code={"export const crew = 'yard';\nexport const site = 'north-gate';\n"} />
    </div>
  );
}
  • Fits: chat (its recipe).
  • Also known as: CodeSnippet, Snippet, Pre, CodeSample, CodePreview.
  • Put it under the line that says what the value is for (a field's description, a card's row); one per value. A value typed by the person is a TextInput, never a CodeBlock.
  • height, width, padding, gap, corner, background, text: add no class for these.

API reference

Options
OptionTypeWhat it does
code?stringThe value shown and copied, exactly as it is put on the clipboard, its line breaks kept.
children?stringThe value as text, when code is not given.
language?stringThe code's language (ts, bash): kept as the block's data-language and the language-<name> class on its code element, the seam a highlighter reads.
highlightedLines?readonly ReactNode[]The code's lines already coloured by your own highlighter, one node per line of code, in order: each is drawn in place of its plain line.
title?stringA name for the block (a filename), shown above the box in the mono: it also names the block for a screen reader.
lineNumbers?boolean = falseA gutter of line numbers before the lines, never selected or copied with the code.
wrap?boolean = falseFill the row and wrap a long value between words, the button at its top (false: the box hugs a short value, and a value of several lines scrolls sideways inside its box).
maxHeight?'sm' | 'md' | 'lg'How tall the box may grow before it scrolls inside: sm 200 px, md 300 px, lg 500 px.
copyable?boolean = trueDraw the copy button (true by default).
onCopy?(code: string) => voidCalled with code once it is on the clipboard (never when the copy failed).
copyLabel?string = 'Copy'The copy button's name, read by a screen reader: say what is copied ("Copy feed link"); "Copy" by default.
copiedLabel?string = 'Copied'What the status says once the value is on the clipboard: "Copied" by default.
failedLabel?string = 'Couldn’t copy'What the status says when there is no clipboard or the browser refused the value: "Couldn’t copy" by default.
  • data-slot values (to select a part by): code-block, code-block-button, code-block-line, code-block-line-label, code-block-status, code-block-text, code-block-title

Keyboard

KeyWhat it does
Enter SpaceOn the copy button: copy the value, the status saying it was copied

Accessibility

  • The part itself answers the keys above.
  • hover, active: the browser's own (:hover, :active): write nothing

Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:

StateDrawn by
focus-visiblethe attribute data-focus-visible

Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

goop.so/themes/meadow/components/code-block.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-code-block.json --yes

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.