Component docs
Loading
import { CodeExample } from "@pixxl-tools/components";
// In Server Components:
import { CodeExample } from "@pixxl-tools/components/server";| Prop | Type | Default | Description |
|---|---|---|---|
code | ReactNode | — | — |
language | ReactNode | — | — |
title | ReactNode | — | Title (any content). |
actions | ReactNode | — | Action slot (buttons or links). |
copyable | boolean | true | Copy button in the header (default: true when code is a string; false hides it). |
description | ReactNode | — | Supporting text. |
label | string | — | Names the copy button ("Copy code: {label}") and the code (a focusable group, not a landmark, while it scrolls) without changing the header. Default: the title, then the language. Give repeated examples on one page distinct labels. |
maxHeight | number | string | — | — |
codeReactNode
languageReactNode
titleReactNode
Title (any content).
actionsReactNode
Action slot (buttons or links).
copyabledefault trueboolean
Copy button in the header (default: true when code is a string; false hides it).
descriptionReactNode
Supporting text.
labelstring
Names the copy button ("Copy code: {label}") and the code (a focusable group, not a landmark, while it scrolls) without changing the header. Default: the title, then the language. Give repeated examples on one page distinct labels.
maxHeightnumber | string
Other props are passed to the root element (HTMLAttributes<HTMLElement>), including className, style, id and aria-* attributes.
{ "ok": true }const json = JSON.stringify({ name: "pixxl" }, null, 2);
<CodeExample title="Request" language="json" code={json} />