button

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<button")
	TagClose = []byte("</button>")

	AttrCommand             = []byte(" command=\"")
	AttrCommandfor          = []byte(" commandfor=\"")
	AttrDisabled            = []byte(" disabled")
	AttrForm                = []byte(" form=\"")
	AttrFormaction          = []byte(" formaction=\"")
	AttrFormenctype         = []byte(" formenctype=\"")
	AttrFormmethod          = []byte(" formmethod=\"")
	AttrFormnovalidate      = []byte(" formnovalidate")
	AttrFormtarget          = []byte(" formtarget=\"")
	AttrName                = []byte(" name=\"")
	AttrPopOverTarget       = []byte(" popovertarget=\"")
	AttrPopovertargetaction = []byte(" popovertargetaction=\"")
	AttrType                = []byte(" type=\"")
	AttrValue               = []byte(" value=\"")
)

Byte constants for HTML rendering.

Functions

func Button

func Button(str string) *element

Button Creates a generic button with text content Example: button.Button("Click Me") Renders: <button type="button">Click Me</button>

func New

func New(nodes ...node.Node) *element

New Creates a new button element with the given child nodes. Example: button.New(text.Text("Click Me")) Renders: <button>Click Me</button>

func RawText

func RawText(str string) *element

RawText Creates a new button element with raw text content. Uses text.RawText which is not HTML-escaped. Example: button.RawText("<b>Submit</b>") Renders: <button><b>Submit</b></button>

func RawTextf

func RawTextf(format string, args ...any) *element

RawTextf Creates a new button element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: button.RawTextf("<span class=\"icon\">%s</span> Save", icon) Renders: <button><span class="icon">★</span> Save</button>

func Reset

func Reset(str string) *element

Reset Creates a reset button with text content Example: button.Reset("Clear Form") Renders: <button type="reset">Clear Form</button>

func Static

func Static(str string) *element

Static Creates a new button element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: button.Static("Submit") Renders: <button>Submit</button>

func Submit

func Submit(str string) *element

Submit Creates a submit button with text content Example: button.Submit("Send Form") Renders: <button type="submit">Send Form</button>

func Text

func Text(str string) *element

Text Creates a new button element with text content. Uses text.Text which HTML-escapes the output. Example: button.Text("Click Me") Renders: <button>Click Me</button>

func Textf

func Textf(format string, args ...any) *element

Textf Creates a new button element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: button.Textf("Save %s", title) Renders: <button>Save Dashboard</button>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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