# Pre-highlighted lines

> Lines built without shiki, the shape a server component passes down.

A shadcn/ui block from the [@reui](https://reui.io) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/reui/c-code-block-15).

- Page, with a live preview: https://shadcn.exchange/r/reui/c-code-block-15
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/reui/c-code-block-15-light-ebdf7712576c5b11.png
- Registry item: https://reui.io/r/new-york-v4/c-code-block-15.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://reui.io/r/new-york-v4/c-code-block-15.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@reui/code-block`

## Files

### `c-code-block-15.tsx`

```tsx
import {
  CodeBlock,
  CodeBlockCopyButton,
  CodeBlockHeader,
  CodeBlockTitle,
} from "@/components/reui/code-block/code-block"
import type { CodeBlockLine } from "@/components/reui/code-block/code-block"

const source = `def fib(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a`

/**
 * Lines built without shiki, to show the shape any highlighter can produce.
 *
 * The same array is what a server component gets back from `highlightCode` and
 * hands over the RSC boundary, so this is also the pre-highlighted path: the
 * client never loads a grammar.
 */
const lines: CodeBlockLine[] = source.split("\n").map((text, index) => ({
  number: index + 1,
  text,
  tokens: text
    .split(/(\b(?:def|for|in|return)\b)/)
    .filter(Boolean)
    .map((content) => ({
      content,
      ...(/^(def|for|in|return)$/.test(content)
        ? { color: "#cf222e", colorDark: "#ff7b72" }
        : {}),
    })),
}))

export function Pattern() {
  return (
    <div className="w-full max-w-2xl">
      <CodeBlock lines={lines} showLineNumbers label="Python code">
        <CodeBlockHeader>
          <CodeBlockTitle>fib.py</CodeBlockTitle>
          <div className="ml-auto flex items-center gap-1.5">
            <span className="text-muted-foreground text-xs">
              No shiki on the client
            </span>
            <CodeBlockCopyButton value={source} />
          </div>
        </CodeBlockHeader>
      </CodeBlock>
    </div>
  )
}
```
