Code
Code displays a code block with optional syntax highlighting and copy functionality
TailwindCSS
Vanilla JS
fmt.Println("Hello, World!")
Installation
Install the component
templui add code
Add the JavaScript to your layout
@code.Script()
Call this template in your base layout file (e.g., in the <head> section).
Examples
Custom Size
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
})
fmt.Println("Server starting on :3000...")
if err := http.ListenAndServe(":3000", nil); err != nil {
log.Fatal(err)
}
}