# Code Block

Code to read and copy: a listing with line numbers, a diff or a command.

Code to read, copy or edit, in a card: a listing with line numbers, a diff, tabbed files or a command. A header (file icon, file name, Copy, or a diff's +N -M) over a Code View, which draws the code: gutter, syntax colouring, diff rows, the current line, wrapping and scrolling. With files the header is the file tabs, the active file's path and one Copy; when the tabs do not fit, a pager and a select stand in for them. The command variant is one line with Copy at its end. editable makes the code an editor (the Code View's, CodeMirror 6, loaded only then); Copy takes the edited text. Because the block is built on the Code View, adding it installs the editor's packages, but a block that is never editable never downloads them (a dynamic import). Copy puts the code on the clipboard and says so for 1.5s. For code without the card (an editor pane), use a Code View.

Kind: component · Category: Display · Status: beta · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add code-block
```

It writes the folder `code-block/` into the project's ui folder (`index.ts`, `code-block.tsx`, `CodeBlock.vue`, `CodeBlock.svelte`, `code-block.recipe.ts`), and what it is built from: [Button](/components/button.md), [Code View](/components/code-view.md), [Tabs](/components/tabs.md), [Pager](/components/pager.md), [Select](/components/select.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { CodeBlock } from "@/components/ui/code-block";
```

```vue
import { CodeBlock } from "@/components/ui/code-block";
```

```svelte
import { CodeBlock } from "$lib/components/ui/code-block";
```

## Parts

In the DOM the root carries `data-slot="code-block"` and each part `data-slot="code-block-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `code-block` |  | Card, max-width 420; fill: no max width, as tall as its container |
| `header` | `div` | `code-block-header` |  | 44px: icon · filename · copy \| stat. With files the same 44px row is the tabs' header part: file tabs · path · copy, or, when the tabs do not fit, pager · select · path · copy |
| `file-icon` | `i` | `code-block-file-icon` |  | Phosphor code icon |
| `filename` | `span` | `code-block-filename` |  | Cut in the middle while it does not fit (a file name keeps its end: "invoice-batch-…-scheduler.ts"), full name in title while cut (lib/truncate.ts middleTruncation) |
| `copy` | `button` | `code-block-copy` | optional | A Button (ghost, xs, rounded, muted) with two labels in one cell (icon part: copy and check; label part: Copy and Copied); data-swapped while "Copied" shows; aria-label "Copy code". Its green while swapped is the code block's. Beside it a visually hidden role=status (sr-only) announces "Copied". The real Button, marked data-code-block="copy"; swapped while Copied shows. |
| `status` | `span` | `code-block-status` |  | Visually hidden role=status beside Copy; says Copied while the button is swapped. |
| `stat` | `span` | `code-block-stat` | optional | +N -M for the diff variant |
| `view` | `div` | `code-block-view` |  | The Code View (code-view), marked data-code-block="view", under the header: the listing, the highlighted lines, the diff or the editor, named by the filename (the active file's path with files). It takes the block's value, wrap, currentLine, height, maxHeight and editable; with fill it takes what the header leaves. |
| `path` | `span` | `code-block-path` | optional | With files: the active file's path in the header row, pushed to the end before Copy; mono, xs, ink-2; the first thing to shrink, cut in the middle so the file name stays ("packages/…/select.tsx"), full path in title while cut; hidden while the pager and the select stand in for the tabs (the select names the file) |
| `pager` | `div` | `code-block-pager` | optional | With files, while the tabs do not fit (data-fit="select" on the root): the pager component (loop, "2 of 5", Previous file / Next file) in the header, before the select |
| `file-select` | `div` | `code-block-file-select` | optional | With files, while the tabs do not fit: the select component (sm, subtle) listing every file by its label, its value cut in the middle when it does not fit; it and the pager stand in for the hidden tab list (and the path) and go once the tabs fit again |
| `command` | `div` | `code-block-command` | optional | variant=command: the one row: the code and a trailing copy |
| `code` | `code` | `code-block-code` | optional | variant=command: the command, one line that scrolls sideways (no scrollbar) |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"code" \| "diff" \| "command"` | `"code"` | code: line-numbered listing. diff: unified diff. command: one line to copy (an install command): no header, no line numbers, copy at the end. |
| `filename` | `string` | `"example.ts"` | The file's name in the header, and the name of the scroll region. |
| `value` | `string` |  | Bindable (React: `defaultValue` and `onValueChange`; Vue: `v-model:value`; Svelte: `bind:value`). The code, lines separated by \n: shown, copied, and, when editable, edited (valueChange). The command variant shows it as one line. |
| `diff` | `{ old: number\|null; cur: number\|null; type: ctx\|add\|del; pieces: { text: string; change?: 'add'\|'del' }[] }[]` |  |  |
| `maxHeight` | `number` |  | Height in px of the code past which it scrolls: passed to the Code View (the header is not counted). |
| `labels` | `object` |  | { copy, copied, copyCode, files, file, previousFile, nextFile } and the Code View's editor words (find, replace, …), passed on |
| `highlighted` | `array` |  | Lines already highlighted elsewhere (shiki and the like), as trusted HTML, one string per line; shown instead of value. Display only: Copy takes value, and editable shows value with the tokenizer's colours. |
| `files` | `{ path: string; label?: string; value?: string; highlighted?: string[] }[]` |  | Files as tabs (the tabs component, underline, inHeader) in one 44px header row: the tabs at the start, their underline resting on the header's hairline, then the active file's path and the block's one Copy (it copies the active file), placed as in a single file's header. Each panel holds the file's Code View; editable, the block keeps each file's edits while another is open. The path shrinks first (cut in the middle). Names of choices are shown whole: when the tabs do not fit beside Copy (measured on mount and on every change of width, code-block.logic.ts), the root takes data-fit="select", the tab list is hidden and a pager plus a select of every file stand in for it; the tabs come back once they fit. |
| `file` | `string` |  | Bindable (React: `defaultFile` and `onFileChange`; Vue: `v-model:file`; Svelte: `bind:file`). The active file's path (defaults to the first). |
| `height` | `number` |  | Fixed height in px of the code: the box keeps its size whatever the code (loading, switching files). Passed to the Code View. |
| `fill` | `boolean` | `false` | Fill the container's height: the block is a column as tall as its parent (give the parent a height), the header keeps its 44px and the Code View takes the rest and scrolls; no max width. Not for the command variant. |
| `currentLine` | `number` |  | The current line, 1-based, of the listing or of the active file: passed to the Code View, which tints it and keeps it in view; editable, a new value moves the caret there. A diff ignores it. |
| `wrap` | `boolean` | `true` | Long lines wrap (default) or, false, scroll sideways under a gutter that stays: passed to the Code View. |
| `editable` | `boolean` | `false` | The code is an editor (the Code View's editable: undo, find and replace, several cursors, folding); Copy takes the edited text and every edit is reported (valueChange). Not for a diff or a command. The editor keeps a 12px fold column, so turning editable on or off on a live block moves the code by that much. |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `copy` | (text: string) after a successful copy |
| `valueChange` | (value: string) after every edit in the editor: the block's text, or the open file's |
| `currentLineChange` | (line: number) when the editor's caret moves to another line |
| `fileChange` | (path: string) when another file is opened |

## States

`hover`, `press`, `focus-visible`, `disabled`, `copied`

## Keyboard and accessibility

Role: region (the Code View, while it scrolls).

Keyboard:

- Enter / Space on Copy copy the code; focus stays on the button
- Tab reaches the code while it overflows (the Code View's scroll region); the arrow keys and Page Up / Page Down scroll it

Notes:

- Copy is named "Copy code"; its visible labels are aria-hidden. A visually hidden role=status region announces "Copied" politely and empties when the label reverts.
- Line numbers, the scroll region and right-to-left reading are the Code View's (see code-view).

## Motion

- copy: icon and label crossfade with opacity and a 2px blur over duration.base; colour over duration.fast; press scales to motion.press-scale over duration.press
- "Copied" holds for 1.5s, then crossfades back; with files it belongs to the file that was copied: opening another file shows Copy at once (no fade) and the status empties
- Code / Diff switch: no animation
- Tabs ↔ pager + select switch (width): no animation; nothing plays on first paint

## Tokens

`color.surface`, `color.ink`, `color.ink-2`, `color.ink-3`, `color.line`, `color.green`, `color.red`, `shadow.card`, `radius.card`, `font.mono`, `text.xs`, `text.dense`, `duration.fast`, `duration.base`, `duration.press`, `easing.out-strong`, `motion.press-scale`

## Dependencies

- [Button](/components/button.md)
- [Code View](/components/code-view.md)
- [Tabs](/components/tabs.md)
- [Pager](/components/pager.md)
- [Select](/components/select.md)

## Examples

### Create a deploy from the SDK

React · `create-deploy.tsx`

```tsx
import { CodeBlock } from "@/components/ui/code-block";

const code = [
  "await northwind.deploys.create({",
  "  project: \"web-app\",",
  "  target: \"production\",",
  "});",
].join("\n");

export default function CreateDeploy() {
  return <CodeBlock variant="code" filename="scripts/deploy.ts" value={code} />;
}
```

Vue · `create-deploy.vue`

```vue
<script setup lang="ts">
import { CodeBlock } from "@/components/ui/code-block";

const code = [
  "await northwind.deploys.create({",
  "  project: \"web-app\",",
  "  target: \"production\",",
  "});",
].join("\n");
</script>

<template>
  <CodeBlock variant="code" filename="scripts/deploy.ts" :value="code" />
</template>
```

Svelte · `create-deploy.svelte`

```svelte
<script lang="ts">
  import { CodeBlock } from "$lib/components/ui/code-block";

  const code = [
    "await northwind.deploys.create({",
    "  project: \"web-app\",",
    "  target: \"production\",",
    "});",
  ].join("\n");
</script>

<CodeBlock variant="code" filename="scripts/deploy.ts" value={code} />
```

### Review a change

React · `pull-request-diff.tsx`

```tsx
import type { ComponentProps } from "react";
import { CodeBlock } from "@/components/ui/code-block";

type Props = ComponentProps<typeof CodeBlock>;

const diff: Props["diff"] = [
  {
    old: 1,
    cur: 1,
    type: "ctx",
    pieces: [{ text: "export async function deliver(event: WebhookEvent) {" }],
  },
  {
    old: 2,
    cur: null,
    type: "del",
    pieces: [
      { text: "  return " },
      { text: "post(event.url, event.body);", change: "del" },
    ],
  },
  {
    old: null,
    cur: 2,
    type: "add",
    pieces: [
      { text: "  return " },
      { text: "retry(() => post(event.url, event.body), {", change: "add" },
    ],
  },
  { old: null, cur: 3, type: "add", pieces: [{ text: "    attempts: 5," }] },
  { old: null, cur: 4, type: "add", pieces: [{ text: "    backoff: \"exponential\"," }] },
  { old: null, cur: 5, type: "add", pieces: [{ text: "  });" }] },
  { old: 3, cur: 6, type: "ctx", pieces: [{ text: "}" }] },
];

export default function PullRequestDiff() {
  return <CodeBlock variant="diff" filename="src/webhooks/deliver.ts" diff={diff} />;
}
```

Vue · `pull-request-diff.vue`

```vue
<script setup lang="ts">
import { CodeBlock } from "@/components/ui/code-block";
import type { CodeDiffRow } from "@/components/ui/code-view";

const diff: CodeDiffRow[] = [
  {
    old: 1,
    cur: 1,
    type: "ctx",
    pieces: [{ text: "export async function deliver(event: WebhookEvent) {" }],
  },
  {
    old: 2,
    cur: null,
    type: "del",
    pieces: [
      { text: "  return " },
      { text: "post(event.url, event.body);", change: "del" },
    ],
  },
  {
    old: null,
    cur: 2,
    type: "add",
    pieces: [
      { text: "  return " },
      { text: "retry(() => post(event.url, event.body), {", change: "add" },
    ],
  },
  { old: null, cur: 3, type: "add", pieces: [{ text: "    attempts: 5," }] },
  { old: null, cur: 4, type: "add", pieces: [{ text: "    backoff: \"exponential\"," }] },
  { old: null, cur: 5, type: "add", pieces: [{ text: "  });" }] },
  { old: 3, cur: 6, type: "ctx", pieces: [{ text: "}" }] },
];
</script>

<template>
  <CodeBlock variant="diff" filename="src/webhooks/deliver.ts" :diff="diff" />
</template>
```

Svelte · `pull-request-diff.svelte`

```svelte
<script lang="ts">
  import { CodeBlock } from "$lib/components/ui/code-block";
  import type { CodeDiffRow } from "$lib/components/ui/code-view";

  const diff: CodeDiffRow[] = [
    {
      old: 1,
      cur: 1,
      type: "ctx",
      pieces: [{ text: "export async function deliver(event: WebhookEvent) {" }],
    },
    {
      old: 2,
      cur: null,
      type: "del",
      pieces: [
        { text: "  return " },
        { text: "post(event.url, event.body);", change: "del" },
      ],
    },
    {
      old: null,
      cur: 2,
      type: "add",
      pieces: [
        { text: "  return " },
        { text: "retry(() => post(event.url, event.body), {", change: "add" },
      ],
    },
    { old: null, cur: 3, type: "add", pieces: [{ text: "    attempts: 5," }] },
    { old: null, cur: 4, type: "add", pieces: [{ text: "    backoff: \"exponential\"," }] },
    { old: null, cur: 5, type: "add", pieces: [{ text: "  });" }] },
    { old: 3, cur: 6, type: "ctx", pieces: [{ text: "}" }] },
  ];
</script>

<CodeBlock variant="diff" filename="src/webhooks/deliver.ts" {diff} />
```

### Install command

React · `install-command.tsx`

```tsx
import { CodeBlock } from "@/components/ui/code-block";

export default function InstallCommand() {
  return <CodeBlock variant="command" value="npm install @northwind/sdk" />;
}
```

Vue · `install-command.vue`

```vue
<script setup lang="ts">
import { CodeBlock } from "@/components/ui/code-block";
</script>

<template>
  <CodeBlock variant="command" value="npm install @northwind/sdk" />
</template>
```

Svelte · `install-command.svelte`

```svelte
<script lang="ts">
  import { CodeBlock } from "$lib/components/ui/code-block";
</script>

<CodeBlock variant="command" value="npm install @northwind/sdk" />
```

### Setup across two files

React · `sdk-setup.tsx`

```tsx
import type { ComponentProps } from "react";
import { CodeBlock } from "@/components/ui/code-block";

type Props = ComponentProps<typeof CodeBlock>;

const files: Props["files"] = [
  {
    path: "src/client.ts",
    label: "client.ts",
    value: [
      "import { Northwind } from \"@northwind/sdk\";",
      "",
      "export const northwind = new Northwind({ apiKey: process.env.NORTHWIND_API_KEY });",
    ].join("\n"),
  },
  {
    path: "src/webhooks/verify.ts",
    label: "verify.ts",
    highlighted: [
      "<span style=\"color: var(--fndn-accent-ink)\">export const</span> secret = process.env.<span style=\"color: var(--fndn-orange)\">WEBHOOK_SECRET</span>;",
    ],
    value: "export const secret = process.env.WEBHOOK_SECRET;",
  },
];

export default function SdkSetup() {
  return <CodeBlock files={files} height={120} />;
}
```

Vue · `sdk-setup.vue`

```vue
<script setup lang="ts">
import { CodeBlock } from "@/components/ui/code-block";

const files = [
  {
    path: "src/client.ts",
    label: "client.ts",
    value: [
      "import { Northwind } from \"@northwind/sdk\";",
      "",
      "export const northwind = new Northwind({ apiKey: process.env.NORTHWIND_API_KEY });",
    ].join("\n"),
  },
  {
    path: "src/webhooks/verify.ts",
    label: "verify.ts",
    highlighted: [
      "<span style=\"color: var(--fndn-accent-ink)\">export const</span> secret = process.env.<span style=\"color: var(--fndn-orange)\">WEBHOOK_SECRET</span>;",
    ],
    value: "export const secret = process.env.WEBHOOK_SECRET;",
  },
];
</script>

<template>
  <CodeBlock :files="files" :height="120" />
</template>
```

Svelte · `sdk-setup.svelte`

```svelte
<script lang="ts">
  import { CodeBlock } from "$lib/components/ui/code-block";

  const files = [
    {
      path: "src/client.ts",
      label: "client.ts",
      value: [
        "import { Northwind } from \"@northwind/sdk\";",
        "",
        "export const northwind = new Northwind({ apiKey: process.env.NORTHWIND_API_KEY });",
      ].join("\n"),
    },
    {
      path: "src/webhooks/verify.ts",
      label: "verify.ts",
      highlighted: [
        "<span style=\"color: var(--fndn-accent-ink)\">export const</span> secret = process.env.<span style=\"color: var(--fndn-orange)\">WEBHOOK_SECRET</span>;",
      ],
      value: "export const secret = process.env.WEBHOOK_SECRET;",
    },
  ];
</script>

<CodeBlock {files} height={120} />
```

### A long config file

React · `project-config.tsx`

```tsx
import { CodeBlock } from "@/components/ui/code-block";

const code = [
  "import { defineConfig } from \"@northwind/sdk\";",
  "",
  "export default defineConfig({",
  "  project: \"web-app\",",
  "  framework: \"vite\",",
  "  buildCommand: \"pnpm build\",",
  "  outputDirectory: \"dist\",",
  "  regions: [\"fra1\", \"iad1\"],",
  "  environments: {",
  "    production: { branch: \"main\", domain: \"app.northwind.example\" },",
  "    staging: { branch: \"develop\" },",
  "    preview: { branches: [\"feat/*\", \"fix/*\"] },",
  "  },",
  "  headers: [",
  "    { source: \"/assets/(.*)\", cacheControl: \"public, max-age=31536000, immutable\" },",
  "  ],",
  "});",
].join("\n");

export default function ProjectConfig() {
  return <CodeBlock variant="code" filename="northwind.config.ts" value={code} maxHeight={200} />;
}
```

Vue · `project-config.vue`

```vue
<script setup lang="ts">
import { CodeBlock } from "@/components/ui/code-block";

const code = [
  "import { defineConfig } from \"@northwind/sdk\";",
  "",
  "export default defineConfig({",
  "  project: \"web-app\",",
  "  framework: \"vite\",",
  "  buildCommand: \"pnpm build\",",
  "  outputDirectory: \"dist\",",
  "  regions: [\"fra1\", \"iad1\"],",
  "  environments: {",
  "    production: { branch: \"main\", domain: \"app.northwind.example\" },",
  "    staging: { branch: \"develop\" },",
  "    preview: { branches: [\"feat/*\", \"fix/*\"] },",
  "  },",
  "  headers: [",
  "    { source: \"/assets/(.*)\", cacheControl: \"public, max-age=31536000, immutable\" },",
  "  ],",
  "});",
].join("\n");
</script>

<template>
  <CodeBlock variant="code" filename="northwind.config.ts" :value="code" :max-height="200" />
</template>
```

Svelte · `project-config.svelte`

```svelte
<script lang="ts">
  import { CodeBlock } from "$lib/components/ui/code-block";

  const code = [
    "import { defineConfig } from \"@northwind/sdk\";",
    "",
    "export default defineConfig({",
    "  project: \"web-app\",",
    "  framework: \"vite\",",
    "  buildCommand: \"pnpm build\",",
    "  outputDirectory: \"dist\",",
    "  regions: [\"fra1\", \"iad1\"],",
    "  environments: {",
    "    production: { branch: \"main\", domain: \"app.northwind.example\" },",
    "    staging: { branch: \"develop\" },",
    "    preview: { branches: [\"feat/*\", \"fix/*\"] },",
    "  },",
    "  headers: [",
    "    { source: \"/assets/(.*)\", cacheControl: \"public, max-age=31536000, immutable\" },",
    "  ],",
    "});",
  ].join("\n");
</script>

<CodeBlock variant="code" filename="northwind.config.ts" value={code} maxHeight={200} />
```

## Recipe

`code-block.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* code-block — the card around a Code View: a header (file icon, file name, Copy or a diff's stat),
 * tabbed files, or a one-line command. The code itself, its gutter, colours, wrapping, scrolling and
 * current line, is the Code View's (code-view.recipe.ts). Every colour is a token. Only Copy has
 * motion (the button's own).
 *
 * Copy is a Button (ghost, xs, rounded, muted) with two labels in one cell: the button is as
 * wide as the label it shows, and its `swapped` prop cross-fades Copy into Copied. Only the green of
 * "Copied" (the `copied` variant) and the placement are the code block's; the button is marked
 * data-code-block="copy". The announcement is a visually hidden role=status beside it (status part).
 *
 * Files: one header row, the same 44px as a single file's: the file tabs (Tabs, underline,
 * inHeader) at the start, then the active file's path and the block's one Copy, pushed to
 * the end. The path is the first thing to shrink (cut in the middle, its title holds the whole
 * path). Names of choices are shown whole: when the tabs do not fit beside Copy (measured in
 * code-block.logic.ts, the `fit` variant), they give way to a Pager and a select that lists every file,
 * and the path goes too (the select names the file). */

const MONO = "[direction:ltr] font-mono";

export const codeBlock = tv({
  slots: {
    base: "w-full max-w-[420px] min-w-0 overflow-hidden rounded-card bg-surface shadow-card",
    /* header — file · (diff stat | copy); also the Tabs header of a block with files */
    header: "flex h-11 items-center gap-2 px-4 border-b border-line text-dense",
    fileIcon: "inline-block shrink-0 size-[15px] text-[15px] leading-none align-[-0.125em] text-ink-3",
    filename: "min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-mono leading-none text-ink",
    /* Copy keeps its end placement; a path before it already took the free space */
    copy: [
      "shrink-0 ms-auto -me-1 [[data-slot=code-block-path]~&]:ms-0",
    ],
    stat: [
      "inline-flex shrink-0 ms-auto items-center gap-2 text-xs leading-none tabular-nums",
      MONO,
      /* added count, then removed count */
      "[&>:first-child]:text-green [&>:last-child]:text-red",
    ],
    /* the Code View under the header */
    view: "",
    path: [
      "flex-[0_1000_auto] min-w-0 ms-auto ps-2 overflow-hidden text-ellipsis whitespace-nowrap",
      "text-xs leading-none text-ink-2",
      MONO,
    ],
    pager: "flex-none -ms-1.5",
    fileSelect: "flex-[0_1_auto] min-w-0 me-auto",
    /* command — one line to copy (an install command): no header, no line numbers, copy at the end */
    command: "flex min-h-11 items-center gap-2 ps-4 pe-2.5",
    /* the command's code: one line that scrolls sideways */
    code: [
      "flex-1 min-w-0 p-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden whitespace-pre",
      "[font-style:inherit] [font-weight:inherit] [font-stretch:inherit] [font-variant:inherit]",
      "text-dense leading-5 text-ink",
      MONO,
    ],
  },
  variants: {
    variant: {
      code: {},
      diff: {},
      /* a command is one line and often a long one: the block may be wider than a listing */
      command: { base: "max-w-[640px]" },
    },
    /* the file tabs share the header: they shrink, and give way to the pager and the select */
    files: {
      true: {
        base: [
          "[&_[data-slot=tabs-list]]:flex-[0_1_auto] [&_[data-slot=tabs-list]]:min-w-0",
        ],
      },
    },
    /* the file tabs do not fit beside Copy (measured in code-block.logic.ts): a pager and a select stand in */
    fit: {
      tabs: {},
      select: { base: "[&_[data-slot=tabs-list]]:hidden [&_[data-slot=code-block-path]]:hidden" },
    },
    /* fills its container's height (an editor pane): the box is a column as tall as its parent and
     * the Code View takes what the header leaves, scrolling past it; no max width either. With files
     * the Tabs root and the open panel pass the height on. */
    fill: {
      true: {
        base: [
          "flex h-full min-h-0 max-w-none flex-col",
          "[&>[data-slot=tabs]]:flex [&>[data-slot=tabs]]:flex-col [&>[data-slot=tabs]]:flex-1 [&>[data-slot=tabs]]:min-h-0",
          "[&>[data-slot=tabs]>[data-slot=tabs-content]:not([hidden])]:flex [&>[data-slot=tabs]>[data-slot=tabs-content]:not([hidden])]:flex-col",
          "[&>[data-slot=tabs]>[data-slot=tabs-content]]:flex-1 [&>[data-slot=tabs]>[data-slot=tabs-content]]:min-h-0",
        ],
        header: "shrink-0",
        view: "flex-1 min-h-0",
      },
    },
    /* Copy while it says Copied */
    copied: {
      true: { copy: "text-green!" },
    },
  },
  defaultVariants: { variant: "code", files: false, fit: "tabs", copied: false, fill: false },
});

export type CodeBlockRecipeProps = VariantProps<typeof codeBlock>;
```
