htmx

package module
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 15 Imported by: 3

README ΒΆ

πŸ”¨ HTMX

Go Reference Go Report Card Taylor Swift

A package to write HTML5 and HTMX components in Go.

πŸ¦„ Features

  • Write declartive HTML5 components in Go without using templates and with the full-power of a type-safe language, auto-completion, and refactoring.
  • Full support for HTMX components.
  • No dependencies on JavaScript frameworks.
  • Fast rendering of HTML5 and HTMX components.
  • Easy to use and learn.
  • Easy to extend and customize.

✨ Components

There are additional complex components that help to write HTML5 and HTMX components in Go.

πŸ›Έ Installation

go get github.com/katallaxie/htmx

πŸ§ͺ Usage

Creating a button leveraging htmx is as easy as this.

htmx.Button(
    htmx.Attribute("type", "submit")
    htmx.Text("Button"),
    htmx.HxPost("/api/respond")
)

All nodes implement the io.Writer interface. Which means it is possible to render to a http.Request but also to render to a file.

f, err := os.OpenFile("123.txt", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
    panic(err)
}
defer f.Close()

err = Page().Render(f)
if err != nil {
    panic(err)
}

🎨 Elements

HTML and HTMX elements are represented as functions in Go. The functions are used to create the elements.

htmx.Div(
    htmx.ClassNames{
        tailwind.FontSemibold: true,
    },
    htmx.Text("Hello World"),
)

This will create the following HTML element.

<div class="font-semibold">Hello World</div>

There is support for all HTML5 elements and Tailwind classes. Use import "github.com/katallaxie/fiber-htmx/tailwind" to include Tailwind classes.

πŸ“¦ Components

Write HTML5 and HTMX components in Go.

func HelloWorld() htmx.Node {
    return htmx.Div(
        htmx.ClassNames{
            "font-semibold",
        },
        htmx.Text("Hello World"),
    )
}

There are different types of composition. For example, passing children to a component.

func HelloWorld(children ...htmx.Node) htmx.Node {
    return htmx.Div(
        htmx.ClassNames{
            "font-semibold",
        },
        htmx.Text("Hello World"),
        htmx.Div(
            htmx.ClassNames{
                "text-red-500",
            },
            htmx.Group(children...),
        ),
    )
}

Styling of components is done with the htmx.ClassNames type.

func HelloWorld() htmx.Node {
    return htmx.Div(
        htmx.ClassNames{
            tailwind.FontSemibold: true,
            "text-red-500": true,
        },
        htmx.Text("Hello World"),
    )
}

There are also helpers to make the life with styling easier by merging classes.

func HelloWorld(classes htmx.ClassNames) htmx.Node {
    return htmx.Div(
        htmx.Merge(
            htmx.ClassNames{
                "font-semibold",
                "text-red-500",
            },
            classes,
        )
        htmx.Text("Hello World"),
    )
}

There is alos another pattern to create a component. This enables you to track state and to use the component in a more declarative way.

type Page struct {
	htmx.Node
}

func NewPage(title, body string) *Page {
	return &Page{
		Node: htmx.HTML5(
			htmx.HTML5Props{
				Title: title,
			},
			htmx.Body(
				htmx.Div(
					htmx.Text(body),
				),
			),
		),
	}
}

🧩 Import map

An import map is a JSON object that allows developers to control how the browser resolves module specifiers when importing JavaScript modules.

htmx.Imports(
    htmx.ImportsProp{
        Resolver: cache.New(jsdeliver.New()),
        Pkgs: []imports.ExactPackage{
            {
                Name:    "htmx.org",
                Version: "2.0.4",
            },
        },
        Requires: []imports.Require{
            {
                File: "dist/htmx.esm.js",
            },
        },
    }
),

Import maps let you import JavaScript modules using logical names that map to versioned/digested files – directly from the browser. So you can build modern JavaScript applications using JavaScript libraries made for ES modules (ESM) without the need for transpiling or bundling. This frees you from needing Webpack, Yarn, npm, or any other part of the JavaScript toolchain. All you need is the asset pipeline that's already included in Rails.

πŸ„β€β™€οΈ Icons

The package has support for Heroicons. The support is for the outline and solid icons.

icon := heroicons.AcademicCapDefaultOutline(heroicons.IconProps{})
icon.Render(os.Stdout)

πŸ–±οΈ Web Components

Web components work great with HTMX and are the idiomatic way to add interactive features to web applications.

πŸ“„ Examples

See examples to understand the provided interfaces.

🏎️ Benchmarks

make bench

License

MIT

Documentation ΒΆ

Overview ΒΆ

Package htmx provides a set of functions for generating HTML attributes as nodes. These attributes can be used in conjunction with the Fiber framework and the htmx library.

Index ΒΆ

Examples ΒΆ

Constants ΒΆ

View Source
const (
	TriggerClick        = "click"
	TriggerClickOnce    = TriggerClick + " once"
	TriggerDblClick     = JSEventTypeDblClickEvent
	TriggerKeyUpEnter   = "keyup[keyCode==13]"
	TriggerEnterPressed = TriggerKeyUpEnter
	TriggerBlur         = "blur"
	TriggerEvery1s      = "every:1s"
	TriggerEvery2s      = "every:2s"
	TriggerEvery5s      = "every:5s"
	TriggerEvery10s     = "every:10s"
	TriggerEvery30s     = "every:30s"
	TriggerEvery1m      = "every:1m"
	TriggerLoad         = "onload"
)
View Source
const (
	ElementType = NodeType(iota)
	AttributeType
)
View Source
const (
	HxClssNameAddedSelector     = ".htmx-added"
	HxClssNameIndicatorSelector = ".htmx-indicator"
	HxClssNameRequestSelector   = ".htmx-request"
	HxClssNameSettlingSelector  = ".htmx-settling"
	HxClssNameSwappingSelector  = ".htmx-swapping"
)

Variables ΒΆ

View Source
var (
	HxDefaultSwapDuration = 0 * time.Millisecond
	HxDefaultSettleDelay  = 20 * time.Millisecond
)

Functions ΒΆ

func JSONSerializeOrEmpty ΒΆ

func JSONSerializeOrEmpty(data any) string

JSONSerializeOrEmpty returns a JSON serialized string of the provided data or an empty string if the serialization fails.

Types ΒΆ

type ClassNames ΒΆ

type ClassNames map[string]bool

ClassNames represents a set of class names.

func Merge ΒΆ

func Merge(classNames ...ClassNames) ClassNames

Merge returns a new ClassNames object that is the result of merging the provided ClassNames objects.

func (ClassNames) Read ΒΆ added in v0.5.4

func (c ClassNames) Read(p []byte) (int, error)

Read reads the class names into the provided byte slice.

func (ClassNames) Render ΒΆ

func (c ClassNames) Render(w io.Writer) error

Render writes the class names to the provided writer.

func (ClassNames) String ΒΆ

func (c ClassNames) String() string

String returns the string representation of the ClassNames.

func (ClassNames) Type ΒΆ

func (c ClassNames) Type() NodeType

Type returns the node type of the ClassNames.

type ErrBoundaryFunc ΒΆ

type ErrBoundaryFunc func() Node

ErrBoundaryFunc is a function that returns a node.

type Errors ΒΆ

type Errors[K comparable] map[K]error

Errors is a slice of errors.

type FallbackFunc ΒΆ

type FallbackFunc func(error) Node

FallbackFunc is a function that returns a node.

type HTML5Props ΒΆ

type HTML5Props struct {
	// Title is the title of the HTML document.
	Title string
	// Description is the description of the HTML document.
	Description string
	// Language is the language of the HTML document.
	Language string
	// Head is the head section of the HTML document.
	Head []Node
	// Attributes are the attributes to be included in the HTML document.
	Attributes []Node
}

HTML5Props represents the properties for an HTML5 document.

type HXSwapStyle ΒΆ

type HXSwapStyle string

HxSwapStyle ...

const (
	HxSwapInnerHTML   HXSwapStyle = "innerHTML"
	HxSwapOuterHTML   HXSwapStyle = "outerHTML"
	HxSwapBeforeBegin HXSwapStyle = "beforebegin"
	HxSwapAfterBegin  HXSwapStyle = "afterbegin"
	HxSwapBeforeEnd   HXSwapStyle = "beforeend"
	HxSwapAfterEnd    HXSwapStyle = "afterend"
	HxSwapDelete      HXSwapStyle = "delete"
	HxSwapNone        HXSwapStyle = "none"
)

func (HXSwapStyle) String ΒΆ

func (s HXSwapStyle) String() string

String ...

type HxAttribute ΒΆ

const (
	HxAttributeBoost       HxAttribute = "hx-boost"
	HxAttributeGet         HxAttribute = "hx-get"
	HxAttributePost        HxAttribute = "hx-post"
	HxAttributePushURL     HxAttribute = "hx-push-url"
	HxAttributeTarget      HxAttribute = "hx-target"
	HxAttributeSelect      HxAttribute = "hx-select"
	HxAttributeSelectOob   HxAttribute = "hx-select-oob"
	HxAttributeSwap        HxAttribute = "hx-swap"
	HxAttributeSwapOob     HxAttribute = "hx-swap-oob"
	HxAttributeTrigger     HxAttribute = "hx-trigger"
	HxAttributeConfirm     HxAttribute = "hx-confirm"
	HxAttributePrompt      HxAttribute = "hx-prompt"
	HxAttributeDelete      HxAttribute = "hx-delete"
	HxAttributeOn          HxAttribute = "hx-on"
	HxAttributePut         HxAttribute = "hx-put"
	HxAttributePatch       HxAttribute = "hx-patch"
	HxAttributeIndicator   HxAttribute = "hx-indicator"
	HxAttributeEncoding    HxAttribute = "hx-encoding"
	HxAttributeExt         HxAttribute = "hx-ext"
	HxAttributeTarget404   HxAttribute = "hx-target-404"
	HxAttributeTarget403   HxAttribute = "hx-target-403"
	HxAttributeTarget401   HxAttribute = "hx-target-401"
	HxAttributeTarget500   HxAttribute = "hx-target-500"
	HxAttributeTarget5xx   HxAttribute = "hx-target-5xx"
	HxAttributeTarget4xx   HxAttribute = "hx-target-4xx"
	HxAttributeTargetError HxAttribute = "hx-target-error"
	HxAttributeTarget50x   HxAttribute = "hx-target-50x"
	HxAttributeDisable     HxAttribute = "hx-disable"
	HxAttributeDisabledElt HxAttribute = "hx-disabled-elt"
	HxAttributeValidate    HxAttribute = "hx-validate"
	HxAttributeInclude     HxAttribute = "hx-include"
	HxAttributeHeaders     HxAttribute = "hx-headers"
	HxAttributeVars        HxAttribute = "hx-vars"
	HxAttributeSync        HxAttribute = "hx-sync"
	HxAttributeParams      HxAttribute = "hx-params"
	HxAttributeVals        HxAttribute = "hx-vals"
)

func (HxAttribute) String ΒΆ

func (a HxAttribute) String() string

type HxClassName ΒΆ

type HxClassName string

HxClassName represents a class name for htmx elements.

const (
	HxClassNameAdded     HxClassName = "htmx-added"
	HxClassNameIndicator HxClassName = "htmx-indicator"
	HxClassNameRequest   HxClassName = "htmx-request"
	HxClassNameSettling  HxClassName = "htmx-settling"
	HxClassNameSwapping  HxClassName = "htmx-swapping"
)

func (HxClassName) String ΒΆ

func (c HxClassName) String() string

String returns the string representation of the HxClassName.

type HxEventType ΒΆ

type HxEventType string

HxEventType represents the type of htmx event.

const (
	HxEventTypeAbort                      HxEventType = "htmx:abort"
	HxEventTypeAfterLoad                  HxEventType = "htmx:afterLoad"
	HxEventTypeAfterProcessNode           HxEventType = "htmx:afterProcessNode"
	HxEventTypeAfterRequest               HxEventType = "htmx:afterRequest"
	HxEventTypeBeforeHistorySaveEvent     HxEventType = "htmx:beforeHistorySave"
	HxEventTypeBeforeOnAbort              HxEventType = "htmx:beforeOnAbort"
	HxEventTypeBeforeOnConfigRequest      HxEventType = "htmx:beforeOnConfigRequest"
	HxEventTypeBeforeOnConfigSwap         HxEventType = "htmx:beforeOnConfigSwap"
	HxEventTypeBeforeOnConfigTrigger      HxEventType = "htmx:beforeOnConfigTrigger"
	HxEventTypeBeforeOnError              HxEventType = "htmx:beforeOnError"
	HxEventTypeBeforeOnLoad               HxEventType = "htmx:beforeOnLoad"
	HxEventTypeBeforeOnRequest            HxEventType = "htmx:beforeOnRequest"
	HxEventTypeBeforeOnSettle             HxEventType = "htmx:beforeOnSettle"
	HxEventTypeBeforeOnSwap               HxEventType = "htmx:beforeOnSwap"
	HxEventTypeBeforeOnTrigger            HxEventType = "htmx:beforeOnTrigger"
	HxEventTypeBeforeRequest              HxEventType = "htmx:beforeRequest"
	HxEventTypeBeforeSettle               HxEventType = "htmx:beforeSettle"
	HxEventTypeBeforeSwap                 HxEventType = "htmx:beforeSwap"
	HxEventTypeConfigRequest              HxEventType = "htmx:configRequest"
	HxEventTypeConfigSwap                 HxEventType = "htmx:configSwap"
	HxEventTypeConfigTrigger              HxEventType = "htmx:configTrigger"
	HxEventTypeError                      HxEventType = "htmx:error"
	HxEventTypeHistoryCacheErrorEvent     HxEventType = "htmx:historyCacheError"
	HxEventTypeHistoryCacheMissErrorEvent HxEventType = "htmx:historyCacheMissError"
	HxEventTypeHistoryCacheMissEvent      HxEventType = "htmx:historyCacheMiss"
	HxEventTypeHistoryCacheMissLoadEvent  HxEventType = "htmx:historyCacheMissLoad"
	HxEventTypeHistoryRestoreEvent        HxEventType = "htmx:historyRestore"
	HxEventTypeLoad                       HxEventType = "htmx:load"
	HxEventTypeNoSSESourceErrorEvent      HxEventType = "htmx:noSSESourceError"
	HxEventTypeOnAbort                    HxEventType = "htmx:onAbort"
	HxEventTypeOnConfigRequest            HxEventType = "htmx:onConfigRequest"
	HxEventTypeOnConfigSwap               HxEventType = "htmx:onConfigSwap"
	HxEventTypeOnConfigTrigger            HxEventType = "htmx:onConfigTrigger"
	HxEventTypeOnError                    HxEventType = "htmx:onError"
	HxEventTypeOnLoad                     HxEventType = "htmx:onLoad"
	HxEventTypeOnLoadErrorEvent           HxEventType = "htmx:onLoadError"
	HxEventTypeOnRequest                  HxEventType = "htmx:onRequest"
	HxEventTypeOnSettle                   HxEventType = "htmx:onSettle"
	HxEventTypeOnSwap                     HxEventType = "htmx:onSwap"
	HxEventTypeOnTrigger                  HxEventType = "htmx:onTrigger"
	HxEventTypeOobAfterSwapEvent          HxEventType = "htmx:oobAfterSwap"
	HxEventTypeOobBeforeSwapEvent         HxEventType = "htmx:oobBeforeSwap"
	HxEventTypePromptEvent                HxEventType = "htmx:prompt"
	HxEventTypePushedIntoHistoryEvent     HxEventType = "htmx:pushedIntoHistory"
	HxEventTypeRequest                    HxEventType = "htmx:request"
	HxEventTypeResponseErrorEvent         HxEventType = "htmx:responseError"
	HxEventTypeSendErrorEvent             HxEventType = "htmx:sendError"
	HxEventTypeSettle                     HxEventType = "htmx:settle"
	HxEventTypeSseAfterMessageEvent       HxEventType = "htmx:sseAfterMessage"
	HxEventTypeSseBeforeMessageEvent      HxEventType = "htmx:sseBeforeMessage"
	HxEventTypeSseClosedEvent             HxEventType = "htmx:sseClose"
	HxEventTypeSseConnectedEvent          HxEventType = "htmx:sseOpen"
	HxEventTypeSseConnectingEvent         HxEventType = "htmx:sseConnecting"
	HxEventTypeSseErrorEvent              HxEventType = "htmx:sseError"
	HxEventTypeSSEErrorEvent              HxEventType = "htmx:sseError"
	HxEventTypeSSEOpenEvent               HxEventType = "htmx:sseOpen"
	HxEventTypeSwap                       HxEventType = "htmx:swap"
	HxEventTypeSwapErrorEvent             HxEventType = "htmx:swapError"
	HxEventTypeTargetErrorEvent           HxEventType = "htmx:targetError"
	HxEventTypeTimeoutEvent               HxEventType = "htmx:timeout"
	HxEventTypeTrigger                    HxEventType = "htmx:trigger"
	HxEventTypeValidationFailedEvent      HxEventType = "htmx:validation:failed"
	HxEventTypeValidationHaltedEvent      HxEventType = "htmx:validation:halted"
	HxEventTypeValidationValidateEvent    HxEventType = "htmx:validation:validate"
	HxEventTypeXhrAbortEvent              HxEventType = "htmx:xhr:abort"
	HxEventTypeXhrLoadEndEvent            HxEventType = "htmx:xhr:loadend"
	HxEventTypeXhrLoadStartEvent          HxEventType = "htmx:xhr:loadstart"
	HxEventTypeXhrProgressEvent           HxEventType = "htmx:xhr:progress"
	HxEventTypeOobErrorNoTargetEvent      HxEventType = "htmx:oobErrorNoTarget"
)

List of predefined htmx event types. See: https://htmx.org/reference/#events

func (HxEventType) String ΒΆ

func (e HxEventType) String() string

String returns the string representation of the HxEventType.

type HxExtType ΒΆ

type HxExtType string

HxExtType is a type for htmx extension types.

const (
	HXDebug                  HxExtType = "debug"                 // The debug extension allows you to debug htmx requests.
	HxExtClassTools          HxExtType = "class-tools"           // The class-tools extension allows you to add and remove classes from elements.
	HxExtClientSideTemplates HxExtType = "client-side-templates" // The client-side-templates extension allows you to use client-side templates to render the response.
	HxExtIgnoreDebug         HxExtType = "ignore:debug"          // The ignore:debug extension allows you to ignore the debug header.
	HxExtJSON                HxExtType = "json-enc"              // The json-enc extension allows you to specify the JSON encoding for the response.
	HxExtMultiSwap           HxExtType = "multi-swap"            // The multi-swap extension allows you to swap multiple elements in a single response.
	HxExtPathDeps            HxExtType = "path-deps"             // The path-deps extension allows you to specify the dependencies for a path.
	HxExtSSE                 HxExtType = "sse"                   // The sse extension allows you to use Server-Sent Events (SSE) to stream updates to the client.
	HxResponseTargets        HxExtType = "response-targets"      // The response-target extension allows you to specify the target for the response.
)

func (HxExtType) String ΒΆ

func (v HxExtType) String() string

String returns the string representation of the htmx extension type.

type HxSwapDirection ΒΆ

type HxSwapDirection string

HxSwapDirection ...

const (
	HxSwapDirectionTop    HxSwapDirection = "top"
	HxSwapDirectionBottom HxSwapDirection = "bottom"
)

func (HxSwapDirection) String ΒΆ

func (s HxSwapDirection) String() string

String ...

type HxSwapScrolling ΒΆ

type HxSwapScrolling struct {
	// contains filtered or unexported fields
}

HxSwapScrolling is used to define the scrolling behavior of the swap operation.

func (*HxSwapScrolling) String ΒΆ

func (s *HxSwapScrolling) String() string

String is used to return the string representation of the hx-swap-scrolling attribute.

type HxSwapScrollingMode ΒΆ

type HxSwapScrollingMode string

HxSwapScrollingMode ...

const (
	HxSwapScrollingScroll HxSwapScrollingMode = "scroll"
	HxSwapScrollingShow   HxSwapScrollingMode = "show"
)

func (HxSwapScrollingMode) String ΒΆ

func (s HxSwapScrollingMode) String() string

String ...

type HxSwapTiming ΒΆ

type HxSwapTiming struct {
	// contains filtered or unexported fields
}

HxSwapTiming is used to define the timing of the swap operation.

func (*HxSwapTiming) String ΒΆ

func (s *HxSwapTiming) String() string

String returns the string representation of the hx-swap attribute.

type HxSwapTimingMode ΒΆ

type HxSwapTimingMode string

HxSwapTimingMode ...

const (
	HxTimingSwap   HxSwapTimingMode = "swap"
	HxTimingSettle HxSwapTimingMode = "settle"
)

func (HxSwapTimingMode) String ΒΆ

func (s HxSwapTimingMode) String() string

String ...

type ImportMap ΒΆ

type ImportMap struct {
	// Imports is a map of module specifiers to URLs.
	Imports map[string]string `json:"imports"`
	// Scopes is a map of scopes to maps of module specifiers to URLs.
	Scopes map[string]map[string]string `json:"scopes,omitempty"`
	// Integrity is a map of URLs to integrity metadata.
	Integrity map[string]string `json:"integrity,omitempty"`
}

ImportMap is a struct that represents an import map. sse https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap

func NewImportMap ΒΆ

func NewImportMap() ImportMap

NewImportMap creates a new import map.

type ImportsProp ΒΆ

type ImportsProp struct {
	Pkgs     []imports.ExactPackage
	Requires []imports.Require
	Resolver imports.Resolver
}

ImportsProp ...

type JSEventType ΒΆ

type JSEventType string

JSEventType represents the type of JavaScript event.

const (
	JSEventTypeClickEvent       JSEventType = "onclick"
	JSEventTypeChangeEvent      JSEventType = "onchange"
	JSEventTypeInputEvent       JSEventType = "oninput"
	JSEventTypeFocusEvent       JSEventType = "onfocus"
	JSEventTypeBlurEvent        JSEventType = "onblur"
	JSEventTypeKeyDownEvent     JSEventType = "onkeydown"
	JSEventTypeKeyUpEvent       JSEventType = "onkeyup"
	JSEventTypeKeyPressEvent    JSEventType = "onkeypress"
	JSEventTypeSubmitEvent      JSEventType = "onsubmit"
	JSEventTypeLoadDomEvent     JSEventType = "onload"
	JSEventTypeLoadEvent        JSEventType = "onload"
	JSEventTypeUnloadEvent      JSEventType = "onunload"
	JSEventTypeResizeEvent      JSEventType = "onresize"
	JSEventTypeScrollEvent      JSEventType = "onscroll"
	JSEventTypeDblClickEvent    JSEventType = "ondblclick"
	JSEventTypeMouseOverEvent   JSEventType = "onmouseover"
	JSEventTypeMouseOutEvent    JSEventType = "onmouseout"
	JSEventTypeMouseMoveEvent   JSEventType = "onmousemove"
	JSEventTypeMouseDownEvent   JSEventType = "onmousedown"
	JSEventTypeMouseUpEvent     JSEventType = "onmouseup"
	JSEventTypeContextMenuEvent JSEventType = "oncontextmenu"
	JSEventTypeDragStartEvent   JSEventType = "ondragstart"
	JSEventTypeDragEvent        JSEventType = "ondrag"
	JSEventTypeDragEnterEvent   JSEventType = "ondragenter"
	JSEventTypeDragLeaveEvent   JSEventType = "ondragleave"
	JSEventTypeDragOverEvent    JSEventType = "ondragover"
	JSEventTypeDropEvent        JSEventType = "ondrop"
	JSEventTypeDragEndEvent     JSEventType = "ondragend"
)

List of predefined JavaScript event types.

func (JSEventType) String ΒΆ

func (e JSEventType) String() string

String returns the string representation of the JSEventType.

type Node ΒΆ

type Node interface {
	Render(w io.Writer) error
	io.Reader
}

Node is a node in the HTML tree.

func A ΒΆ

func A(children ...Node) Node

A represents an HTML anchor element.

func Abbr ΒΆ

func Abbr(children ...Node) Node

Abbr represents an HTML abbr element.

func Accept ΒΆ

func Accept(v string) Node

Accept sets the accept attribute for file input elements.

func Action ΒΆ

func Action(v string) Node

Action sets the action attribute for form elements.

func Address ΒΆ

func Address(children ...Node) Node

Address represents an HTML address element.

func Alt ΒΆ

func Alt(v string) Node

Alt sets the alt attribute for image elements.

func Area ΒΆ

func Area(children ...Node) Node

Area represents an HTML area element.

func Aria ΒΆ

func Aria(name, v string) Node

Aria sets the aria-{name} attribute for elements.

func AriaLabel ΒΆ added in v0.5.5

func AriaLabel(v string) Node

AriaLabel sets the aria-label attribute for elements.

func Article ΒΆ

func Article(children ...Node) Node

Article represents an HTML article element.

func As ΒΆ

func As(v string) Node

As sets the as attribute for link elements.

func Aside ΒΆ

func Aside(children ...Node) Node

Aside represents an HTML aside element.

func Async ΒΆ

func Async() Node

Async sets the async attribute for script elements.

func Attribute ΒΆ

func Attribute(name string, value ...string) Node

Attribute is a node that renders an HTML attribute.

Example (Bool) ΒΆ
package main

import (
	"os"

	htmx "github.com/katallaxie/htmx"
	"github.com/katallaxie/pkg/conv"
)

func main() {
	_ = htmx.Attribute("disabled", conv.String(true)).Render(os.Stdout)
}
Output:

disabled="true"
Example (Name_value) ΒΆ
package main

import (
	"os"

	htmx "github.com/katallaxie/htmx"
)

func main() {
	_ = htmx.Attribute("href", "/").Render(os.Stdout)
}
Output:

href="/"

func Audio ΒΆ

func Audio(children ...Node) Node

Audio represents an HTML audio element.

func AutoComplete ΒΆ

func AutoComplete(v string) Node

AutoComplete sets the autocomplete attribute for form elements.

func AutoFocus ΒΆ

func AutoFocus() Node

AutoFocus sets the autofocus attribute for form elements.

func AutoPlay ΒΆ

func AutoPlay() Node

AutoPlay sets the autoplay attribute for media elements.

func B ΒΆ

func B(children ...Node) Node

B represents an HTML b element.

func Base ΒΆ

func Base(children ...Node) Node

Base represents an HTML base element.

func BlockQuote ΒΆ

func BlockQuote(children ...Node) Node

BlockQuote represents an HTML blockquote element.

func Body ΒΆ

func Body(children ...Node) Node

Body represents an HTML body element.

func Br ΒΆ

func Br(children ...Node) Node

Br represents an HTML line break element.

func Button ΒΆ

func Button(children ...Node) Node

Button represents an HTML button element.

func Canvas ΒΆ

func Canvas(children ...Node) Node

Canvas represents an HTML canvas element.

func Caption ΒΆ

func Caption(children ...Node) Node

Caption represents an HTML caption element.

func Charset ΒΆ

func Charset(v string) Node

Charset sets the charset attribute for meta elements.

func Checked ΒΆ

func Checked() Node

Checked sets the checked attribute for input elements.

func Cite ΒΆ

func Cite(children ...Node) Node

Cite represents an HTML cite element.

func Class ΒΆ

func Class(v string) Node

Class sets the class attribute for elements.

func ClipRule ΒΆ

func ClipRule(v string) Node

ClipRule returns an SVG attribute node for specifying the clip rule. The clip rule determines how the clipping path is applied to the SVG element. The value of the clip rule is specified as a string. Example usage: ClipRule("evenodd").

func Code ΒΆ

func Code(children ...Node) Node

Code represents an HTML code element.

func Col ΒΆ

func Col(children ...Node) Node

Col represents an HTML col element.

func ColGroup ΒΆ

func ColGroup(children ...Node) Node

ColGroup represents an HTML colgroup element.

func ColSpan ΒΆ

func ColSpan(v string) Node

ColSpan sets the colspan attribute for table cells.

func Cols ΒΆ

func Cols(v string) Node

Cols sets the cols attribute for textarea elements.

func Command ΒΆ added in v0.5.5

func Command(v string) Node

Command sets the command following the https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API.

func CommandFor ΒΆ added in v0.5.5

func CommandFor(v string) Node

CommandFor sets the command following the https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API.

func Comment ΒΆ

func Comment(comment string) Node

Comment represents an HTML comment.

func Content ΒΆ

func Content(v string) Node

Content sets the content attribute for meta elements.

func ContentEditable ΒΆ

func ContentEditable(v string) Node

ContentEditable sets the contenteditable attribute for elements.

func Controls ΒΆ

func Controls() Node

Controls sets the controls attribute for media elements.

func CrossOrigin ΒΆ

func CrossOrigin(v string) Node

CrossOrigin sets the crossorigin attribute for elements.

func CustomElement ΒΆ

func CustomElement(tag string, children ...Node) Node

CustomElement represents a custom HTML element.

func D ΒΆ

func D(v string) Node

D returns an SVG attribute node for specifying the path data. The path data defines the shape of the SVG path element. The value of the path data is specified as a string. Example usage: D("M10 10 L20 20").

func DElement ΒΆ

func DElement(children ...Node) Node

DElement represents an HTML del element.

func DataAttribute ΒΆ

func DataAttribute(name, v string) Node

DataAttribute sets the data-{name} attribute for elements.

func DataElement ΒΆ

func DataElement(children ...Node) Node

DataElement represents an HTML data element.

func DataList ΒΆ

func DataList(children ...Node) Node

DataList represents an HTML datalist element.

func Dd ΒΆ

func Dd(children ...Node) Node

Dd represents an HTML dd element.

func Defer ΒΆ

func Defer() Node

Defer sets the defer attribute for script elements.

func Details ΒΆ

func Details(children ...Node) Node

Details represents an HTML details element.

func Dfn ΒΆ

func Dfn(children ...Node) Node

Dfn represents an HTML dfn element.

func Dialog ΒΆ

func Dialog(children ...Node) Node

Dialog represents an HTML dialog element.

func Disabled ΒΆ

func Disabled() Node

Disabled sets the disabled attribute for form elements.

func Div ΒΆ

func Div(children ...Node) Node

Div represents an HTML div element.

func Dl ΒΆ

func Dl(children ...Node) Node

Dl represents an HTML dl element.

func Doctype ΒΆ

func Doctype(sibling Node) Node

Doctype represents the HTML doctype declaration.

func Dt ΒΆ

func Dt(children ...Node) Node

Dt represents an HTML dt element.

func Em ΒΆ

func Em(children ...Node) Node

Em represents an HTML em element.

func Embed ΒΆ

func Embed(children ...Node) Node

Embed represents an HTML embed element.

func Empty ΒΆ

func Empty() Node

Empty is a node that renders an empty string.

func EncType ΒΆ

func EncType(v string) Node

EncType sets the enctype attribute for form elements.

func ErrorBoundary ΒΆ

func ErrorBoundary(n ErrBoundaryFunc) Node

ErrorBoundary is a node that catches panics and renders an error.

func ErrorExists ΒΆ

func ErrorExists[K comparable](e Errors[K], key K, fn func(k K, v error) Node) Node

ErrorExists is a node that renders a child node if an error exists.

func Fallback ΒΆ

func Fallback(n Node, f FallbackFunc) Node

Fallback is a node that renders a fallback node if a condition is false.

func FieldSet ΒΆ

func FieldSet(children ...Node) Node

FieldSet represents an HTML fieldset element.

func Fieldset ΒΆ added in v0.5.3

func Fieldset(children ...Node) Node

Fieldset represents an HTML fieldset element.

func FigCaption ΒΆ

func FigCaption(children ...Node) Node

FigCaption represents an HTML figcaption element.

func Figure ΒΆ

func Figure(children ...Node) Node

Figure represents an HTML figure element.

func Fill ΒΆ

func Fill(v string) Node

Fill returns an SVG attribute node for specifying the fill color. The fill color determines the color used to fill the SVG element. The value of the fill color is specified as a string. Example usage: Fill("red").

func FillRule ΒΆ

func FillRule(v string) Node

FillRule returns an SVG attribute node for specifying the fill rule. The fill rule determines how the interior of the SVG element is filled. The value of the fill rule is specified as a string. Example usage: FillRule("evenodd").

func Filter ΒΆ

func Filter(f func(n Node) bool, children ...Node) []Node

Filter loops and filters the content.

func Footer(children ...Node) Node

Footer represents an HTML footer element.

func For ΒΆ

func For(v string) Node

For sets the for attribute for label elements.

func Form ΒΆ

func Form(children ...Node) Node

Form represents an HTML form element.

func FormAttribute ΒΆ

func FormAttribute(v string) Node

FormAttribute sets the form attribute for elements.

func FormElement ΒΆ

func FormElement(children ...Node) Node

FormElement represents an HTML form element.

func Fragment ΒΆ

func Fragment(children ...Node) Node

Fragment is a node that renders a fragment of nodes.

func G ΒΆ

func G(children ...Node) Node

G creates an SVG group element with the specified children. It is a convenience function that calls the Element function with "g" as the tag name.

func Group ΒΆ

func Group(children ...Node) Node

Group is a node that groups children nodes.

func H1 ΒΆ

func H1(children ...Node) Node

H1 represents an HTML h1 element.

func H2 ΒΆ

func H2(children ...Node) Node

H2 represents an HTML h2 element.

func H3 ΒΆ

func H3(children ...Node) Node

H3 represents an HTML h3 element.

func H4 ΒΆ

func H4(children ...Node) Node

H4 represents an HTML h4 element.

func H5 ΒΆ

func H5(children ...Node) Node

H5 represents an HTML h5 element.

func H6 ΒΆ

func H6(children ...Node) Node

H6 represents an HTML h6 element.

func HGroup ΒΆ

func HGroup(children ...Node) Node

HGroup represents an HTML hgroup element.

func HTML ΒΆ

func HTML(children ...Node) Node

HTML represents an HTML html element.

func HTML5 ΒΆ

func HTML5(props HTML5Props, body ...Node) Node

HTML5 generates an HTML5 document based on the provided properties.

func HandlebarsTemplate ΒΆ

func HandlebarsTemplate(v string) Node

HandlebarsTemplate sets the handlebars-template attribute to specify the handlebars template for the response.

func Head(children ...Node) Node

Head represents an HTML head element.

func Header(children ...Node) Node

Header represents an HTML header element.

func Height ΒΆ

func Height(v string) Node

Height sets the height attribute for elements.

func Hr ΒΆ

func Hr(children ...Node) Node

Hr represents an HTML horizontal rule element.

func Href ΒΆ

func Href(v string) Node

Href sets the href attribute for anchor elements.

func HxBoost ΒΆ

func HxBoost(v bool) Node

HxBoost sets the hx-boost attribute to enable or disable boosting.

func HxConfirm ΒΆ

func HxConfirm(msg string) Node

HxConfirm sets the hx-confirm attribute to display a confirmation message.

func HxDelete ΒΆ

func HxDelete(url string) Node

HxDelete sets the hx-delete attribute to specify the URL for DELETE requests.

func HxDisable ΒΆ

func HxDisable() Node

HxDisable sets the hx-disable attribute to disable htmx functionality.

func HxDisabledElt ΒΆ

func HxDisabledElt(target string) Node

HxDisabledElt sets the hx-disable-elt attribute to disable the target element.

func HxEncoding ΒΆ

func HxEncoding(enc string) Node

HxEncoding sets the hx-encoding attribute to specify the encoding type for form submission.

func HxExt ΒΆ

func HxExt(ext string) Node

HxExt sets the hx-ext attribute to specify the file extension for file uploads.

func HxGet ΒΆ

func HxGet(url string) Node

HxGet sets the hx-get attribute to specify the URL for GET requests.

func HxHeaders ΒΆ

func HxHeaders(headers map[string]string) Node

HxHeaders sets the hx-headers attribute to specify the headers for the request.

func HxInclude ΒΆ

func HxInclude(target string) Node

HxInclude sets the hx-include attribute to specify the target element for inclusion.

func HxIndicator ΒΆ

func HxIndicator(target string) Node

HxIndicator sets the hx-indicator attribute to specify the target element for showing an indicator.

func HxOn ΒΆ

func HxOn(target string, js string) Node

HxOn sets the hx-put-{target} attribute to specify the JavaScript code to execute on a PUT request.

func HxPatch ΒΆ

func HxPatch(url string) Node

HxPatch sets the hx-patch attribute to specify the URL for PATCH requests.

func HxPost ΒΆ

func HxPost(url string) Node

HxPost sets the hx-post attribute to specify the URL for POST requests.

func HxPrompt ΒΆ

func HxPrompt(msg string) Node

HxPrompt sets the hx-prompt attribute to display a prompt message.

func HxPushURL ΒΆ

func HxPushURL(v bool) Node

HxPushURL sets the hx-push-url attribute to enable or disable URL pushing.

func HxPut ΒΆ

func HxPut(url string) Node

HxPut sets the hx-put attribute to specify the URL for PUT requests.

func HxSSE ΒΆ

func HxSSE() Node

HxSSE sets the sse attribute to specify the Server-Sent Events (SSE) URL.

func HxSSEConnect ΒΆ

func HxSSEConnect(url string) Node

HxSSEConnect sets the sse-connect attribute to specify the Server-Sent Events (SSE) URL.

func HxSSESwap ΒΆ

func HxSSESwap(target string) Node

HxSSESwap sets the sse-swap attribute to specify the Server-Sent Events (SSE) swap.

func HxSelect ΒΆ

func HxSelect(target string) Node

HxSelect sets the hx-select attribute to specify the target element for selection.

func HxSelectOob ΒΆ

func HxSelectOob(target string) Node

HxSelectOob sets the hx-select-oob attribute to specify the target element for out-of-band selection.

func HxSwap ΒΆ

func HxSwap(target string) Node

HxSwap sets the hx-swap attribute to specify the target element for swapping.

func HxSwapOob ΒΆ

func HxSwapOob(target string) Node

HxSwapOob sets the hx-swap-oob attribute to specify the target element for out-of-band swapping.

func HxTarget ΒΆ

func HxTarget(target string) Node

HxTarget sets the hx-target attribute to specify the target element for the response.

func HxTarget4xx ΒΆ

func HxTarget4xx(target string) Node

HxTarget4xx sets the hx-target-4xx attribute to specify the target element for 4xx responses.

func HxTarget5xx ΒΆ

func HxTarget5xx(target string) Node

HxTarget5xx sets the hx-target-5xx attribute to specify the target element for 5xx responses.

func HxTarget50x ΒΆ

func HxTarget50x(target string) Node

HxTarget50x sets the hx-target-50x attribute to specify the target element for 50x responses.

func HxTarget401 ΒΆ

func HxTarget401(target string) Node

HxTarget401 sets the hx-target-401 attribute to specify the target element for 401 responses.

func HxTarget403 ΒΆ

func HxTarget403(target string) Node

HxTarget403 sets the hx-target-403 attribute to specify the target element for 403 responses.

func HxTarget404 ΒΆ

func HxTarget404(target string) Node

HxTarget404 sets the hx-target-404 attribute to specify the target element for 404 responses.

func HxTarget500 ΒΆ

func HxTarget500(target string) Node

HxTarget500 sets the hx-target-500 attribute to specify the target element for 500 responses.

func HxTargetError ΒΆ

func HxTargetError(target string) Node

HxTargetError sets the hx-target-error attribute to specify the target element for error responses.

func HxTrigger ΒΆ

func HxTrigger(targets ...string) Node

HxTrigger sets the hx-trigger attribute to specify the target element for triggering an event.

func HxValidate ΒΆ

func HxValidate(v bool) Node

HxValidate sets the hx-validate attribute to enable or disable form validation.

func HyperScript ΒΆ

func HyperScript(v string) Node

HyperScript sets the _ attribute to specify the hyperscript for the response.

func I ΒΆ

func I(children ...Node) Node

I represents an HTML i element.

func ID ΒΆ

func ID(v string) Node

ID sets the id attribute for elements.

func IFrame ΒΆ

func IFrame(children ...Node) Node

IFrame represents an HTML iframe element.

func If ΒΆ

func If(condition bool, n Node) Node

If is a node that renders a child node if a condition is true.

func IfElse ΒΆ

func IfElse(condition bool, n, elseN Node) Node

IfElse is a node that renders a child node if a condition is true, otherwise it renders another child node.

func Img ΒΆ

func Img(children ...Node) Node

Img represents an HTML img element.

func Imports ΒΆ

func Imports(props ImportsProp) Node

Imports ...

func Input ΒΆ

func Input(children ...Node) Node

Input represents an HTML input element.

func Ins ΒΆ

func Ins(children ...Node) Node

Ins represents an HTML ins element.

func Integrity ΒΆ

func Integrity(v string) Node

Integrity sets the integrity attribute for elements.

func Is ΒΆ

func Is(v string) Node

Is sets the is attribute for custom elements.

func JSEvent ΒΆ

func JSEvent(e JSEventType, value ...string) Node

JSEvent is a type that represents JavaScript events.

func Kbd ΒΆ

func Kbd(children ...Node) Node

Kbd represents an HTML kbd element.

func KeyExists ΒΆ

func KeyExists[K comparable, V any](m map[K]V, key K, fn func(k K, v V) Node) Node

KeyExists is a node that renders a child node if a key exists in a map.

func Label ΒΆ

func Label(children ...Node) Node

Label represents an HTML label element.

func Lang ΒΆ

func Lang(v string) Node

Lang sets the lang attribute for elements.

func Legend ΒΆ

func Legend(children ...Node) Node

Legend represents an HTML legend element.

func Li ΒΆ

func Li(children ...Node) Node

Li represents an HTML li element.

func Link(children ...Node) Node

Link represents an HTML link element.

func List ΒΆ

func List(v string) Node

List sets the list attribute for input elements.

func Loading ΒΆ

func Loading(v string) Node

Loading sets the loading attribute for elements.

func Loop ΒΆ

func Loop() Node

Loop sets the loop attribute for media elements.

func Main ΒΆ

func Main(children ...Node) Node

Main represents an HTML main element.

func Mark ΒΆ

func Mark(children ...Node) Node

Mark represents an HTML mark element.

func Markdown ΒΆ

func Markdown(source []byte, opts ...goldmark.Option) Node

Markdown is a node that renders a markdown.

func Max ΒΆ

func Max(v string) Node

Max sets the max attribute for input elements.

func MaxLength ΒΆ

func MaxLength(v string) Node

MaxLength sets the maxlength attribute for input elements.

func Meta ΒΆ

func Meta(children ...Node) Node

Meta represents an HTML meta element.

func Meter ΒΆ

func Meter(children ...Node) Node

Meter represents an HTML meter element.

func Method ΒΆ

func Method(v string) Node

Method sets the method attribute for form elements.

func Min ΒΆ

func Min(v string) Node

Min sets the min attribute for input elements.

func MinLength ΒΆ

func MinLength(v string) Node

MinLength sets the minlength attribute for input elements.

func Multiple ΒΆ

func Multiple() Node

Multiple sets the multiple attribute for input elements.

func MustacheTemplate ΒΆ

func MustacheTemplate(v string) Node

MustacheTemplate sets the mustache-template attribute to specify the mustache template for the response.

func Muted ΒΆ

func Muted() Node

Muted sets the muted attribute for media elements.

func Name ΒΆ

func Name(v string) Node

Name sets the name attribute for elements.

func Nav(children ...Node) Node

Nav represents an HTML nav element.

func NoScript ΒΆ

func NoScript(children ...Node) Node

NoScript represents an HTML noscript element.

func NoValidate ΒΆ

func NoValidate() Node

NoValidate sets the novalidate attribute for form elements.

func NunjucksTemplate ΒΆ

func NunjucksTemplate(v string) Node

NunjucksTemplate sets the nunjucks-template attribute to specify the nunjucks template for the response.

func Object ΒΆ

func Object(children ...Node) Node

Object represents an HTML object element.

func Ol ΒΆ

func Ol(children ...Node) Node

Ol represents an HTML ol element.

func OnClick ΒΆ

func OnClick(v string) Node

OnClick sets the onclick attribute for elements.

func OnePasswordIgnore ΒΆ

func OnePasswordIgnore() Node

OnePasswordIgnore sets the data-1p-ignore attribute for elements.

func OptGroup ΒΆ

func OptGroup(children ...Node) Node

OptGroup represents an HTML optgroup element.

func Option ΒΆ

func Option(children ...Node) Node

Option represents an HTML option element.

func P ΒΆ

func P(children ...Node) Node

P represents an HTML p element.

func Param ΒΆ

func Param(children ...Node) Node

Param represents an HTML param element.

func Path ΒΆ

func Path(children ...Node) Node

Path creates an SVG path element with the specified children. It is a convenience function that calls the Element function with "path" as the tag name.

func Pattern ΒΆ

func Pattern(v string) Node

Pattern sets the pattern attribute for input elements.

func Picture ΒΆ

func Picture(children ...Node) Node

Picture represents an HTML picture element.

func Placeholder ΒΆ

func Placeholder(v string) Node

Placeholder sets the placeholder attribute for input elements.

func PlaysInline ΒΆ

func PlaysInline() Node

PlaysInline sets the playsinline attribute for media elements.

func Popover ΒΆ added in v0.5.5

func Popover() Node

Popover make a element a popover target. See: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/popover

func Poster ΒΆ

func Poster(v string) Node

Poster sets the poster attribute for video elements.

func Pre ΒΆ

func Pre(children ...Node) Node

Pre represents an HTML pre element.

func Preload ΒΆ

func Preload(v string) Node

Preload sets the preload attribute for media elements.

func Progress ΒΆ

func Progress(children ...Node) Node

Progress represents an HTML progress element.

func Q ΒΆ

func Q(children ...Node) Node

Q represents an HTML q element.

func Raw ΒΆ

func Raw(t string) Node

Raw is a node that renders raw HTML.

func RawScript ΒΆ

func RawScript(t string) Node

RawScript is a node that renders a raw script.

func Rawf ΒΆ

func Rawf(format string, a ...interface{}) Node

Rawf is a node that renders a formatted raw HTML.

func ReadOnly ΒΆ

func ReadOnly() Node

ReadOnly sets the readonly attribute for form elements.

func Reduce ΒΆ

func Reduce(f func(prev Node, next Node) Node, children ...Node) Node

Reduce reduces the content to a single node.

func Rel ΒΆ

func Rel(v string) Node

Rel sets the rel attribute for link elements.

func Required ΒΆ

func Required() Node

Required sets the required attribute for form elements.

func Role ΒΆ

func Role(v string) Node

Role sets the role attribute for elements.

func RowSpan ΒΆ

func RowSpan(v string) Node

RowSpan sets the rowspan attribute for table cells.

func Rows ΒΆ

func Rows(v string) Node

Rows sets the rows attribute for textarea elements.

func S ΒΆ

func S(children ...Node) Node

S represents an HTML s element.

func SVG ΒΆ

func SVG(children ...Node) Node

SVG creates an SVG element with the specified children. It sets the "xmlns" attribute to "http://www.w3.org/2000/svg". The children are rendered inside a group element.

func Samp ΒΆ

func Samp(children ...Node) Node

Samp represents an HTML samp element.

func Script ΒΆ

func Script(children ...Node) Node

Script represents an HTML script element.

func Section ΒΆ

func Section(children ...Node) Node

Section represents an HTML section element.

func Select ΒΆ

func Select(children ...Node) Node

Select represents an HTML select element.

func Selected ΒΆ

func Selected() Node

Selected sets the selected attribute for option elements.

func Slot ΒΆ

func Slot(children ...Node) Node

Slot represents an HTML slot element.

func Small ΒΆ

func Small(children ...Node) Node

Small represents an HTML small element.

func Source ΒΆ

func Source(children ...Node) Node

Source represents an HTML source element.

func Span ΒΆ

func Span(children ...Node) Node

Span represents an HTML span element.

func Src ΒΆ

func Src(v string) Node

Src sets the src attribute for elements.

func SrcSet ΒΆ

func SrcSet(v string) Node

SrcSet sets the srcset attribute for elements.

func Step ΒΆ

func Step(v string) Node

Step sets the step attribute for input elements.

func Stroke ΒΆ

func Stroke(v string) Node

Stroke returns an SVG attribute node for specifying the stroke color. The stroke color determines the color used to stroke the SVG element. The value of the stroke color is specified as a string. Example usage: Stroke("blue").

func StrokeWidth ΒΆ

func StrokeWidth(v string) Node

StrokeWidth returns an SVG attribute node for specifying the stroke width. The stroke width determines the thickness of the stroke applied to an SVG element. The value of the stroke width is specified as a string. Example usage: StrokeWidth("2px").

func Strong ΒΆ

func Strong(children ...Node) Node

Strong represents an HTML strong element.

func Style ΒΆ added in v0.5.2

func Style(children ...Node) Node

Style represents an HTML style element.

func StyleAttribute ΒΆ

func StyleAttribute(v string) Node

StyleAttribute sets the style attribute for elements.

func Sub ΒΆ

func Sub(children ...Node) Node

Sub represents an HTML sub element.

func Summary ΒΆ

func Summary(children ...Node) Node

Summary represents an HTML summary element.

func Sup ΒΆ

func Sup(children ...Node) Node

Sup represents an HTML sup element.

func TBody ΒΆ

func TBody(children ...Node) Node

TBody represents an HTML tbody element.

func TFoot ΒΆ

func TFoot(children ...Node) Node

TFoot represents an HTML tfoot element.

func THead ΒΆ

func THead(children ...Node) Node

THead represents an HTML thead element.

func TabIndex ΒΆ

func TabIndex(v string) Node

TabIndex sets the tabindex attribute for elements.

func Table ΒΆ

func Table(children ...Node) Node

Table represents an HTML table element.

func Target ΒΆ

func Target(v string) Node

Target sets the target attribute for elements.

func Td ΒΆ

func Td(children ...Node) Node

Td represents an HTML td element.

func Template ΒΆ

func Template(children ...Node) Node

Template represents an HTML template element.

func Text ΒΆ

func Text(t string) Node

Text is a node that renders a text.

func Textarea ΒΆ

func Textarea(children ...Node) Node

Textarea represents an HTML textarea element.

func Textf ΒΆ

func Textf(format string, a ...interface{}) Node

Textf is a node that renders a formatted text.

func Th ΒΆ

func Th(children ...Node) Node

Th represents an HTML th element.

func Time ΒΆ

func Time(children ...Node) Node

Time represents an HTML time element.

func Title ΒΆ

func Title(children ...Node) Node

Title represents an HTML title element.

func TitleAttribute ΒΆ

func TitleAttribute(v string) Node

TitleAttribute sets the title attribute for elements.

func TitleElement ΒΆ

func TitleElement(children ...Node) Node

TitleElement represents an HTML title element.

func Tr ΒΆ

func Tr(children ...Node) Node

Tr represents an HTML tr element.

func Track ΒΆ

func Track(children ...Node) Node

Track represents an HTML track element.

func Type ΒΆ

func Type(v string) Node

Type sets the type attribute for elements.

func U ΒΆ

func U(children ...Node) Node

U represents an HTML u element.

func Ul ΒΆ

func Ul(children ...Node) Node

Ul represents an HTML ul element.

func UnsafeRaw ΒΆ

func UnsafeRaw(t string) Node

UnsafeRaw is a node that renders an unsafe raw HTML.

func UnsafeRawScript ΒΆ

func UnsafeRawScript(t string) Node

UnsafeRawScript is a node that renders an unsafe raw script.

func UnsafeRawf ΒΆ

func UnsafeRawf(format string, a ...interface{}) Node

UnsafeRawf is a node that renders an unsafe formatted raw HTML.

func Value ΒΆ

func Value(v string) Node

Value sets the value attribute for elements.

func Var ΒΆ

func Var(children ...Node) Node

Var represents an HTML var element.

func Video ΒΆ

func Video(children ...Node) Node

Video represents an HTML video element.

func ViewBox ΒΆ

func ViewBox(v string) Node

ViewBox returns an SVG attribute node for specifying the viewBox. The viewBox defines the position and size of the SVG element's viewport. The value of the viewBox is specified as a string. Example usage: ViewBox("0 0 100 100").

func Wbr ΒΆ

func Wbr(children ...Node) Node

Wbr represents an HTML wbr element.

func Width ΒΆ

func Width(v string) Node

Width sets the width attribute for elements.

func XSLTTemplat ΒΆ

func XSLTTemplat(v string) Node

XSLTTemplat sets the xslt-template attribute to specify the xslt template for the response.

type NodeFunc ΒΆ

type NodeFunc func(io.Writer) error

NodeFunc is a function that renders a node.

func Element ΒΆ

func Element(name string, children ...Node) NodeFunc

Element is a node that renders an HTML element.

Example (A) ΒΆ
_ = Element("a").Render(os.Stdout)
Output:

<a></a>
Example (Div) ΒΆ
_ = Element("div").Render(os.Stdout)
Output:

<div></div>
Example (Tag) ΒΆ
package main

import (
	"os"

	htmx "github.com/katallaxie/htmx"
)

func main() {
	_ = htmx.Element("div").Render(os.Stdout)
}
Output:

<div></div>

func (NodeFunc) Read ΒΆ added in v0.5.4

func (n NodeFunc) Read(p []byte) (int, error)

Read is a node that reads from the node.

func (NodeFunc) Render ΒΆ

func (n NodeFunc) Render(w io.Writer) error

Render renders the node.

func (NodeFunc) String ΒΆ

func (n NodeFunc) String() string

String returns the node as a string.

func (NodeFunc) Type ΒΆ

func (n NodeFunc) Type() NodeType

Type returns the node type.

type NodeType ΒΆ

type NodeType int

NodeType is the type of a node.

type NodeTypeDescriptor ΒΆ

type NodeTypeDescriptor interface {
	Type() NodeType
}

NodeTypeDescriptor is a node that has a type.

type Nodes ΒΆ

type Nodes []Node

Nodes is a slice of nodes.

func ForEach ΒΆ

func ForEach[S ~[]E, E comparable](s S, f func(E, int) Node) Nodes

ForEach loops over the content.

func Map ΒΆ

func Map[T1 comparable, T2 any](m map[T1]T2, f func(T1, T2) Node) Nodes

Map is using a map to transform into htmx nodes.

type Swap ΒΆ

type Swap struct {
	// contains filtered or unexported fields
}

Swap is a component for the htmx swap extension.

func NewSwap ΒΆ

func NewSwap() *Swap

NewSwap creates a new Swap instance with the default style set to HxSwapInnerHTML.

func (*Swap) FocusScroll ΒΆ

func (s *Swap) FocusScroll(focusScroll bool) *Swap

FocusScroll is a boolean attribute that indicates whether the element should be scrolled into view after the swap.

func (*Swap) IgnoreTitle ΒΆ

func (s *Swap) IgnoreTitle(ignoreTitle bool) *Swap

IgnoreTitle is a boolean attribute that indicates whether the title of the page should be ignored.

func (*Swap) Scroll ΒΆ

func (s *Swap) Scroll(direction HxSwapDirection, target ...string) *Swap

Scroll ...

func (*Swap) ScrollBottom ΒΆ

func (s *Swap) ScrollBottom(target ...string) *Swap

ScrollBottom ...

func (*Swap) ScrollTop ΒΆ

func (s *Swap) ScrollTop(target ...string) *Swap

ScrollTop ...

func (*Swap) Settle ΒΆ

func (s *Swap) Settle(swap ...time.Duration) *Swap

Settle modifies the amount of time that htmx will wait after receiving a response to settle the content.

func (*Swap) Show ΒΆ

func (s *Swap) Show(direction HxSwapDirection, target ...string) *Swap

Show ...

func (*Swap) ShowBottom ΒΆ

func (s *Swap) ShowBottom(target ...string) *Swap

ShowBottom ...

func (*Swap) ShowTop ΒΆ

func (s *Swap) ShowTop(target ...string) *Swap

ShowTop ...

func (*Swap) String ΒΆ

func (s *Swap) String() string

String returns the string representation of the Swap.

func (*Swap) Style ΒΆ

func (s *Swap) Style(style HXSwapStyle) *Swap

Style sets the style of the swap operation.

func (*Swap) Swap ΒΆ

func (s *Swap) Swap(swap ...time.Duration) *Swap

Swap modifies the amount of time that htmx will wait after receiving a response to swap the content.

func (*Swap) Transition ΒΆ

func (s *Swap) Transition(transition bool) *Swap

Transition is a boolean attribute that indicates whether the swap should be animated.

Directories ΒΆ

Path Synopsis
Package alerts provides functionality for managing and processing alerts within the system.
Package alerts provides functionality for managing and processing alerts within the system.
Package avatars provides components for rendering user avatars.
Package avatars provides components for rendering user avatars.
Package badges provides components for rendering user badges.
Package badges provides components for rendering user badges.
Package breadcrumbs provides components for rendering breadcrumbs.
Package breadcrumbs provides components for rendering breadcrumbs.
Package buttons provides components for rendering buttons.
Package buttons provides components for rendering buttons.
cmd
cli command
heroicons command
sidekickicons command
tailwind command
badge command
datalist command
drawer command
filter command
heroicons command
indicator command
login command
modal command
tables command
Package forms contains form components such as Filter and FilterOption.
Package forms contains form components such as Filter and FilterOption.
Package icons provides a set of icons for use in the application.
Package icons provides a set of icons for use in the application.
heroicons
Code generated by herogen; DO NOT EDIT.
Code generated by herogen; DO NOT EDIT.
sidekickicons
Code generated by herogen; DO NOT EDIT.
Code generated by herogen; DO NOT EDIT.
internal
Package modals provides structures and methods for handling modal dialogs in a web application.
Package modals provides structures and methods for handling modal dialogs in a web application.
Package skeletons provides skeleton components for various UI elements.
Package skeletons provides skeleton components for various UI elements.
Package `toasts` provides a simple way to display toast notifications in a web application.
Package `toasts` provides a simple way to display toast notifications in a web application.

Jump to

Keyboard shortcuts

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