Skip to content
CtrlK

ArdoCodeBlock

On this page

Syntax-highlighted code block with copy button.

Pass the code as the code prop or as children. When children is a string, leading and trailing blank lines and the common indentation are stripped.

import { ArdoCodeBlock } from "ardo/ui"

<ArdoCodeBlock>{children}</ArdoCodeBlock>

Props

NameTypeRequiredDescription
codestringNoThe code to display (as prop or as children string)
languagestringNoProgramming language for syntax highlighting
titlestringNoOptional title shown above the code
data-labelstringNoLabel used by CodeGroup tabs
lineNumbersbooleanNoShow line numbers
wrapbooleanNoWrap long lines instead of scrolling sideways. Meant for prose, such as an
agent prompt. Defaults to true for the prompt language.
highlightLinesnumber[]NoLine numbers to highlight
childrenReact.ReactNodeNoCode as children — supports template literals with auto-outdent
metastringNoNative fence metadata used by the literal TSX prepass.
__htmlstringNoCompatibility input for callers of the public HTML-returning highlightCode helper.

Props type: ArdoCodeBlockProps

Example

<ArdoCodeBlock language="typescript">{`
  const x = 42
`}</ArdoCodeBlock>