# CodeBlock

Display and copy multiline source in a bounded, keyboard-scrollable surface.

Connect Flood once using [the installation guide](https://flood.md/docs/installation). Then import the components you use; no per-component add command is needed.

## Example

```tsx
"use client";

import { FloodRoot, CodeBlock } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <CodeBlock filename="example.ts" language="TypeScript" code={"export const limit = 10;\nexport const page = 1;"} />
    </FloodRoot>
  );
}
```

## Design notes

- Pass original source text. Indentation and line breaks are preserved when copying.
- Use wrap when reading across a narrow surface matters more than retaining visual line width.
- Use CodeSnippet for a short command or inline installation snippet. The CodeBlock language is a label.

## API reference

| Prop | Values | Default |
| --- | --- | --- |
| `code` | `string` | `Required` |
| `label` | `string` | `"Code example"` |
| `filename` | `string` | `—` |
| `language` | `string` | `—` |
| `maxBlockSize` | `string` | `"20rem"` |
| `wrap` | `boolean` | `false` |
| `showCopy` | `boolean` | `true` |
| `copyLabel` | `string` | `"Copy code"` |
| `Native HTML props` | `Omit<HTMLAttributes<HTMLElement>, "children" \| "aria-label">` | `Forwarded` |
