counter

command
v0.0.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 6 Imported by: 0

README

Tailwind Counter Example

This example boots a complete LiveUI application with TailwindCSS styling. It shows how to:

  • render a component that uses Tailwind utility classes
  • serve the SSR boot payload with internal/server/http.Manager
  • attach a PondSocket endpoint so websocket diffs reach the browser
  • compile Tailwind locally so no CDN requests are required at runtime

Running the example

cd examples/counter
go run .

The server listens on http://localhost:8080. The precompiled Tailwind subset from public/tailwind.css is embedded and served so styling works without reaching out to a CDN.

The checked-in public/tailwind.css is generated, not handwritten. It is the exact output of the Tailwind CLI scanning the Go components referenced in this example. Regenerate it whenever you tweak the Go markup or Tailwind config:

npm install
npx tailwindcss -i styles/input.css -o public/tailwind.css --minify

The bundled tailwind.config.js is configured to scan *.go files so Tailwind detects the class names embedded in component definitions.

Smoke-testing the HTTP boot endpoint

You can verify the SSR response with a simple HTTP request:

curl -s http://localhost:8080/ | head

The output contains the stylesheet link and the LiveUI boot payload.

Automated coverage lives in main_test.go, which uses the HTTP manager directly to assert on the rendered HTML.

Documentation

Overview

Package main hosts a full LiveUI application that renders a TailwindCSS-styled counter and wires both the HTTP boot route and PondSocket transport. It can be started with `go run .` and will serve SSR HTML plus a websocket endpoint for interactive updates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL