h

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 6 Imported by: 0

README

hyper

A fast, type-safe HTML generator for Go.

Features

  • Auto-escaping - Strings are HTML-escaped automatically for security
  • Type-safe - Compile-time checking of your HTML structure
  • Zero dependencies - Pure Go standard library
  • Fast - Minimal allocations, direct writer output
  • Composable - Build complex layouts from simple components

Installation

go get github.com/assaidy/hyper

Quick Start

package main

import (
    "os"

    . "github.com/assaidy/hyper"
)

func main() {
    page := Empty(
        DoctypeHtml(),
        Html(
            Head(
                Title("My Page"),
            ),
            Body(
                H1("Hello, World!"),
                P("Auto-escaped: <script>alert('xss')</script>"),
            ),
        ),
    )
    
    if err := page.Render(os.Stdout); err != nil {
        panic(err)
    }
}

Usage

Basic Elements
// Strings are auto-escaped
Div("Hello", " ", "World")  // <div>Hello World</div>

P("<script>alert('xss')</script>")
// <p>&lt;script&gt;alert(&#39;xss&#39;)&lt;/script&gt;</p>

// Raw HTML (not escaped. use with caution)
Div(RawText("<svg>...</svg>")) // <svg>...</svg>

// Numbers and booleans are auto-converted
P("Count: ", 42)           // <p>Count: 42</p>
P("Active: ", true)        // <p>Active: true</p>
Attributes
Div(KV{AttrClass: "container", AttrId: "main"}, "Content")
// <div class="container" id="main">Content</div>
Conditional Rendering
// Show element only if condition is true
If(isLoggedIn, Div("Welcome back!"))

// Choose between two options
IfElse(isAdmin, Div("Admin"), Div("User"))
Lists and Iteration
items := []string{"Apple", "Banana"}

// Map over slice
Ul(
    MapSlice(items, func(item string) HyperNode {
        return Li(item)
    }),
)

// Repeat N times
Div(
    Repeat(3, func() HyperNode {
        return P("Repeated")
    }),
)
With Tailwind CSS
Div(KV{AttrClass: "bg-gray-100 min-h-screen p-8"},
    Div(KV{AttrClass: "max-w-4xl mx-auto"},
        H1(KV{AttrClass: "text-4xl font-bold text-gray-800"}, "Title"),
        P(KV{AttrClass: "text-gray-600 mt-2"}, "Description"),
        Button(KV{AttrClass: "px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"},
            "Click Me",
        ),
    ),
)
With HTMX
// Include htmx library from CDN
Script(KV{AttrSrc: "https://unpkg.com/[email protected]"})

// HTMX button that loads content
Button(KV{
    AttrClass:     "px-4 py-2 bg-blue-500 text-white rounded",
    AttrHxGet:      "/api/users",
    AttrHxTarget:   "#users-list",
    AttrHxSwap:     SwapOuterHtml,
},
    "Load Users",
)

// HTMX form
Form(KV{
    AttrHxPost:     "/api/submit",
    AttrHxTarget:   "#result",
    AttrClass:     "space-y-4",
},
    Input(KV{
        AttrType:  TypeText,
        AttrName:  "message",
        AttrClass: "border rounded px-3 py-2",
    }),
    Button(KV{AttrType: TypeSubmit, AttrClass: "bg-blue-500 text-white px-4 py-2 rounded"},
        "Submit",
    ),
)
Complete Example
package main

import (
    "os"

    . "github.com/assaidy/hyper"
    . "github.com/assaidy/hyper/htmx"
)

func main() {
    users := []string{"Alice", "Bob", "Charlie"}
    isAdmin := true

    page := Empty(
        DoctypeHtml(),
        Html(KV{AttrLang: "en"},
            Head(
                Title("Dashboard"),
                Script(KV{AttrSrc: "https://unpkg.com/[email protected]"}),
                Script(KV{AttrSrc: "https://cdn.tailwindcss.com"}),
            ),
            Body(KV{AttrClass: "bg-gray-100 p-8"},
                Div(KV{AttrClass: "max-w-2xl mx-auto"},
                    H1(KV{AttrClass: "text-3xl font-bold mb-4"}, "Dashboard"),
                    
                    // Conditional admin panel
                    If(isAdmin,
                        Div(KV{AttrClass: "bg-blue-50 p-4 rounded mb-4"},
                            P(KV{AttrClass: "font-semibold"}, "Admin Panel"),
                        ),
                    ),
                    
                    // User count
                    P("Total users: ", len(users)),

                    // HTMX button to refresh users
                    Button(KV{
                        AttrClass:      "px-4 py-2 bg-blue-500 text-white rounded mt-4",
                        AttrHxGet:      "/api/users",
                        AttrHxTarget:   "#users-list",
                        AttrHxSwap:     SwapOuterHtml,
                    },
                        "Refresh Users",
                    ),
                    
                    // User list
                    Ul(KV{AttrClass: "space-y-2 mt-4", AttrId: "users-list"},
                        MapSlice(users, func(name string) HyperNode {
                            return Li(KV{AttrClass: "p-2 bg-white rounded shadow"},
                                name,
                            )
                        }),
                    ),
                ),
            ),
        ),
    )

    if err := page.Render(os.Stdout); err != nil {
        panic(err)
    }
}

Documentation

Index

Constants

View Source
const (
	// AttrAccept sets the accepted file types for <input type="file">.
	AttrAccept = "accept"
	// AttrAcceptCharset sets the character encodings accepted by the server.
	AttrAcceptCharset = "accept-charset"
	// AttrAccessKey gives keyboard shortcut access to an element.
	AttrAccessKey = "accesskey"
	// AttrAction specifies where to send the form data.
	AttrAction = "action"
	// AttrAlign specifies the alignment of an element.
	AttrAlign = "align"
	// AttrAllow specifies permissions for an iframe.
	AttrAllow = "allow"
	// AttrAlpha sets the alpha transparency level of an element.
	AttrAlpha = "alpha"
	// AttrAlt provides alternative text for an image.
	AttrAlt = "alt"
	// AttrAs specifies the relation between the linked resource and the document.
	AttrAs = "as"
	// AttrAsync indicates that the script should execute asynchronously.
	AttrAsync = "async"
	// AttrAutocapitalize controls whether text input is automatically capitalized.
	AttrAutocapitalize = "autocapitalize"
	// AttrAutocomplete specifies whether an input field should have autocomplete enabled.
	AttrAutocomplete = "autocomplete"
	// AttrAutofocus specifies that an element should automatically get focus on page load.
	AttrAutofocus = "autofocus"
	// AttrAutoplay specifies that the audio/video should automatically start playing.
	AttrAutoplay = "autoplay"
	// AttrBackground specifies the background image URL.
	AttrBackground = "background"
	// AttrBgColor specifies the background color of an element.
	AttrBgColor = "bgcolor"
	// AttrBorder specifies the border width around an element.
	AttrBorder = "border"
	// AttrCapture specifies which camera/mic to use for media capture.
	AttrCapture = "capture"
	// AttrCharset specifies the character encoding of the document.
	AttrCharset = "charset"
	// AttrChecked specifies whether an input checkbox or radio is checked.
	AttrChecked = "checked"
	// AttrCite specifies the source of a quotation.
	AttrCite = "cite"
	// AttrClass specifies one or more class names for an element.
	AttrClass = "class"
	// AttrColor specifies the text color of an element.
	AttrColor = "color"
	// AttrColorSpace specifies the color space for an image.
	AttrColorSpace = "colorspace"
	// AttrCols specifies the number of columns in a textarea.
	AttrCols = "cols"
	// AttrColSpan specifies the number of columns a table cell should span.
	AttrColSpan = "colspan"
	// AttrContent provides metadata about the element.
	AttrContent = "content"
	// AttrContentEditable specifies whether the element is editable.
	AttrContentEditable = "contenteditable"
	// AttrControls shows the audio/video controls.
	AttrControls = "controls"
	// AttrCoords specifies the coordinates of an area in an image map.
	AttrCoords = "coords"
	// AttrCrossOrigin specifies how the element handles cross-origin requests.
	AttrCrossOrigin = "crossorigin"
	// AttrCsp specifies the Content Security Policy for an element.
	AttrCsp = "csp"
	// AttrData specifies the URL of the data for an object element.
	AttrData = "data"
	// AttrDateTime specifies the date and time for an element.
	AttrDateTime = "datetime"
	// AttrDecoding specifies how to decode an image.
	AttrDecoding = "decoding"
	// AttrDefault specifies that a track should be enabled by default.
	AttrDefault = "default"
	// AttrDefer indicates that the script should be executed after the document is parsed.
	AttrDefer = "defer"
	// AttrDir specifies the text direction of an element.
	AttrDir = "dir"
	// AttrDirName specifies the name of the form field used for sending the directionality of the element.
	AttrDirName = "dirname"
	// AttrDisabled specifies that an element should be disabled.
	AttrDisabled = "disabled"
	// AttrDownload specifies that the target should be downloaded when clicked.
	AttrDownload = "download"
	// AttrDraggable specifies whether an element is draggable.
	AttrDraggable = "draggable"
	// AttrEnctype specifies how form data should be encoded before sending to a server.
	AttrEnctype = "enctype"
	// AttrEnterKeyHint specifies what action label to show on the enter key.
	AttrEnterKeyHint = "enterkeyhint"
	// AttrElementTiming specifies that an element should be observed for performance.
	AttrElementTiming = "elementtiming"
	// AttrForm specifies the id of a form element that the element belongs to.
	AttrForm = "form"
	// AttrFormAction specifies where to send the form data.
	AttrFormAction = "formaction"
	// AttrFormEnctype specifies how form data should be encoded.
	AttrFormEnctype = "formenctype"
	// AttrFormMethod specifies the HTTP method for form submission.
	AttrFormMethod = "formmethod"
	// AttrFormNoValidate specifies that the form should not be validated.
	AttrFormNoValidate = "formnovalidate"
	// AttrFormTarget specifies where to display the response after form submission.
	AttrFormTarget = "formtarget"
	// AttrFetchPriority indicates the priority of fetching an external resource.
	AttrFetchPriority = "fetchpriority"
	// AttrHeaders specifies the header cells that a table cell relates to.
	AttrHeaders = "headers"
	// AttrHeight specifies the height of an element.
	AttrHeight = "height"
	// AttrHidden specifies that an element is not yet or is no longer relevant.
	AttrHidden = "hidden"
	// AttrHigh specifies the lower bound of a range.
	AttrHigh = "high"
	// AttrHref specifies the URL of a link.
	AttrHref = "href"
	// AttrHrefLang specifies the language of the linked resource.
	AttrHrefLang = "hreflang"
	// AttrHttpEquiv provides an HTTP header for the information in the content attribute.
	AttrHttpEquiv = "http-equiv"
	// AttrId specifies a unique id for an element.
	AttrId = "id"
	// AttrIntegrity specifies a hash of the resource to verify its integrity.
	AttrIntegrity = "integrity"
	// AttrInputMode provides a hint to browsers about the type of data the user should enter.
	AttrInputMode = "inputmode"
	// AttrIsMap specifies that an image is part of a server-side image map.
	AttrIsMap = "ismap"
	// AttrItemProp specifies the property of an item.
	AttrItemProp = "itemprop"
	// AttrKind specifies the kind of text track.
	AttrKind = "kind"
	// AttrLabel specifies the label of an option or track.
	AttrLabel = "label"
	// AttrLang specifies the language of the element.
	AttrLang = "lang"
	// AttrLanguage specifies the scripting language of an element.
	AttrLanguage = "language"
	// AttrLoading specifies whether to load an image lazily.
	AttrLoading = "loading"
	// AttrList refers to a datalist containing predefined options.
	AttrList = "list"
	// AttrLoop specifies whether to loop an audio/video.
	AttrLoop = "loop"
	// AttrLow specifies the upper bound of a range.
	AttrLow = "low"
	// AttrMax specifies the maximum value.
	AttrMax = "max"
	// AttrMaxLength specifies the maximum number of characters allowed.
	AttrMaxLength = "maxlength"
	// AttrMinLength specifies the minimum number of characters required.
	AttrMinLength = "minlength"
	// AttrMedia specifies the media type or device the resource applies to.
	AttrMedia = "media"
	// AttrMethod specifies the HTTP method for form submission.
	AttrMethod = "method"
	// AttrMin specifies the minimum value.
	AttrMin = "min"
	// AttrMultiple specifies that a user can enter more than one value.
	AttrMultiple = "multiple"
	// AttrMuted specifies that the audio should be muted.
	AttrMuted = "muted"
	// AttrName specifies the name of an element.
	AttrName = "name"
	// AttrNoValidate specifies that the form should not be validated.
	AttrNoValidate = "novalidate"
	// AttrOnAbort specifies the event handler for the abort event.
	AttrOnAbort = "onAbort"
	// AttrOnActivate specifies the event handler for the activate event.
	AttrOnActivate = "onActivate"
	// AttrOnAfterPrint specifies the event handler for the afterprint event.
	AttrOnAfterPrint = "onAfterPrint"
	// AttrOnAfterUpdate specifies the event handler for the afterupdate event.
	AttrOnAfterUpdate = "onAfterUpdate"
	// AttrOnBeforeActivate specifies the event handler for the beforeactivate event.
	AttrOnBeforeActivate = "onBeforeActivate"
	// AttrOnBeforeCopy specifies the event handler for the beforecopy event.
	AttrOnBeforeCopy = "onBeforeCopy"
	// AttrOnBeforeCut specifies the event handler for the beforecut event.
	AttrOnBeforeCut = "onBeforeCut"
	// AttrOnBeforeDeactivate specifies the event handler for the beforedeactivate event.
	AttrOnBeforeDeactivate = "onBeforeDeactivate"
	// AttrOnBeforeEditFocus specifies the event handler for the beforeeditfocus event.
	AttrOnBeforeEditFocus = "onBeforeEditFocus"
	// AttrOnBeforePaste specifies the event handler for the beforepaste event.
	AttrOnBeforePaste = "onBeforePaste"
	// AttrOnBeforePrint specifies the event handler for the beforeprint event.
	AttrOnBeforePrint = "onBeforePrint"
	// AttrOnBeforeUnload specifies the event handler for the beforeunload event.
	AttrOnBeforeUnload = "onBeforeUnload"
	// AttrOnBeforeUpdate specifies the event handler for the beforeupdate event.
	AttrOnBeforeUpdate = "onBeforeUpdate"
	// AttrOnBegin specifies the event handler for the begin event.
	AttrOnBegin = "onBegin"
	// AttrOnBlur specifies the event handler for the blur event.
	AttrOnBlur = "onBlur"
	// AttrOnBounce specifies the event handler for the bounce event.
	AttrOnBounce = "onBounce"
	// AttrOnCellChange specifies the event handler for the cellchange event.
	AttrOnCellChange = "onCellChange"
	// AttrOnChange specifies the event handler for the change event.
	AttrOnChange = "onChange"
	// AttrOnClick specifies the event handler for the click event.
	AttrOnClick = "onClick"
	// AttrOnContextMenu specifies the event handler for the contextmenu event.
	AttrOnContextMenu = "onContextMenu"
	// AttrOnControlSelect specifies the event handler for the controlselect event.
	AttrOnControlSelect = "onControlSelect"
	// AttrOnCopy specifies the event handler for the copy event.
	AttrOnCopy = "onCopy"
	// AttrOnCut specifies the event handler for the cut event.
	AttrOnCut = "onCut"
	// AttrOnDataAvailable specifies the event handler for the dataavailable event.
	AttrOnDataAvailable = "onDataAvailable"
	// AttrOnDataSetChanged specifies the event handler for the datasetchanged event.
	AttrOnDataSetChanged = "onDataSetChanged"
	// AttrOnDataSetComplete specifies the event handler for the datasetcomplete event.
	AttrOnDataSetComplete = "onDataSetComplete"
	// AttrOnDblClick specifies the event handler for the dblclick event.
	AttrOnDblClick = "onDblClick"
	// AttrOnDeactivate specifies the event handler for the deactivate event.
	AttrOnDeactivate = "onDeactivate"
	// AttrOnDrag specifies the event handler for the drag event.
	AttrOnDrag = "onDrag"
	// AttrOnDragEnd specifies the event handler for the dragend event.
	AttrOnDragEnd = "onDragEnd"
	// AttrOnDragLeave specifies the event handler for the dragleave event.
	AttrOnDragLeave = "onDragLeave"
	// AttrOnDragEnter specifies the event handler for the dragenter event.
	AttrOnDragEnter = "onDragEnter"
	// AttrOnDragOver specifies the event handler for the dragover event.
	AttrOnDragOver = "onDragOver"
	// AttrOnDragDrop specifies the event handler for the dragdrop event.
	AttrOnDragDrop = "onDragDrop"
	// AttrOnDragStart specifies the event handler for the dragstart event.
	AttrOnDragStart = "onDragStart"
	// AttrOnDrop specifies the event handler for the drop event.
	AttrOnDrop = "onDrop"
	// AttrOnEnd specifies the event handler for the end event.
	AttrOnEnd = "onEnd"
	// AttrOnError specifies the event handler for the error event.
	AttrOnError = "onError"
	// AttrOnErrorUpdate specifies the event handler for the errorupdate event.
	AttrOnErrorUpdate = "onErrorUpdate"
	// AttrOnFilterChange specifies the event handler for the filterchange event.
	AttrOnFilterChange = "onFilterChange"
	// AttrOnFinish specifies the event handler for the finish event.
	AttrOnFinish = "onFinish"
	// AttrOnFocus specifies the event handler for the focus event.
	AttrOnFocus = "onFocus"
	// AttrOnFocusIn specifies the event handler for the focusin event.
	AttrOnFocusIn = "onFocusIn"
	// AttrOnFocusOut specifies the event handler for the focusout event.
	AttrOnFocusOut = "onFocusOut"
	// AttrOnHashChange specifies the event handler for the hashchange event.
	AttrOnHashChange = "onHashChange"
	// AttrOnHelp specifies the event handler for the help event.
	AttrOnHelp = "onHelp"
	// AttrOnInput specifies the event handler for the input event.
	AttrOnInput = "onInput"
	// AttrOnKeyDown specifies the event handler for the keydown event.
	AttrOnKeyDown = "onKeyDown"
	// AttrOnKeyPress specifies the event handler for the keypress event.
	AttrOnKeyPress = "onKeyPress"
	// AttrOnKeyUp specifies the event handler for the keyup event.
	AttrOnKeyUp = "onKeyUp"
	// AttrOnLayoutComplete specifies the event handler for the layoutcomplete event.
	AttrOnLayoutComplete = "onLayoutComplete"
	// AttrOnLoad specifies the event handler for the load event.
	AttrOnLoad = "onLoad"
	// AttrOnLoseCapture specifies the event handler for the losecapture event.
	AttrOnLoseCapture = "onLoseCapture"
	// AttrOnMediaComplete specifies the event handler for the mediacomplete event.
	AttrOnMediaComplete = "onMediaComplete"
	// AttrOnMediaError specifies the event handler for the mediaerror event.
	AttrOnMediaError = "onMediaError"
	// AttrOnMessage specifies the event handler for the message event.
	AttrOnMessage = "onMessage"
	// AttrOnMouseDown specifies the event handler for the mousedown event.
	AttrOnMouseDown = "onMouseDown"
	// AttrOnMouseEnter specifies the event handler for the mouseenter event.
	AttrOnMouseEnter = "onMouseEnter"
	// AttrOnMouseLeave specifies the event handler for the mouseleave event.
	AttrOnMouseLeave = "onMouseLeave"
	// AttrOnMouseMove specifies the event handler for the mousemove event.
	AttrOnMouseMove = "onMouseMove"
	// AttrOnMouseOut specifies the event handler for the mouseout event.
	AttrOnMouseOut = "onMouseOut"
	// AttrOnMouseOver specifies the event handler for the mouseover event.
	AttrOnMouseOver = "onMouseOver"
	// AttrOnMouseUp specifies the event handler for the mouseup event.
	AttrOnMouseUp = "onMouseUp"
	// AttrOnMouseWheel specifies the event handler for the mousewheel event.
	AttrOnMouseWheel = "onMouseWheel"
	// AttrOnMove specifies the event handler for the move event.
	AttrOnMove = "onMove"
	// AttrOnMoveEnd specifies the event handler for the moveend event.
	AttrOnMoveEnd = "onMoveEnd"
	// AttrOnMoveStart specifies the event handler for the movestart event.
	AttrOnMoveStart = "onMoveStart"
	// AttrOnOffline specifies the event handler for the offline event.
	AttrOnOffline = "onOffline"
	// AttrOnOnline specifies the event handler for the online event.
	AttrOnOnline = "onOnline"
	// AttrOnOutOfSync specifies the event handler for the outofsync event.
	AttrOnOutOfSync = "onOutOfSync"
	// AttrOnPaste specifies the event handler for the paste event.
	AttrOnPaste = "onPaste"
	// AttrOnPause specifies the event handler for the pause event.
	AttrOnPause = "onPause"
	// AttrOnPopState specifies the event handler for the popstate event.
	AttrOnPopState = "onPopState"
	// AttrOnProgress specifies the event handler for the progress event.
	AttrOnProgress = "onProgress"
	// AttrOnPropertyChange specifies the event handler for the propertychange event.
	AttrOnPropertyChange = "onPropertyChange"
	// AttrOnReadyStateChange specifies the event handler for the readystatechange event.
	AttrOnReadyStateChange = "onReadyStateChange"
	// AttrOnRedo specifies the event handler for the redo event.
	AttrOnRedo = "onRedo"
	// AttrOnRepeat specifies the event handler for the repeat event.
	AttrOnRepeat = "onRepeat"
	// AttrOnReset specifies the event handler for the reset event.
	AttrOnReset = "onReset"
	// AttrOnResize specifies the event handler for the resize event.
	AttrOnResize = "onResize"
	// AttrOnResizeEnd specifies the event handler for the resizeend event.
	AttrOnResizeEnd = "onResizeEnd"
	// AttrOnResizeStart specifies the event handler for the resizestart event.
	AttrOnResizeStart = "onResizeStart"
	// AttrOnResume specifies the event handler for the resume event.
	AttrOnResume = "onResume"
	// AttrOnReverse specifies the event handler for the reverse event.
	AttrOnReverse = "onReverse"
	// AttrOnRowsEnter specifies the event handler for the rowsenter event.
	AttrOnRowsEnter = "onRowsEnter"
	// AttrOnRowExit specifies the event handler for the rowexit event.
	AttrOnRowExit = "onRowExit"
	// AttrOnRowDelete specifies the event handler for the rowdelete event.
	AttrOnRowDelete = "onRowDelete"
	// AttrOnRowInserted specifies the event handler for the rowinserted event.
	AttrOnRowInserted = "onRowInserted"
	// AttrOnScroll specifies the event handler for the scroll event.
	AttrOnScroll = "onScroll"
	// AttrOnSeek specifies the event handler for the seek event.
	AttrOnSeek = "onSeek"
	// AttrOnSelect specifies the event handler for the select event.
	AttrOnSelect = "onSelect"
	// AttrOnSelectionChange specifies the event handler for the selectionchange event.
	AttrOnSelectionChange = "onSelectionChange"
	// AttrOnSelectStart specifies the event handler for the selectstart event.
	AttrOnSelectStart = "onSelectStart"
	// AttrOnStart specifies the event handler for the start event.
	AttrOnStart = "onStart"
	// AttrOnStop specifies the event handler for the stop event.
	AttrOnStop = "onStop"
	// AttrOnStorage specifies the event handler for the storage event.
	AttrOnStorage = "onStorage"
	// AttrOnSyncRestored specifies the event handler for the syncrestored event.
	AttrOnSyncRestored = "onSyncRestored"
	// AttrOnSubmit specifies the event handler for the submit event.
	AttrOnSubmit = "onSubmit"
	// AttrOnTimeError specifies the event handler for the timeerror event.
	AttrOnTimeError = "onTimeError"
	// AttrOnTrackChange specifies the event handler for the trackchange event.
	AttrOnTrackChange = "onTrackChange"
	// AttrOnUndo specifies the event handler for the undo event.
	AttrOnUndo = "onUndo"
	// AttrOnUnload specifies the event handler for the unload event.
	AttrOnUnload = "onUnload"
	// AttrOnURLFlip specifies the event handler for the urlflip event.
	AttrOnURLFlip = "onURLFlip"
	// AttrOpen specifies whether the element is visible (for details, dialog, etc.).
	AttrOpen = "open"
	// AttrOptimum specifies the optimal value in a range.
	AttrOptimum = "optimum"
	// AttrPattern specifies a regular expression for input validation.
	AttrPattern = "pattern"
	// AttrPing specifies a list of URLs to notify when a link is clicked.
	AttrPing = "ping"
	// AttrPlaceholder provides a hint to the user about what to enter.
	AttrPlaceholder = "placeholder"
	// AttrPlaysInline specifies that the video should play inline.
	AttrPlaysInline = "playsinline"
	// AttrPoster specifies the preview image for a video.
	AttrPoster = "poster"
	// AttrPopoverTargetAction specifies the action to perform with a popover element.
	AttrPopoverTargetAction = "popovertargetaction"
	// AttrPreload specifies how to preload an audio/video.
	AttrPreload = "preload"
	// AttrReadonly specifies that an input field is read-only.
	AttrReadonly = "readonly"
	// AttrReferrerPolicy specifies the referrer policy for the resource.
	AttrReferrerPolicy = "referrerpolicy"
	// AttrRel specifies the relationship between the current document and the linked resource.
	AttrRel = "rel"
	// AttrRequired specifies that an input field must be filled out.
	AttrRequired = "required"
	// AttrReversed specifies that the list order should be reversed.
	AttrReversed = "reversed"
	// AttrRole specifies the role of an element for accessibility.
	AttrRole = "role"
	// AttrRows specifies the number of rows in a textarea.
	AttrRows = "rows"
	// AttrRowSpan specifies the number of rows a table cell should span.
	AttrRowSpan = "rowspan"
	// AttrSandbox enables extra restrictions for an iframe.
	AttrSandbox = "sandbox"
	// AttrScope specifies the header cells that a th element applies to.
	AttrScope = "scope"
	// AttrSelected specifies that an option should be pre-selected.
	AttrSelected = "selected"
	// AttrShape specifies the shape of an area in an image map.
	AttrShape = "shape"
	// AttrSize specifies the size of an input field or select element.
	AttrSize = "size"
	// AttrSizes specifies the sizes of an image for different layouts.
	AttrSizes = "sizes"
	// AttrSlot assigns a slot to an element in a shadow DOM.
	AttrSlot = "slot"
	// AttrSpan specifies the number of columns in a colgroup.
	AttrSpan = "span"
	// AttrSpellCheck specifies whether to enable spell checking.
	AttrSpellCheck = "spellcheck"
	// AttrSrc specifies the URL of an image, audio, video, or iframe.
	AttrSrc = "src"
	// AttrSrcDoc specifies the inline HTML for an iframe.
	AttrSrcDoc = "srcdoc"
	// AttrSrcLang specifies the language of the track text.
	AttrSrcLang = "srclang"
	// AttrSrcSet specifies multiple image sources for responsive images.
	AttrSrcSet = "srcset"
	// AttrStart specifies the starting number of an ordered list.
	AttrStart = "start"
	// AttrStep specifies the interval between legal numbers in an input.
	AttrStep = "step"
	// AttrStyle specifies inline CSS styles.
	AttrStyle = "style"
	// AttrSummary provides a summary for a table.
	AttrSummary = "summary"
	// AttrTabIndex specifies the tab order of an element.
	AttrTabIndex = "tabindex"
	// AttrTarget specifies where to open a link or form response.
	AttrTarget = "target"
	// AttrTitle provides advisory information about an element.
	AttrTitle = "title"
	// AttrTranslate specifies whether to translate an element.
	AttrTranslate = "translate"
	// AttrType specifies the type of an input element.
	AttrType = "type"
	// AttrUseMap specifies that an image is a client-side image map.
	AttrUseMap = "usemap"
	// AttrValue specifies the value of an input element.
	AttrValue = "value"
	// AttrWidth specifies the width of an element.
	AttrWidth = "width"
	// AttrWrap specifies how text should wrap in a textarea.
	AttrWrap = "wrap"
)
View Source
const (
	// TypeText creates a single-line text input field.
	TypeText = "text"
	// TypePassword creates a password input field.
	TypePassword = "password"
	// TypeCheckbox creates a checkbox input field.
	TypeCheckbox = "checkbox"
	// TypeRadio creates a radio button input field.
	TypeRadio = "radio"
	// TypeSubmit creates a submit button.
	TypeSubmit = "submit"
	// TypeReset creates a reset button.
	TypeReset = "reset"
	// TypeButton creates a generic button.
	TypeButton = "button"
	// TypeFile creates a file upload input field.
	TypeFile = "file"
	// TypeHidden creates a hidden input field.
	TypeHidden = "hidden"
	// TypeImage creates an image submit button.
	TypeImage = "image"
	// TypeColor creates a color picker input field.
	TypeColor = "color"
	// TypeDate creates a date picker input field.
	TypeDate = "date"
	// TypeDateTime creates a date and time picker input field.
	TypeDateTime = "datetime"
	// TypeDateTimeLocal creates a local date and time picker input field.
	TypeDateTimeLocal = "datetime-local"
	// TypeEmail creates an email input field.
	TypeEmail = "email"
	// TypeMonth creates a month picker input field.
	TypeMonth = "month"
	// TypeNumber creates a number input field.
	TypeNumber = "number"
	// TypeRange creates a range slider input field.
	TypeRange = "range"
	// TypeSearch creates a search input field.
	TypeSearch = "search"
	// TypeTel creates a telephone number input field.
	TypeTel = "tel"
	// TypeTime creates a time picker input field.
	TypeTime = "time"
	// TypeUrl creates a URL input field.
	TypeUrl = "url"
	// TypeWeek creates a week picker input field.
	TypeWeek = "week"
)

Type* constants are valid values for the type attribute on various elements.

View Source
const (
	// RelAlternate indicates an alternate version of the current document.
	RelAlternate = "alternate"
	// RelAuthor indicates the author of the current document.
	RelAuthor = "author"
	// RelBookmark indicates a bookmark for the current document.
	RelBookmark = "bookmark"
	// RelCanonical indicates the canonical URL of the current document.
	RelCanonical = "canonical"
	// RelCompressionDictionary indicates a compression dictionary resource.
	RelCompressionDictionary = "compression-dictionary"
	// RelDnsPrefetch indicates to pre-resolve the DNS of the linked resource.
	RelDnsPrefetch = "dns-prefetch"
	// RelExternal indicates the linked resource is not part of the current site.
	RelExternal = "external"
	// RelHelp indicates a link to a help resource.
	RelHelp = "help"
	// RelIcon indicates the favicon of the current document.
	RelIcon = "icon"
	// RelLicense indicates the copyright license for the current document.
	RelLicense = "license"
	// RelManifest indicates a Web App Manifest.
	RelManifest = "manifest"
	// RelModulePreload indicates to preload a JavaScript module.
	RelModulePreload = "modulepreload"
	// RelNext indicates the next document in a sequence.
	RelNext = "next"
	// RelNoFollow indicates the link is not endorsed by the author.
	RelNoFollow = "nofollow"
	// RelNoOpener prevents the opened page from accessing the source page.
	RelNoOpener = "noopener"
	// RelNoReferrer indicates not to send a referrer header.
	RelNoReferrer = "noreferrer"
	// RelOpener allows the opened page to access the source page.
	RelOpener = "opener"
	// RelPingback indicates the URL of a pingback server.
	RelPingback = "pingback"
	// RelPreconnect indicates to pre-connect to the linked resource.
	RelPreconnect = "preconnect"
	// RelPrefetch indicates to prefetch the linked resource.
	RelPrefetch = "prefetch"
	// RelPreload indicates to preload the linked resource.
	RelPreload = "preload"
	// RelPrerender indicates to prerender the linked resource.
	RelPrerender = "prerender"
	// RelPrev indicates the previous document in a sequence.
	RelPrev = "prev"
	// RelSearch indicates a search resource for the current document.
	RelSearch = "search"
	// RelStylesheet indicates a stylesheet for the current document.
	RelStylesheet = "stylesheet"
	// RelTag indicates a tag relevant to the current document.
	RelTag = "tag"
)

Rel* constants are valid values for the rel attribute.

View Source
const (
	// TargetBlank opens the link in a new tab or window.
	TargetBlank = "_blank"
	// TargetSelf opens the link in the same frame as clicked.
	TargetSelf = "_self"
	// TargetParent opens the link in the parent frame.
	TargetParent = "_parent"
	// TargetTop opens the link in the topmost frame.
	TargetTop = "_top"
	// TargetFramename opens the link in a named frame.
	TargetFramename = "framename"
)

Target* constants are valid values for the target attribute.

View Source
const (
	// MethodGet sends form data as URL parameters.
	MethodGet = "get"
	// MethodPost sends form data in the request body.
	MethodPost = "post"
)

Method* constants are valid values for the method attribute on <form>.

View Source
const (
	// EnctypeUrlEncoded encodes form data as URL-encoded string.
	EnctypeUrlEncoded = "application/x-www-form-urlencoded"
	// EnctypeMultipartForm encodes form data as multipart/form-data.
	EnctypeMultipartForm = "multipart/form-data"
	// EnctypePlainText encodes form data as plain text.
	EnctypePlainText = "text/plain"
)

Enctype* constants are valid values for the enctype attribute on <form>.

View Source
const (
	// CrossOriginAnonymous allows anonymous cross-origin requests.
	CrossOriginAnonymous = "anonymous"
	// CrossOriginUseCredentials requires credentials for cross-origin requests.
	CrossOriginUseCredentials = "use-credentials"
)

CrossOrigin* constants are valid values for the crossorigin attribute.

View Source
const (
	// DirLtr sets text direction to left-to-right.
	DirLtr = "ltr"
	// DirRtl sets text direction to right-to-left.
	DirRtl = "rtl"
	// DirAuto sets text direction to automatically detected.
	DirAuto = "auto"
)

Dir* constants are valid values for the dir attribute.

View Source
const (
	// TranslateYes indicates the element should be translated.
	TranslateYes = "yes"
	// TranslateNo indicates the element should not be translated.
	TranslateNo = "no"
)

Translate* constants are valid values for the translate attribute.

View Source
const (
	// PreloadNone indicates not to preload the media.
	PreloadNone = "none"
	// PreloadMetadata indicates to preload only metadata.
	PreloadMetadata = "metadata"
	// PreloadAuto indicates to preload the entire media.
	PreloadAuto = "auto"
)

Preload* constants are valid values for the preload attribute on <audio> and <video>.

View Source
const (
	// LoadingLazy defers loading until the element is near the viewport.
	LoadingLazy = "lazy"
	// LoadingEager loads the element immediately.
	LoadingEager = "eager"
)

Loading* constants are valid values for the loading attribute on <img> and <iframe>.

View Source
const (
	// DecodingAsync decodes the image asynchronously.
	DecodingAsync = "async"
	// DecodingSync decodes the image synchronously.
	DecodingSync = "sync"
	// DecodingAuto lets the browser decide.
	DecodingAuto = "auto"
)

Decoding* constants are valid values for the decoding attribute on <img>.

View Source
const (
	// ReferrerPolicyNoReferrer does not send a referrer header.
	ReferrerPolicyNoReferrer = "no-referrer"
	// ReferrerPolicyNoReferrerWhenDowngrade sends referrer only for same-origin or secure-to-insecure.
	ReferrerPolicyNoReferrerWhenDowngrade = "no-referrer-when-downgrade"
	// ReferrerPolicyOrigin sends only the origin as referrer.
	ReferrerPolicyOrigin = "origin"
	// ReferrerPolicyOriginWhenCrossOrigin sends full URL for same-origin, origin for cross-origin.
	ReferrerPolicyOriginWhenCrossOrigin = "origin-when-cross-origin"
	// ReferrerPolicySameOrigin sends referrer only for same-origin.
	ReferrerPolicySameOrigin = "same-origin"
	// ReferrerPolicyStrictOriginWhenCrossOrigin sends origin for cross-origin when downgrade.
	ReferrerPolicyStrictOriginWhenCrossOrigin = "strict-origin-when-cross-origin"
	// ReferrerPolicyUnsafeUrl sends the full URL in all requests.
	ReferrerPolicyUnsafeUrl = "unsafe-url"
)

ReferrerPolicy* constants are valid values for the referrerpolicy attribute.

View Source
const (
	// FetchPriorityLow indicates low fetch priority.
	FetchPriorityLow = "low"
	// FetchPriorityHigh indicates high fetch priority.
	FetchPriorityHigh = "high"
	// FetchPriorityAuto lets the browser decide the priority.
	FetchPriorityAuto = "auto"
)

FetchPriority* constants are valid values for the fetchpriority attribute.

View Source
const (
	// EnterKeyHintEnter indicates the enter key should insert a newline.
	EnterKeyHintEnter = "enter"
	// EnterKeyHintDone indicates the enter key should indicate "done".
	EnterKeyHintDone = "done"
	// EnterKeyHintGo indicates the enter key should indicate "go".
	EnterKeyHintGo = "go"
	// EnterKeyHintNext indicates the enter key should indicate "next".
	EnterKeyHintNext = "next"
	// EnterKeyHintPrevious indicates the enter key should indicate "previous".
	EnterKeyHintPrevious = "previous"
	// EnterKeyHintSearch indicates the enter key should indicate "search".
	EnterKeyHintSearch = "search"
	// EnterKeyHintSend indicates the enter key should indicate "send".
	EnterKeyHintSend = "send"
)

EnterKeyHint* constants are valid values for the enterkeyhint attribute.

View Source
const (
	// WrapHard specifies hard wrapping with preserved line breaks.
	WrapHard = "hard"
	// WrapSoft specifies soft wrapping without line breaks in the submitted value.
	WrapSoft = "soft"
	// WrapOff disables wrapping.
	WrapOff = "off"
)

Wrap* constants are valid values for the wrap attribute on <textarea>.

View Source
const (
	// ShapeDefault defines the entire region.
	ShapeDefault = "default"
	// ShapeCircle defines a circular region.
	ShapeCircle = "circle"
	// ShapePoly defines a polygonal region.
	ShapePoly = "poly"
	// ShapeRect defines a rectangular region.
	ShapeRect = "rect"
)

Shape* constants are valid values for the shape attribute on <area>.

View Source
const (
	// SpellCheckTrue enables spell checking.
	SpellCheckTrue = "true"
	// SpellCheckFalse disables spell checking.
	SpellCheckFalse = "false"
)

Spellcheck* constants are valid values for the spellcheck attribute.

View Source
const (
	// ContentEditableTrue makes the element editable.
	ContentEditableTrue = "true"
	// ContentEditableFalse makes the element non-editable.
	ContentEditableFalse = "false"
	// ContentEditablePlaintextOnly allows only plain text editing.
	ContentEditablePlaintextOnly = "plaintext-only"
)

ContentEditable* constants are valid values for the contenteditable attribute.

View Source
const (
	// DraggableTrue makes the element draggable.
	DraggableTrue = "true"
	// DraggableFalse makes the element non-draggable.
	DraggableFalse = "false"
)

Draggable* constants are valid values for the draggable attribute.

View Source
const (
	// InputModeNone indicates no virtual keyboard.
	InputModeNone = "none"
	// InputModeText indicates a text input mode.
	InputModeText = "text"
	// InputModeDecimal indicates a decimal number input mode.
	InputModeDecimal = "decimal"
	// InputModeNumeric indicates a numeric input mode.
	InputModeNumeric = "numeric"
	// InputModeTel indicates a telephone number input mode.
	InputModeTel = "tel"
	// InputModeSearch indicates a search input mode.
	InputModeSearch = "search"
	// InputModeEmail indicates an email input mode.
	InputModeEmail = "email"
	// InputModeUrl indicates a URL input mode.
	InputModeUrl = "url"
)

InputMode* constants are valid values for the inputmode attribute.

View Source
const (
	// PopoverTargetActionHide hides the popover.
	PopoverTargetActionHide = "hide"
	// PopoverTargetActionShow shows the popover.
	PopoverTargetActionShow = "show"
	// PopoverTargetActionToggle toggles the popover visibility.
	PopoverTargetActionToggle = "toggle"
)

PopoverTargetAction* constants are valid values for the popovertargetaction attribute.

View Source
const (
	// AutocompleteOff disables autocomplete.
	AutocompleteOff = "off"
	// AutocompleteOn enables autocomplete.
	AutocompleteOn = "on"
	// AutocompleteName specifies the full name.
	AutocompleteName = "name"
	// AutocompleteHonorificPrefix specifies a honorific prefix (e.g., Mr, Mrs).
	AutocompleteHonorificPrefix = "honorific-prefix"
	// AutocompleteGivenName specifies the given (first) name.
	AutocompleteGivenName = "given-name"
	// AutocompleteAdditionalName specifies an additional name.
	AutocompleteAdditionalName = "additional-name"
	// AutocompleteFamilyName specifies the family (last) name.
	AutocompleteFamilyName = "family-name"
	// AutocompleteHonorificSuffix specifies a honorific suffix (e.g., Jr, III).
	AutocompleteHonorificSuffix = "honorific-suffix"
	// AutocompleteNickname specifies a nickname.
	AutocompleteNickname = "nickname"
	// AutocompleteEmail specifies an email address.
	AutocompleteEmail = "email"
	// AutocompleteUsername specifies a username.
	AutocompleteUsername = "username"
	// AutocompleteNewPassword specifies a new password (for signup).
	AutocompleteNewPassword = "new-password"
	// AutocompleteCurrentPassword specifies the current password (for login).
	AutocompleteCurrentPassword = "current-password"
	// AutocompleteOneTimeCode specifies a one-time code for authentication.
	AutocompleteOneTimeCode = "one-time-code"
	// AutocompleteOrganizationTitle specifies a job title or organizational title.
	AutocompleteOrganizationTitle = "organization-title"
	// AutocompleteOrganization specifies an organization name.
	AutocompleteOrganization = "organization"
	// AutocompleteStreetAddress specifies a street address.
	AutocompleteStreetAddress = "street-address"
	// AutocompleteAddressLine1 specifies the first line of an address.
	AutocompleteAddressLine1 = "address-line1"
	// AutocompleteAddressLine2 specifies the second line of an address.
	AutocompleteAddressLine2 = "address-line2"
	// AutocompleteAddressLine3 specifies the third line of an address.
	AutocompleteAddressLine3 = "address-line3"
	// AutocompleteAddressLevel4 specifies the most granular address level (e.g., neighborhood).
	AutocompleteAddressLevel4 = "address-level4"
	// AutocompleteAddressLevel3 specifies the third address level (e.g., city).
	AutocompleteAddressLevel3 = "address-level3"
	// AutocompleteAddressLevel2 specifies the second address level (e.g., state/province).
	AutocompleteAddressLevel2 = "address-level2"
	// AutocompleteAddressLevel1 specifies the first address level (e.g., country).
	AutocompleteAddressLevel1 = "address-level1"
	// AutocompleteCountry specifies the country code.
	AutocompleteCountry = "country"
	// AutocompleteCountryName specifies the country name.
	AutocompleteCountryName = "country-name"
	// AutocompleteCcName specifies the name on the credit card.
	AutocompleteCcName = "cc-name"
	// AutocompleteCcGivenName specifies the given name on the credit card.
	AutocompleteCcGivenName = "cc-given-name"
	// AutocompleteCcAdditionalName specifies the additional name on the credit card.
	AutocompleteCcAdditionalName = "cc-additional-name"
	// AutocompleteCcFamilyName specifies the family name on the credit card.
	AutocompleteCcFamilyName = "cc-family-name"
	// AutocompleteCcNumber specifies the credit card number.
	AutocompleteCcNumber = "cc-number"
	// AutocompleteCcExp specifies the credit card expiration date.
	AutocompleteCcExp = "cc-exp"
	// AutocompleteCcExpMonth specifies the credit card expiration month.
	AutocompleteCcExpMonth = "cc-exp-month"
	// AutocompleteCcExpYear specifies the credit card expiration year.
	AutocompleteCcExpYear = "cc-exp-year"
	// AutocompleteCcCsc specifies the credit card security code.
	AutocompleteCcCsc = "cc-csc"
	// AutocompleteCcType specifies the credit card type (e.g., Visa, Mastercard).
	AutocompleteCcType = "cc-type"
	// AutocompleteTransactionCurrency specifies the transaction currency.
	AutocompleteTransactionCurrency = "transaction-currency"
	// AutocompleteTransactionAmount specifies the transaction amount.
	AutocompleteTransactionAmount = "transaction-amount"
	// AutocompleteLanguage specifies a language tag.
	AutocompleteLanguage = "language"
	// AutocompleteBday specifies a birth date.
	AutocompleteBday = "bday"
	// AutocompleteBdayDay specifies the day of birth.
	AutocompleteBdayDay = "bday-day"
	// AutocompleteBdayMonth specifies the month of birth.
	AutocompleteBdayMonth = "bday-month"
	// AutocompleteBdayYear specifies the year of birth.
	AutocompleteBdayYear = "bday-year"
	// AutocompleteSex specifies a gender identity.
	AutocompleteSex = "sex"
	// AutocompleteTelCountryCode specifies the country code component of a telephone number.
	AutocompleteTelCountryCode = "tel-country-code"
	// AutocompleteTelNational specifies the telephone number without country code.
	AutocompleteTelNational = "tel-national"
	// AutocompleteTelAreaCode specifies the area code component of a telephone number.
	AutocompleteTelAreaCode = "tel-area-code"
	// AutocompleteTelLocal specifies the local telephone number.
	AutocompleteTelLocal = "tel-local"
	// AutocompleteTelExtension specifies a telephone extension code.
	AutocompleteTelExtension = "tel-extension"
	// AutocompleteImpp specifies an instant messaging protocol URL.
	AutocompleteImpp = "impp"
	// AutocompleteUrl specifies a URL.
	AutocompleteUrl = "url"
	// AutocompletePhoto specifies a photo URL.
	AutocompletePhoto = "photo"
)

Autocomplete* constants are valid values for the autocomplete attribute.

View Source
const (
	// SandboxAllowForms allows form submission in the iframe.
	SandboxAllowForms = "allow-forms"
	// SandboxAllowModals allows modal dialogs in the iframe.
	SandboxAllowModals = "allow-modals"
	// SandboxAllowOrientationLock allows screen orientation lock in the iframe.
	SandboxAllowOrientationLock = "allow-orientation-lock"
	// SandboxAllowPointerLock allows pointer lock in the iframe.
	SandboxAllowPointerLock = "allow-pointer-lock"
	// SandboxAllowPopups allows popups in the iframe.
	SandboxAllowPopups = "allow-popups"
	// SandboxAllowPopupsToEscapeSandbox allows popups to escape sandbox restrictions.
	SandboxAllowPopupsToEscapeSandbox = "allow-popups-to-escape-sandbox"
	// SandboxAllowPresentation allows presentation mode in the iframe.
	SandboxAllowPresentation = "allow-presentation"
	// SandboxAllowSameOrigin allows the iframe to access same-origin content.
	SandboxAllowSameOrigin = "allow-same-origin"
	// SandboxAllowScripts allows JavaScript execution in the iframe.
	SandboxAllowScripts = "allow-scripts"
	// SandboxAllowTopNavigation allows top-level navigation in the iframe.
	SandboxAllowTopNavigation = "allow-top-navigation"
	// SandboxAllowTopNavigationByUserActivation allows top-level navigation only by user gesture.
	SandboxAllowTopNavigationByUserActivation = "allow-top-navigation-by-user-activation"
)

Sandbox* constants are valid values for the sandbox attribute on <iframe>.

View Source
const (
	// EventAbort fires when an operation is aborted.
	EventAbort = "abort"
	// EventAfterPrint fires after the document is printed.
	EventAfterPrint = "afterprint"
	// EventAnimationEnd fires when a CSS animation ends.
	EventAnimationEnd = "animationend"
	// EventAnimationIteration fires when a CSS animation repeats.
	EventAnimationIteration = "animationiteration"
	// EventAnimationStart fires when a CSS animation starts.
	EventAnimationStart = "animationstart"
	// EventAppInstalled fires when an app is installed.
	EventAppInstalled = "appinstalled"
	// EventAudioProcess fires when an audio buffer is processed.
	EventAudioProcess = "audioprocess"
	// EventAudioEnd fires when audio playback ends.
	EventAudioEnd = "audioend"
	// EventAudioStart fires when audio playback starts.
	EventAudioStart = "audiostart"
	// EventBeforePrint fires before the document is printed.
	EventBeforePrint = "beforeprint"
	// EventBeforeUnload fires before the document is unloaded.
	EventBeforeUnload = "beforeunload"
	// EventBeginEvent fires when a SMIL animation begins.
	EventBeginEvent = "beginEvent"
	// EventBlur fires when an element loses focus.
	EventBlur = "blur"
	// EventBoundary fires when a speech recognition boundary is reached.
	EventBoundary = "boundary"
	// EventCached fires when a cached resource is available.
	EventCached = "cached"
	// EventCanPlay fires when media can start playing.
	EventCanPlay = "canplay"
	// EventCanPlayThrough fires when media can play to the end without buffering.
	EventCanPlayThrough = "canplaythrough"
	// EventChange fires when an input value changes.
	EventChange = "change"
	// EventChargingChange fires when the battery charging state changes.
	EventChargingChange = "chargingchange"
	// EventChargingTimeChange fires when the battery charging time changes.
	EventChargingTimeChange = "chargingtimechange"
	// EventChecking fires when checking for cached resources.
	EventChecking = "checking"
	// EventClick fires when an element is clicked.
	EventClick = "click"
	// EventClose fires when a connection is closed.
	EventClose = "close"
	// EventComplete fires when an operation completes.
	EventComplete = "complete"
	// EventCompositionEnd fires when composition of text is complete.
	EventCompositionEnd = "compositionend"
	// EventCompositionStart fires when composition of text starts.
	EventCompositionStart = "compositionstart"
	// EventCompositionUpdate fires during composition of text.
	EventCompositionUpdate = "compositionupdate"
	// EventContextMenu fires when a context menu is triggered.
	EventContextMenu = "contextmenu"
	// EventCopy fires when text is copied to the clipboard.
	EventCopy = "copy"
	// EventCut fires when text is cut from the clipboard.
	EventCut = "cut"
	// EventDblClick fires when an element is double-clicked.
	EventDblClick = "dblclick"
	// EventDeviceChange fires when a device changes.
	EventDeviceChange = "devicechange"
	// EventDeviceLight fires when ambient light levels change.
	EventDeviceLight = "devicelight"
	// EventDeviceMotion fires when device motion data is available.
	EventDeviceMotion = "devicemotion"
	// EventDeviceOrientation fires when device orientation changes.
	EventDeviceOrientation = "deviceorientation"
	// EventDeviceProximity fires when device proximity is detected.
	EventDeviceProximity = "deviceproximity"
	// EventDischargingTimeChange fires when the battery discharging time changes.
	EventDischargingTimeChange = "dischargingtimechange"
	// EventDomActivate fires when an element is activated.
	EventDomActivate = "DOMActivate"
	// EventDomAttributeNameChanged fires when an attribute name changes.
	EventDomAttributeNameChanged = "DOMAttributeNameChanged"
	// EventDomAttrModified fires when an attribute is modified.
	EventDomAttrModified = "DOMAttrModified"
	// EventDomCharacterDataModified fires when character data is modified.
	EventDomCharacterDataModified = "DOMCharacterDataModified"
	// EventDomContentLoaded fires when the DOM content is loaded.
	EventDomContentLoaded = "DOMContentLoaded"
	// EventDomElementNameChanged fires when an element name changes.
	EventDomElementNameChanged = "DOMElementNameChanged"
	// EventDomFocusIn fires when an element gains focus.
	EventDomFocusIn = "DOMFocusIn"
	// EventDomFocusOut fires when an element loses focus.
	EventDomFocusOut = "DOMFocusOut"
	// EventDomNodeInserted fires when a node is inserted.
	EventDomNodeInserted = "DOMNodeInserted"
	// EventDomNodeInsertedIntoDocument fires when a node is inserted into the document.
	EventDomNodeInsertedIntoDocument = "DOMNodeInsertedIntoDocument"
	// EventDomNodeRemoved fires when a node is removed.
	EventDomNodeRemoved = "DOMNodeRemoved"
	// EventDomNodeRemovedFromDocument fires when a node is removed from the document.
	EventDomNodeRemovedFromDocument = "DOMNodeRemovedFromDocument"
	// EventDomSubtreeModified fires when the subtree is modified.
	EventDomSubtreeModified = "DOMSubtreeModified"
	// EventDownloading fires when a download is in progress.
	EventDownloading = "downloading"
	// EventDrag fires when an element is being dragged.
	EventDrag = "drag"
	// EventDragEnd fires when a drag operation ends.
	EventDragEnd = "dragend"
	// EventDragEnter fires when a dragged element enters a drop target.
	EventDragEnter = "dragenter"
	// EventDragLeave fires when a dragged element leaves a drop target.
	EventDragLeave = "dragleave"
	// EventDragOver fires when a dragged element is over a drop target.
	EventDragOver = "dragover"
	// EventDragStart fires when a drag operation starts.
	EventDragStart = "dragstart"
	// EventDrop fires when an element is dropped.
	EventDrop = "drop"
	// EventDurationChange fires when the duration of media changes.
	EventDurationChange = "durationchange"
	// EventEmptied fires when media becomes empty.
	EventEmptied = "emptied"
	// EventEnd fires when an operation ends.
	EventEnd = "end"
	// EventEnded fires when media playback ends.
	EventEnded = "ended"
	// EventEndEvent fires when a SMIL animation ends.
	EventEndEvent = "endEvent"
	// EventError fires when an error occurs.
	EventError = "error"
	// EventFocus fires when an element gains focus.
	EventFocus = "focus"
	// EventFocusIn fires when an element gains focus.
	EventFocusIn = "focusin"
	// EventFocusOut fires when an element loses focus.
	EventFocusOut = "focusout"
	// EventFullscreenChange fires when fullscreen mode changes.
	EventFullscreenChange = "fullscreenchange"
	// EventFullscreenError fires when fullscreen mode cannot be entered.
	EventFullscreenError = "fullscreenerror"
	// EventGamepadConnected fires when a gamepad is connected.
	EventGamepadConnected = "gamepadconnected"
	// EventGamepadDisconnected fires when a gamepad is disconnected.
	EventGamepadDisconnected = "gamepaddisconnected"
	// EventGotPointerCapture fires when pointer capture is obtained.
	EventGotPointerCapture = "gotpointercapture"
	// EventHashChange fires when the URL hash changes.
	EventHashChange = "hashchange"
	// EventLostPointerCapture fires when pointer capture is lost.
	EventLostPointerCapture = "lostpointercapture"
	// EventInput fires when an input value changes.
	EventInput = "input"
	// EventInvalid fires when an input element is invalid.
	EventInvalid = "invalid"
	// EventKeyDown fires when a key is pressed down.
	EventKeyDown = "keydown"
	// EventKeyPress fires when a key is pressed.
	EventKeyPress = "keypress"
	// EventKeyUp fires when a key is released.
	EventKeyUp = "keyup"
	// EventLanguageChange fires when the language changes.
	EventLanguageChange = "languagechange"
	// EventLevelChange fires when the battery level changes.
	EventLevelChange = "levelchange"
	// EventLoad fires when a resource loads.
	EventLoad = "load"
	// EventLoadedData fires when media data is loaded.
	EventLoadedData = "loadeddata"
	// EventLoadedMetadata fires when media metadata is loaded.
	EventLoadedMetadata = "loadedmetadata"
	// EventLoadEnd fires when a resource finishes loading.
	EventLoadEnd = "loadend"
	// EventLoadStart fires when a resource starts loading.
	EventLoadStart = "loadstart"
	// EventMark fires when a text mark is reached in media.
	EventMark = "mark"
	// EventMessage fires when a message is received.
	EventMessage = "message"
	// EventMessageError fires when a message error occurs.
	EventMessageError = "messageerror"
	// EventMouseDown fires when a mouse button is pressed.
	EventMouseDown = "mousedown"
	// EventMouseEnter fires when the mouse enters an element.
	EventMouseEnter = "mouseenter"
	// EventMouseLeave fires when the mouse leaves an element.
	EventMouseLeave = "mouseleave"
	// EventMouseMove fires when the mouse moves.
	EventMouseMove = "mousemove"
	// EventMouseOut fires when the mouse leaves an element.
	EventMouseOut = "mouseout"
	// EventMouseOver fires when the mouse enters an element.
	EventMouseOver = "mouseover"
	// EventMouseUp fires when a mouse button is released.
	EventMouseUp = "mouseup"
	// EventNoMatch fires when a speech recognition result doesn't match.
	EventNoMatch = "nomatch"
	// EventNotificationClick fires when a notification is clicked.
	EventNotificationClick = "notificationclick"
	// EventNoUpdate fires when no update is available.
	EventNoUpdate = "noupdate"
	// EventObsolete fires when an obsolete API is used.
	EventObsolete = "obsolete"
	// EventOffline fires when the network goes offline.
	EventOffline = "offline"
	// EventOnline fires when the network comes online.
	EventOnline = "online"
	// EventOpen fires when a connection is opened.
	EventOpen = "open"
	// EventOrientationChange fires when the device orientation changes.
	EventOrientationChange = "orientationchange"
	// EventPageHide fires when a page is being hidden.
	EventPageHide = "pagehide"
	// EventPageShow fires when a page is being shown.
	EventPageShow = "pageshow"
	// EventPaste fires when text is pasted from the clipboard.
	EventPaste = "paste"
	// EventPause fires when media playback pauses.
	EventPause = "pause"
	// EventPointerCancel fires when a pointer operation is cancelled.
	EventPointerCancel = "pointercancel"
	// EventPointerDown fires when a pointer is pressed.
	EventPointerDown = "pointerdown"
	// EventPointerEnter fires when a pointer enters an element.
	EventPointerEnter = "pointerenter"
	// EventPointerLeave fires when a pointer leaves an element.
	EventPointerLeave = "pointerleave"
	// EventPointerLockChange fires when pointer lock state changes.
	EventPointerLockChange = "pointerlockchange"
	// EventPointerLockError fires when pointer lock fails.
	EventPointerLockError = "pointerlockerror"
	// EventPointerMove fires when a pointer moves.
	EventPointerMove = "pointermove"
	// EventPointerOut fires when a pointer leaves an element.
	EventPointerOut = "pointerout"
	// EventPointerOver fires when a pointer enters an element.
	EventPointerOver = "pointerover"
	// EventPointerUp fires when a pointer is released.
	EventPointerUp = "pointerup"
	// EventPlay fires when media playback starts.
	EventPlay = "play"
	// EventPlaying fires when media is actively playing.
	EventPlaying = "playing"
	// EventPopState fires when the history state changes.
	EventPopState = "popstate"
	// EventProgress fires when a resource is loading.
	EventProgress = "progress"
	// EventPush fires when a push notification is received.
	EventPush = "push"
	// EventPushSubscriptionChange fires when a push subscription changes.
	EventPushSubscriptionChange = "pushsubscriptionchange"
	// EventRateChange fires when the playback rate changes.
	EventRateChange = "ratechange"
	// EventReadyStateChange fires when the ready state changes.
	EventReadyStateChange = "readystatechange"
	// EventRepeatEvent fires when a SMIL animation repeats.
	EventRepeatEvent = "repeatEvent"
	// EventReset fires when a form is reset.
	EventReset = "reset"
	// EventResize fires when the viewport is resized.
	EventResize = "resize"
	// EventResourceTimingBufferFull fires when the resource timing buffer is full.
	EventResourceTimingBufferFull = "resourcetimingbufferfull"
	// EventResult fires when a speech recognition result is available.
	EventResult = "result"
	// EventResume fires when media playback resumes.
	EventResume = "resume"
	// EventScroll fires when an element is scrolled.
	EventScroll = "scroll"
	// EventSeeked fires when a seek operation completes.
	EventSeeked = "seeked"
	// EventSeeking fires when a seek operation starts.
	EventSeeking = "seeking"
	// EventSelect fires when text is selected.
	EventSelect = "select"
	// EventSelectStart fires when a text selection starts.
	EventSelectStart = "selectstart"
	// EventSelectionChange fires when the selection changes.
	EventSelectionChange = "selectionchange"
	// EventShow fires when a context menu or dialog is shown.
	EventShow = "show"
	// EventSlotChange fires when a slot's content changes.
	EventSlotChange = "slotchange"
	// EventSoundEnd fires when sound ends.
	EventSoundEnd = "soundend"
	// EventSoundStart fires when sound starts.
	EventSoundStart = "soundstart"
	// EventSpeechEnd fires when speech recognition ends.
	EventSpeechEnd = "speechend"
	// EventSpeechStart fires when speech recognition starts.
	EventSpeechStart = "speechstart"
	// EventStalled fires when media loading stalls.
	EventStalled = "stalled"
	// EventStart fires when an operation starts.
	EventStart = "start"
	// EventStorage fires when storage is modified.
	EventStorage = "storage"
	// EventSubmit fires when a form is submitted.
	EventSubmit = "submit"
	// EventSuccess fires when an operation succeeds.
	EventSuccess = "success"
	// EventSuspend fires when media loading is suspended.
	EventSuspend = "suspend"
	// EventSvgAbort fires when SVG loading is aborted.
	EventSvgAbort = "SVGAbort"
	// EventSvgError fires when SVG loading fails.
	EventSvgError = "SVGError"
	// EventSvgLoad fires when SVG loads.
	EventSvgLoad = "SVGLoad"
	// EventSvgResize fires when SVG is resized.
	EventSvgResize = "SVGResize"
	// EventSvgScroll fires when SVG is scrolled.
	EventSvgScroll = "SVGScroll"
	// EventSvgUnload fires when SVG is unloaded.
	EventSvgUnload = "SVGUnload"
	// EventSvgZoom fires when SVG is zoomed.
	EventSvgZoom = "SVGZoom"
	// EventTimeout fires when a timeout occurs.
	EventTimeout = "timeout"
	// EventTimeUpdate fires when the current playback time updates.
	EventTimeUpdate = "timeupdate"
	// EventTouchCancel fires when a touch is cancelled.
	EventTouchCancel = "touchcancel"
	// EventTouchEnd fires when a touch ends.
	EventTouchEnd = "touchend"
	// EventTouchMove fires when a touch moves.
	EventTouchMove = "touchmove"
	// EventTouchStart fires when a touch starts.
	EventTouchStart = "touchstart"
	// EventTransitionEnd fires when a CSS transition ends.
	EventTransitionEnd = "transitionend"
	// EventUnload fires when the document is unloaded.
	EventUnload = "unload"
	// EventUpdateReady fires when an update is ready.
	EventUpdateReady = "updateready"
	// EventUserProximity fires when user proximity is detected.
	EventUserProximity = "userproximity"
	// EventVoicesChanged fires when available voices change.
	EventVoicesChanged = "voiceschanged"
	// EventVisibilityChange fires when document visibility changes.
	EventVisibilityChange = "visibilitychange"
	// EventVolumeChange fires when the volume changes.
	EventVolumeChange = "volumechange"
	// EventWaiting fires when media is waiting for data.
	EventWaiting = "waiting"
	// EventWheel fires when the mouse wheel is rotated.
	EventWheel = "wheel"
)

Variables

This section is empty.

Functions

func IfElse

func IfElse[T any](condition bool, result, alternative T) T

IfElse returns the appropriate value based on a boolean condition.

This generic function is useful for inline conditional expressions in builder-style code where you need to choose between two values without breaking the chain of method calls.

Example:

div := Div(KV{"class": IfElse(isActive, "active", "inactive")})

Body(
	IfElse(isAdmin,
		Div("Admin content"),
		P("Regular user content"),
	),
)

func Render

func Render(w io.Writer, node HyperNode) error

Render writes the HTML representation of a Node to the provided io.Writer.

This is a convenience function that makes it suitable for writing directly to files, HTTP responses, or other output streams.

Example:

err := Render(os.Stdout, Div("Hello"))
// Outputs: <div>Hello</div>

Types

type Element

type Element struct {
	Tag        string      // HTML tag name
	IsVoid     bool        // Whether the tag is self-closing (e.g., <br>, <img>)
	Attributes []attribute // HTML attributes as key-value pairs
	Children   []HyperNode // Child nodes
}

Element represents an HTML element with its attributes and children.

func (Element) Render

func (me Element) Render(w io.Writer) error

Render generates the HTML for the element and its children to the provided writer.

type HyperNode added in v1.7.0

type HyperNode interface {
	Render(io.Writer) error
}

HyperNode represents any renderable HTML element or text content.

The HyperNode interface is the core abstraction that allows both HTML elements and text content to be treated uniformly when building and rendering HTML trees. All elements created by the factory functions (Div(), P(), Svg(), etc.) implement this interface.

Example:

var node HyperNode = Div("Hello")
err := node.Render(os.Stdout)

func A

func A(args ...any) HyperNode

A creates hyperlinks to other web pages, files, locations within the same page, or anything else a URL can address.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a

func Abbr

func Abbr(args ...any) HyperNode

Abbr represents an abbreviation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/abbr

func Address

func Address(args ...any) HyperNode

Address indicates contact information for a person or organization.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/address

func Area

func Area(attrs ...KV) HyperNode

Area defines an area inside an image map that has predefined clickable areas. An image map allows geometric areas on an image to be associated with hyperlink.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/area

func Article

func Article(args ...any) HyperNode

Article creates an article element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/article

func Aside

func Aside(args ...any) HyperNode

Aside creates an aside element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/aside

func Audio

func Audio(args ...any) HyperNode

Audio is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the source element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio

func B

func B(args ...any) HyperNode

B draws attention to text without conveying importance.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/b

func Base

func Base(attrs ...KV) HyperNode

Base specifies the base URL and default browsing context for relative URLs.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/base

func Bdi

func Bdi(args ...any) HyperNode

Bdi isolates text for bidirectional text formatting.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/bdi

func Bdo

func Bdo(args ...any) HyperNode

Bdo overrides the current text direction.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/bdo

func Blockquote

func Blockquote(args ...any) HyperNode

Blockquote represents a section quoted from another source.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/blockquote

func Body

func Body(args ...any) HyperNode

Body represents the content of an HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/body

func Br

func Br(attrs ...KV) HyperNode

Br produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/br

func Button

func Button(args ...any) HyperNode

Button is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology. Once activated, it performs an action, such as submitting a form or opening a dialog.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button

func Canvas

func Canvas(args ...any) HyperNode

Canvas is a container element to use with either the canvas scripting API or the WebGL API to draw graphics and animations.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/canvas

func Caption

func Caption(args ...any) HyperNode

Caption specifies the caption (or title) of a table.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/caption

func Cite

func Cite(args ...any) HyperNode

Cite marks the title of a creative work.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/cite

func Code

func Code(args ...any) HyperNode

Code displays its contents styled as computer code.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/code

func Col

func Col(attrs ...KV) HyperNode

Col defines one or more columns in a column group represented by its implicit or explicit parent &lt;colgroup&gt; element. The &lt;col&gt; element is only valid as a child of a &lt;colgroup&gt; element that has no span attribute defined.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/col

func Colgroup

func Colgroup(args ...any) HyperNode

Colgroup defines a group of columns within a table.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/colgroup

func Data

func Data(args ...any) HyperNode

Data links content with a machine-readable translation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/data

func Datalist

func Datalist(args ...any) HyperNode

Datalist contains a set of &lt;option&gt; elements that represent the permissible or recommended options available to choose from within other controls.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/datalist

func Dd

func Dd(args ...any) HyperNode

Dd provides the description, definition, or value for the preceding term.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dd

func Del

func Del(args ...any) HyperNode

Del represents a range of text that has been deleted from a document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/del

func Details

func Details(args ...any) HyperNode

Details creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label must be provided using the &lt;summary&gt; element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details

func Dfn

func Dfn(args ...any) HyperNode

Dfn indicates the defining instance of a term.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dfn

func Dialog

func Dialog(args ...any) HyperNode

Dialog represents a dialog box or other interactive component, such as a dismissible alert, inspector, or subwindow.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog

func Div

func Div(args ...any) HyperNode

Div is the generic container for flow content.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/div

func Dl

func Dl(args ...any) HyperNode

Dl represents a description list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dl

func DoctypeHtml

func DoctypeHtml() HyperNode

DoctypeHtml creates the <!DOCTYPE html> element.

https://developer.mozilla.org/en-US/docs/Glossary/Doctype

func Dt

func Dt(args ...any) HyperNode

Dt specifies a term in a description or definition list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dt

func Embed

func Embed(attrs ...KV) HyperNode

Embed embeds external content at the specified point in the document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/embed

func Empty

func Empty(args ...any) HyperNode

Empty creates an empty element (no tag).

func Fencedframe

func Fencedframe(args ...any) HyperNode

Fencedframe represents a nested browsing context, like &lt;iframe&gt; but with more native privacy features built in.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/fencedframe

func Fieldset

func Fieldset(args ...any) HyperNode

Fieldset is used to group several controls as well as labels (&lt;label&gt;) within a web form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/fieldset

func Figcaption

func Figcaption(args ...any) HyperNode

Figcaption represents a caption or legend for the contents of its parent figure element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/figcaption

func Figure

func Figure(args ...any) HyperNode

Figure represents self-contained content with an optional caption.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/figure

func Footer(args ...any) HyperNode

Footer creates a footer element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/footer

func Form

func Form(args ...any) HyperNode

Form represents a document section containing interactive controls for submitting information.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form

func H1

func H1(args ...any) HyperNode

H1 creates a level 1 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h1

func H2

func H2(args ...any) HyperNode

H2 creates a level 2 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h2

func H3

func H3(args ...any) HyperNode

H3 creates a level 3 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h3

func H4

func H4(args ...any) HyperNode

H4 creates a level 4 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h4

func H5

func H5(args ...any) HyperNode

H5 creates a level 5 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h5

func H6

func H6(args ...any) HyperNode

H6 creates a level 6 heading element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/h6

func Head(args ...any) HyperNode

Head contains machine-readable information about the document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/head

func Header(args ...any) HyperNode

Header creates a header element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/header

func Hgroup

func Hgroup(args ...any) HyperNode

Hgroup groups a set of h1–h6 elements when they represent a multi-level heading.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/hgroup

func Hr

func Hr(attrs ...KV) HyperNode

Hr represents a thematic break between paragraph-level elements.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/hr

func Html

func Html(args ...any) HyperNode

Html creates the root element of an HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/html

func I

func I(args ...any) HyperNode

I represents text in an alternate voice or mood.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/i

func If

func If(condition bool, result HyperNode) HyperNode

Conditionally returns a Node based on a boolean condition.

This function returns an empty Node (not nil) when the condition is false, which prevents nil pointer issues when building DOM trees.

Example:

Body(
	If(showHeader, Header(...)),
	Main(...),
)

func Iframe

func Iframe(args ...any) HyperNode

Iframe represents a nested browsing context, embedding another HTML page into the current one.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe

func Img

func Img(attrs ...KV) HyperNode

Img embeds an image into the document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img

func Input

func Input(attrs ...KV) HyperNode

Input is used to create interactive controls for web-based forms to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The &lt;input&gt; element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input

func Ins

func Ins(args ...any) HyperNode

Ins represents a range of text that has been added to a document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ins

func Kbd

func Kbd(args ...any) HyperNode

Kbd represents text that the user should enter.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/kbd

func Label

func Label(args ...any) HyperNode

Label represents a caption for an item in a user interface.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/label

func Legend

func Legend(args ...any) HyperNode

Legend represents a caption for the content of its parent &lt;fieldset&gt;.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/legend

func Link(attrs ...KV) HyperNode

Link specifies relationships between the current document and an external resource.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link

func Main

func Main(args ...any) HyperNode

Main creates a main content element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/main

func Map

func Map(args ...any) HyperNode

Map is used with &lt;area&gt; elements to define an image map (a clickable link area).

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/map

func MapSlice

func MapSlice[T any](input []T, f func(T) HyperNode) HyperNode

MapSlice transforms a slice of items into Nodes by applying a function to each element.

Each element in the input slice is transformed using the provided function, and all resulting Nodes are aggregated into a single container Node.

Example:

items := []string{"Apple", "Banana", "Cherry"}
Ul(
	MapSlice(items, func(item string) HyperNode {
		return Li(item)
	}),
)

func Mark

func Mark(args ...any) HyperNode

Mark highlights text for reference.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/mark

func Math

func Math(args ...any) HyperNode

Math is the top-level element in MathML. Every valid MathML instance must be wrapped in it. In addition, you must not nest a second &lt;math&gt; element in another, but you can have an arbitrary number of other child elements in it.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/math

func Menu(args ...any) HyperNode

Menu represents a set of commands or options.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/menu

func Meta

func Meta(attrs ...KV) HyperNode

Meta represents metadata that cannot be represented by other HTML meta-related elements.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta

func Meter

func Meter(args ...any) HyperNode

Meter represents either a scalar value within a known range or a fractional value.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meter

func Nav(args ...any) HyperNode

Nav creates a navigation element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/nav

func Noscript

func Noscript(args ...any) HyperNode

Noscript defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/noscript

func Object

func Object(args ...any) HyperNode

Object represents an external resource, which can be treated as an image, a nested browsing context, or a resource to be handled by a plugin.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/object

func Ol

func Ol(args ...any) HyperNode

Ol represents an ordered list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ol

func Optgroup

func Optgroup(args ...any) HyperNode

Optgroup creates a grouping of options within a &lt;select&gt; element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/optgroup

func Option

func Option(args ...any) HyperNode

Option is used to define an item contained in a &lt;select&gt;, an &lt;optgroup&gt;, or a &lt;datalist&gt; element. As such, &lt;option&gt; can represent menu items in popups and other lists of items in an HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option

func Output

func Output(args ...any) HyperNode

Output is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/output

func P

func P(args ...any) HyperNode

P creates a paragraph element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/p

func Picture

func Picture(args ...any) HyperNode

Picture defines multiple sources for an img element to offer alternative versions of an image for different display/device scenarios.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/picture

func Pre

func Pre(args ...any) HyperNode

Pre represents preformatted text.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/pre

func Progress

func Progress(args ...any) HyperNode

Progress displays an indicator showing the completion progress of a task, typically displayed as a progress bar.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/progress

func Q

func Q(args ...any) HyperNode

Q indicates a short inline quotation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/q

func Repeat

func Repeat(n int, f func() HyperNode) HyperNode

Repeat generates multiple Nodes by calling a function n times.

The provided function is called exactly n times, and each resulting Node is aggregated into a single container Node. Using a function ensures each Node instance is unique (important for elements with mutable state).

Example:

Ul(
	Repeat(5, func() HyperNode {
		return Li("List item")
	}),
)

func Rp

func Rp(args ...any) HyperNode

Rp provides parentheses for browsers that don't support ruby text.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/rp

func Rt

func Rt(args ...any) HyperNode

Rt specifies the ruby text for ruby annotations.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/rt

func Ruby

func Ruby(args ...any) HyperNode

Ruby represents ruby annotations for East Asian typography.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ruby

func S

func S(args ...any) HyperNode

S renders text with a strikethrough.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/s

func Samp

func Samp(args ...any) HyperNode

Samp represents sample output from a computer program.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/samp

func Script

func Script(args ...any) HyperNode

Script is used to embed executable code or data; this is typically used to embed or refer to JavaScript code. The &lt;script&gt; element can also be used with other languages, such as WebGL's GLSL shader programming language and JSON.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script

func Search(args ...any) HyperNode

Search represents a search or filtering interface.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/search

func Section

func Section(args ...any) HyperNode

Section creates a section element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/section

func Select

func Select(args ...any) HyperNode

Select represents a control that provides a menu of options.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/select

func Selectedcontent

func Selectedcontent(args ...any) HyperNode

Selectedcontent displays the content of the currently selected &lt;option&gt; inside a closed &lt;select&gt; element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/selectedcontent

func Slot

func Slot(args ...any) HyperNode

Slot acts as a placeholder inside a web component that you can fill with your own markup, which lets you create separate DOM trees and present them together.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/slot

func Small

func Small(args ...any) HyperNode

Small represents side-comments and small print.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/small

func Source

func Source(attrs ...KV) HyperNode

Source specifies multiple media resources for the picture, the audio element, or the video element. It is a void element, meaning that it has no content and does not have a closing tag. It is commonly used to offer the same media content in multiple file formats in order to provide compatibility with a broad range of browsers given their differing support for image file formats and media file formats.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/source

func Span

func Span(args ...any) HyperNode

Span is the generic inline container for phrasing content.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/span

func Strong

func Strong(args ...any) HyperNode

Strong indicates strong importance.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/strong

func Style

func Style(args ...any) HyperNode

Style contains style information for a document or part of a document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/style

func Sub

func Sub(args ...any) HyperNode

Sub specifies inline text displayed as subscript.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/sub

func Summary

func Summary(args ...any) HyperNode

Summary specifies a summary, caption, or legend for a details element's disclosure box. Clicking the &lt;summary&gt; element toggles the state of the parent &lt;details&gt; element open and closed.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/summary

func Sup

func Sup(args ...any) HyperNode

Sup specifies inline text displayed as superscript.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/sup

func Svg

func Svg(args ...any) HyperNode

Svg is a container defining a new coordinate system and viewport. It is used as the outermost element of SVG documents, but it can also be used to embed an SVG fragment inside an SVG or HTML document.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/svg

func Table

func Table(args ...any) HyperNode

Table represents tabular data—that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/table

func Tbody

func Tbody(args ...any) HyperNode

Tbody groups the body content in a table with information about the table's columns. This is usually in the form of column headers (&lt;th&gt; elements).

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/tbody

func Td

func Td(args ...any) HyperNode

Td is a child of the &lt;tr&gt; element, it defines a cell of a table that contains data.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/td

func Template

func Template(args ...any) HyperNode

Template holds HTML that is not to be rendered immediately when a page is loaded but may be instantiated subsequently during runtime using JavaScript.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template

func Textarea

func Textarea(args ...any) HyperNode

Textarea represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example, a comment on a review or feedback form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/textarea

func Tfoot

func Tfoot(args ...any) HyperNode

Tfoot groups the footer content in a table with information about the table's columns. This is usually a summary of the columns, e.g., a sum of the given numbers in a column.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/tfoot

func Th

func Th(args ...any) HyperNode

Th is a child of the &lt;tr&gt; element, it defines a cell as the header of a group of table cells. The nature of this group can be explicitly defined by the scope and headers attributes.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/th

func Thead

func Thead(args ...any) HyperNode

Thead groups the header content in a table with information about the table's columns. This is usually in the form of column headers (&lt;th&gt; elements).

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/thead

func Time

func Time(args ...any) HyperNode

Time represents a specific period in time.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/time

func Title

func Title(args ...any) HyperNode

Title defines the document's title that is shown in a browser's title bar or a page's tab.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/title

func Tr

func Tr(args ...any) HyperNode

Tr defines a row of cells in a table. The row's cells can then be established using a mix of &lt;td&gt; (data cell) and &lt;th&gt; (header cell) elements.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/tr

func Track

func Track(attrs ...KV) HyperNode

Track is used as a child of the media elements, audio and video. It lets you specify timed text tracks (or time-based data), for example to automatically handle subtitles. The tracks are formatted in WebVTT format (.vtt files)—Web Video Text Tracks.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/track

func U

func U(args ...any) HyperNode

U represents text with an unarticulated annotation.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/u

func Ul

func Ul(args ...any) HyperNode

Ul represents an unordered list.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ul

func Var

func Var(args ...any) HyperNode

Var represents a variable in a mathematical expression or programming context.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/var

func Video

func Video(args ...any) HyperNode

Video embeds a media player which supports video playback into the document. You can also use &lt;video&gt; for audio content, but the audio element may provide a more appropriate user experience.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/video

func Wbr

func Wbr(attrs ...KV) HyperNode

Wbr represents a word break opportunity.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/wbr

type KV

type KV map[string]any

KV represents a key-value map for HTML attributes.

The value type must be either string or bool:

  • string: Attribute will have the format key="value" (HTML-escaped)
  • bool: If true, attribute appears as key (valueless). If false, attribute is omitted.
  • any other type triggers an error during rendering.

Example:

KV{"class": "container", "hidden": true, "disabled": false}
// Renders: class="container" hidden

type RawText

type RawText string

RawText represents a text node that renders its content exactly as provided, without any HTML escaping.

func (RawText) Render

func (me RawText) Render(w io.Writer) error

type Text

type Text string

Text represents a plain text node that renders HTML-escaped content. Unlike HTML elements, Text nodes are not wrapped in tags and are rendered as literal text content with HTML entities automatically escaped.

func (Text) Render

func (me Text) Render(w io.Writer) error

Directories

Path Synopsis
templ: version: v0.3.977
templ: version: v0.3.977
Package hx provides constants for htmx attributes and events.
Package hx provides constants for htmx attributes and events.
extensions/ws
Package hxws provides constants for the htmx WebSocket extension attributes and events.
Package hxws provides constants for the htmx WebSocket extension attributes and events.

Jump to

Keyboard shortcuts

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