templUI Pro coming soon  

50% OFF Join Waitlist

Code

Code displays a code block with optional syntax highlighting and copy functionality

TailwindCSS
Vanilla JS

fmt.Println("Hello, World!")

Installation

  1. Install the component

    templui add code
  2. Add the JavaScript to your layout

    @code.Script()
    

    Call this template in your base layout file (e.g., in the <head> section).

Examples

Copy Button

fmt.Println("Hello, World!")

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)
   }
}