Skip to content

About

Type-safe DaisyUI v5 HTML AST component library and interactive CLI generator for Go.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

daisyui-go

Important

100% AI-Generated Codebase: This repository and all of its contents—including the spec-parsing pipelines, code generators, Go AST component builders, interactive Cobra CLI, live preview server, test suites, and documentation—have been generated in their totality by AI.

A Go component library for DaisyUI, generated from daisyUI's own skills/daisyui/components/*.md specs (github.com/saadeghi/daisyui), built on the ht HTML-AST-builder pattern (github.com/AccentDesign/ht).

  • 67/68 components covered (all but calendar, which documents 3 unrelated JS library integrations rather than a class-based component).
  • 430 generated test cases assert EXACT class-attribute output for every documented color/size/style/modifier/part class, sourced directly from the spec markdown -- no hand-typed expectations.

Updating from Upstream DaisyUI Specs

Option 1: Automated 1-Click Update

Run the automated script to fetch latest specs from github.com/saadeghi/daisyui, regenerate Go files, and run the test suite:

./fetch_specs.sh

Option 2: Step-by-Step Manual Update

  1. Clone the DaisyUI component markdown specs using Git sparse checkout:

    git clone --depth 1 --filter=blob:none --sparse https://github.com/saadeghi/daisyui.git ./tmp_daisyui
    (cd ./tmp_daisyui && git sparse-checkout set skills/daisyui/components)
    mkdir -p ./specs/components
    cp ./tmp_daisyui/skills/daisyui/components/*.md ./specs/components/
    rm -rf ./tmp_daisyui
  2. Run the 3-stage generation pipeline:

    # 1. Parse markdown specs into specs.json
    python3 parse_specs.py ./specs/components
    
    # 2. Generate Go builders, class constants, and runtime registry
    python3 gen_go.py
    
    # 3. Generate 430+ automated class verification tests
    python3 gen_test.py
  3. Verify end-to-end with Go tests:

    go vet ./...
    go test ./... -v

Building / testing (Go 1.26+ required; x/net/html uses range-over-func)

go build ./...
go vet ./...
go test ./...

DaisyUI CLI & Component Generator

daisyui-go provides a full-featured Cobra CLI (cmd/daisyui) for generating code, previewing components live in the browser, and inspecting component metadata:

# Install the CLI
go install ./cmd/daisyui

# Or run directly
go run ./cmd/daisyui [command]

Commands

1. Generate Components (gen / default)

Launch the interactive terminal wizard with live search and arrow-key navigation, or pass a component slug directly:

# Interactive terminal wizard (auto-copies Go snippet to clipboard)
go run ./cmd/daisyui gen

# Direct component selection
go run ./cmd/daisyui gen table
go run ./cmd/daisyui gen card -o card.go

# Start live preview server with a specific theme (e.g. cyberpunk, cupcake, dark)
go run ./cmd/daisyui gen table -s -p 3000 -t cyberpunk
  • Arrow-Key Navigation & Live Filtering: Type characters to filter the 67 components live; navigate options with ↑/↓ and Space checkboxes.
  • Automatic Clipboard Copy: Generated Go snippets are instantly copied to your clipboard.
  • Live Theme Switching: The --serve preview server includes an in-browser theme dropdown covering all 35 DaisyUI themes.

2. List Available Components (list / ls)

View all 67 supported components, root HTML tags, base classes, and modifier counts:

go run ./cmd/daisyui list

3. Inspect Component Details (info / inspect)

View full modifier categories, constants, and sub-part structures for any component:

go run ./cmd/daisyui info card
go run ./cmd/daisyui info modal

4. Live Preview Server (serve / preview)

Start a standalone live preview server:

go run ./cmd/daisyui serve -p 3000 -t synthwave

5. Shell Autocompletion

Generate tab-completion for bash, zsh, fish, or powershell:

# For Zsh
source <(daisyui completion zsh)

# For Bash
source <(daisyui completion bash)

Example Demo

go run ./examples/demo
go run ./examples/interactive

About

Type-safe DaisyUI v5 HTML AST component library and interactive CLI generator for Go.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages