label

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

	AttrFor = []byte(" for=\"")
)

Byte constants for HTML rendering.

Functions

func For

func For(forID string, str string) *element

For Creates a label element associated with a form control by ID, with text content. The most common label pattern. Uses text.Text which HTML-escapes the output. Example: label.For("email", "Email Address") Renders: <label for="email">Email Address</label>

func New

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

New Creates a new label element with child nodes. Example: label.New() Renders: <label></label>

func NewLabel

func NewLabel(forID string, nodes ...node.Node) *element

NewLabel Creates a new label element with for attribute and child nodes. Example: label.NewLabel("email") Renders: <label for="email"></label>

func RawText

func RawText(str string) *element

RawText Creates a new label element with raw text content. Uses text.RawText which is not HTML-escaped. Example: label.RawText("Email <abbr>Addr.</abbr>") Renders: <label>Email <abbr>Addr.</abbr></label>

func RawTextf

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

RawTextf Creates a new label element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: label.RawTextf("<strong>%s</strong>", field) Renders: <label><strong>Email</strong></label>

func Static

func Static(str string) *element

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

func Text

func Text(str string) *element

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

func Textf

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

Textf Creates a new label element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: label.Textf("Enter %s", field) Renders: <label>Enter Email</label>

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