Documentation
¶
Overview ¶
Package button provides constructors and methods for the HTML <button> element.
The <button> HTML element is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology. Once activated, it then performs an action, such as submitting a form or opening a dialog.
Index ¶
- Variables
- func Button(str string) *element
- func New(nodes ...node.Node) *element
- func RawText(str string) *element
- func RawTextf(format string, args ...any) *element
- func Reset(str string) *element
- func Static(str string) *element
- func Submit(str string) *element
- func Text(str string) *element
- func Textf(format string, args ...any) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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>