Code

tile/code

Shows preformatted source code content with an optional language label.

NameRequiredLightning TypeDefaultDescription
codeYeslightning__multilineTextTypeThe source code text string, which includes any programming or markup language.
languageNolightning__textTypeA 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.

  • javascript
  • typescript
  • python
  • java
  • c
  • cpp
  • csharp
  • go
  • rust
  • ruby
  • php
  • sql
  • html
  • css
  • json
  • yaml
  • xml
  • bash
  • markdown

Consider these guidelines when working with code.

  • Set language to 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.