Sajari UI

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 main
import (
"log"
"net/http"
)
// Example comment but a really long one to show how the Code component handles wrapping of the content
func 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

NameTypeDefaultDescription
languagePrism.LanguageThe language type for the code block.
themelight, darkBy default this will be determined by the users OS setting.
valuestring, object, array''The content of the code block. Non strings will be stringified using JSON.stringify with 2 space indentation.
wrapbooleanfalseEnables word wrap in the code block. Note: as no line numbers are rendered, it can be hard to determine a new line versus wrapped.