Skip to main content

CodeSnippet

Use the CodeSnippet to display a code block in a read-only context. By default, the code is formatted but not highlighted.

CodeSnippetProps

extends, , , ,
NameTypeDefaultDescription
language?
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
-

Code language to be used to run highlighting on the given code.

allowCopy?
true

Whether the copy button should be displayed.

showLineNumbers?
true

Whether line numbers should be shown.

maxHeight?
-

Height of the code container. If this is known in advance, then very long code snippets will still be able to fit into the container while also having scrolling enabled. Value is given in px.

lineBreaks?
false

Whether the content breaks into new lines automatically or not.

onCopy?
() =>
-

Callback fired when copy button is clicked and the code snippet was copied.

size?
|
'default'

CodeSnippet layout size, 'default' for standard spacing and 'condensed' for reduced font size, padding and margins.

Still have questions?
Find answers in the Dynatrace Community