optgroup

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package optgroup provides constructors and methods for the HTML <optgroup> element.

The <optgroup> HTML element creates a grouping of options within a <select> element.

Index

Constants

This section is empty.

Variables

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

	AttrLabel    = []byte(" label=\"")
	AttrDisabled = []byte(" disabled")
)

Byte constants for HTML rendering.

Functions

func Labelled added in v0.3.0

func Labelled(label string, options ...*option.Element) *element

Labelled creates a labelled optgroup from option elements, enforcing correct nesting at compile time. Example: optgroup.Labelled("Colours", option.Option("red", "Red"), option.Option("blue", "Blue")) Renders: <optgroup label="Colours"><option value="red">Red</option><option value="blue">Blue</option></optgroup>

func New

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

New creates a new optgroup element with child option elements. Example: optgroup.New(option.Option("red", "Red"), option.Option("blue", "Blue")).Label("Colours") Renders: <optgroup label="Colours"><option value="red">Red</option><option value="blue">Blue</option></optgroup>

func Options added in v0.3.0

func Options(options ...*option.Element) *element

Options creates an optgroup from option elements, enforcing correct nesting at compile time. Example: optgroup.Options(option.Option("red", "Red"), option.Option("blue", "Blue")).Label("Colours") Renders: <optgroup label="Colours"><option value="red">Red</option><option value="blue">Blue</option></optgroup>

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