mirror of
https://github.com/imjasonh/html
synced 2026-07-07 00:23:26 +00:00
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
35 lines
847 B
Go
35 lines
847 B
Go
package html
|
|
|
|
// LabelElement represents the <label> HTML element.
|
|
|
|
type LabelElement[C HTMLContent] basicElement[C]
|
|
|
|
|
|
// Label creates a new <label> element.
|
|
func Label(children ...HTMLContent) *LabelElement[HTMLContent] {
|
|
return &LabelElement[HTMLContent]{
|
|
tagName: "label",
|
|
|
|
content: children,
|
|
}
|
|
}
|
|
|
|
// Render returns the HTML string representation.
|
|
func (e *LabelElement[C]) Render() string {
|
|
return (*basicElement[C])(e).Render()
|
|
}
|
|
|
|
// Attr sets an arbitrary attribute as an escape hatch.
|
|
func (e *LabelElement[C]) Attr(key, value string) *LabelElement[C] {
|
|
e.attributes = append(e.attributes, Attribute{Key: key, Value: value})
|
|
return e
|
|
}
|
|
|
|
|
|
// HtmlFor sets the htmlFor attribute.
|
|
func (e *LabelElement[C]) HtmlFor(v string) *LabelElement[C] {
|
|
e.attributes = append(e.attributes, Attribute{Key: "htmlFor", Value: v})
|
|
return e
|
|
}
|
|
|
|
|