Label

En/ Ru

Label

Label links visible text to one form control.

github.com/fastygo/templ/ui

Summary

Label links visible text to one form control.Label sets for attribute when HTMLFor is set.

Use Cases

    Name an email input field

    Name a checkbox in a form item

Semantics

    Root element is label

    for attribute references control id from HTMLFor

Example layout.with-control

import "github.com/fastygo/templ/ui"

templ Example() {
	@ui.Label(ui.LabelProps{HTMLFor: "demo-email"}) {
		Email
	}
}

API

Attrs · templ.Attributes — role: html-attrs

Class · string — role: style-extension

HTMLFor · string — role: control-id