Code
Component used to present a block of code in a Toolkit element
Last updated
Component used to present a block of code in a Toolkit element
Last updated
The code block is parsed with Prettier before it is rendered.
Property
Type
Description
className
String
The Class name to apply to the component
Default: rtk-code
editor
Codemirror
foldGutter
Boolean
Enable folding
Default: true
lineNumbers
Boolean
Hide/show the line numbers.
Default: true
lineWrapping
Boolean
Wrap long lines of code.
Default: false
id
String
ID value used for action Zone.
Default: code
indentUnit
Number
Number of spaces used when indenting.
Default: 4
readOnly
Boolean
Disable live editing.
Default: false
value
String
The block of code to output
onChange
Function
Called when the change event is triggered.
The Code component is an implementation of Codemirror and most of the properties are passed through to the Codemirror instance. If you want more control over the Code output you can directly apply configuration to the Codemirror instance via the editor
property.
Triggered when the code value is changed.
You can theme the Code block by supplying the following scss variables before the Toolkit styles are imported:
Reference to the object.