# Code Block

Compose the header, content, and footer independently. Pass plain text to `Content`, or compose `Line` elements for diff states and styled token arrays. `CopyButton` copies its explicit `value`.

```svelte
<script lang="ts">
  import * as CodeBlock from "~/components/code-block";
  const code = "npm install svelte";
</script>

<CodeBlock.Root>
  <CodeBlock.Header>
    <CodeBlock.Title>Terminal</CodeBlock.Title>
    <CodeBlock.Actions><CodeBlock.CopyButton value={code} /></CodeBlock.Actions>
  </CodeBlock.Header>
  <CodeBlock.Content {code} lineNumbers />
</CodeBlock.Root>
```

Root supports `variant="default" | "destructive"` and `size="default" | "sm"`. Content supports `wrap`, `lineNumbers`, and `startLine`. Line supports `default`, `added`, `removed`, and `highlighted` variants. Token arrays accept `content`, `style`, and `class`; syntax highlighting is supplied by the consumer.