Code
Code is a component used to display code blocks. It is composed from the
Box component with a font family of mono
for displaying code.
Import
Usage
Editable Example
cd2ca5f6-b361-4129-a275-7dbefafc0250
Language
Editable Example
package mainimport ("log""net/http")// Example comment but a really long one to show how the Code component handles wrapping of the contentfunc main() {port := "8080"http.Handle("/", http.FileServer(http.Dir("public")))log.Printf("Listening on port %s", port)if err := http.ListenAndServe(":"+port, nil); err != nil {log.Fatal(err)}}
Props
Name | Type | Default | Description |
---|---|---|---|
language | Prism.Language | The language type for the code block. | |
theme | light , dark | By default this will be determined by the users OS setting. | |
value | string , object , array | '' | The content of the code block. Non strings will be stringified using JSON.stringify with 2 space indentation. |
wrap | boolean | false | Enables word wrap in the code block. Note: as no line numbers are rendered, it can be hard to determine a new line versus wrapped. |