Code
tile/code
Shows preformatted source code content with an optional language label.
| Name | Required | Lightning Type | Default | Description |
|---|---|---|---|---|
| code | Yes | lightning__multilineTextType | The source code text string, which includes any programming or markup language. | |
| language | No | lightning__textType | A programming language identifier shown as a header label. For example: javascript, python, sql. |
Display a block of preformatted source code in a monospace font, preserving whitespace, indentation, and line breaks exactly as written. Use tile/code to show a snippet, command, config file, or query.
For inline code within a sentence, use tile/text with variant: "code" instead. For rich-formatted content, use tile/markdown instead.
Embed newlines as \n and include any indentation directly in the code string. Whitespace is preserved exactly as you entered it.
When the snippet doesn’t match a supported language, omit language to hide the header.
Use the language attribute with these languages.
javascripttypescriptpythonjavaccppcsharpgorustrubyphpsqlhtmlcssjsonyamlxmlbashmarkdown
Consider these guidelines when working with code.
- Set
languageto a lowercase identifier such as"python"or"sql", so the header label appears. - Code highlighting isn’t supported.
Note any limitations that apply to this component.
No known limitations for tile/code in Slackbot.
No known limitations for tile/code in ChatGPT.
language isn’t supported. The code block renders as monospace text without syntax highlighting.