# MarkdownCodeBlock

Code with a copy button, optional syntax colors and line numbers.

- **Use it for**: Copyable code with optional highlighting.
- **Not for**: One command. Try [Snippet](https://unseenui.com/components/snippet/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { MarkdownCodeBlock } from '@stackunseen/ui/code';
import '@stackunseen/ui/styles.css';

<MarkdownCodeBlock variant="panel" code={code} language="typescript" />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `code` (required) | `string` |  |
| `highlightLines` | `readonly (readonly [number, number])[]` | Inclusive 1-based line ranges to mark, such as a tour stop. |
| `language` | `string` |  |
| `scrollToLine` | `number` | Scrolls this 1-based line near the top of the code pane, never the page, whenever it changes. |
| `streaming` | `boolean` |  |
| `variant` | `"panel" \| "minimal" \| "numbered"` |  |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[MarkdownResponse](https://unseenui.com/components/markdown-response/), [RichMarkdownResponse](https://unseenui.com/components/rich-markdown-response/), [MathFormula](https://unseenui.com/components/math-formula/), [MermaidDiagram](https://unseenui.com/components/mermaid-diagram/)

Page: https://unseenui.com/components/markdown-code-block/
