Documentation
¶
Overview ¶
Package input provides constructors and methods for the HTML <input> element.
The <input> HTML element creates interactive form controls for collecting user data. The type attribute determines the control's appearance and behaviour, with over 20 different types including text, password, email, number, date, checkbox, radio, file, and more. Each type provides appropriate validation, input methods, and user interfaces. Essential for all forms requiring user input, from simple searches to complex data entry applications.
Index ¶
- Variables
- func Button(value string) *element
- func Checkbox(name string, value string) *element
- func Color(name string) *element
- func Date(name string) *element
- func DateTimeLocal(name string) *element
- func Email(name string) *element
- func File(name string) *element
- func Hidden(name string, value string) *element
- func Image(name string, src string) *element
- func Month(name string) *element
- func New() *element
- func Number(name string) *element
- func Password(name string) *element
- func Radio(name string, value string) *element
- func Range(name string) *element
- func Reset(value string) *element
- func Search(name string) *element
- func Submit(value string) *element
- func Tel(name string) *element
- func Text(name string, value string) *element
- func Time(name string) *element
- func URL(name string) *element
- func Week(name string) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<input") AttrName = []byte(" name=\"") AttrValue = []byte(" value=\"") AttrType = []byte(" type=\"") AttrSrc = []byte(" src=\"") AttrAccept = []byte(" accept=\"") AttrAlt = []byte(" alt=\"") AttrAutoComplete = []byte(" autocomplete=\"") AttrCapture = []byte(" capture=\"") AttrChecked = []byte(" checked") AttrDirName = []byte(" dirname=\"") AttrDisabled = []byte(" disabled") AttrForm = []byte(" form=\"") AttrFormAction = []byte(" formaction=\"") AttrFormEncType = []byte(" formenctype=\"") AttrFormMethod = []byte(" formmethod=\"") AttrFormNoValidate = []byte(" formnovalidate") AttrFormTarget = []byte(" formtarget=\"") AttrHeight = []byte(" height=\"") AttrList = []byte(" list=\"") AttrMax = []byte(" max=\"") AttrMaxLength = []byte(" maxlength=\"") AttrMin = []byte(" min=\"") AttrMinLength = []byte(" minlength=\"") AttrMultiple = []byte(" multiple") AttrPattern = []byte(" pattern=\"") AttrPlaceholder = []byte(" placeholder=\"") AttrPopoverTarget = []byte(" popovertarget=\"") AttrPopoverTargetAction = []byte(" popovertargetaction=\"") AttrReadOnly = []byte(" readonly") AttrRequired = []byte(" required") AttrSize = []byte(" size=\"") AttrStep = []byte(" step=\"") AttrWidth = []byte(" width=\"") AttrAlpha = []byte(" alpha") AttrColorSpace = []byte(" colorspace=\"") )
Byte constants for HTML rendering.
Functions ¶
func Button ¶
func Button(value string) *element
Button creates a button input with no default behaviour. Example: input.Button("Click Me") Renders: <input value="Click Me" type="button" />
func Checkbox ¶
Checkbox creates a checkbox input for boolean or multi-select options. Example: input.Checkbox("agree", "yes") Renders: <input name="agree" value="yes" type="checkbox" />
func Color ¶
func Color(name string) *element
Color creates a colour picker input field. Example: input.Color("theme") Renders: <input name="theme" type="color" />
func Date ¶
func Date(name string) *element
Date creates a date picker input field. Example: input.Date("birthday") Renders: <input name="birthday" type="date" />
func DateTimeLocal ¶
func DateTimeLocal(name string) *element
DateTimeLocal creates a local date and time picker input field. Example: input.DateTimeLocal("meeting") Renders: <input name="meeting" type="datetime-local" />
func Email ¶
func Email(name string) *element
Email creates an email input field with automatic email validation. Example: input.Email("email") Renders: <input name="email" type="email" />
func File ¶
func File(name string) *element
File creates a file upload input for selecting local files. Example: input.File("avatar") Renders: <input name="avatar" type="file" />
func Hidden ¶
Hidden creates a hidden input field not visible to users. Example: input.Hidden("csrf_token", "abc123") Renders: <input name="csrf_token" value="abc123" type="hidden" />
func Image ¶
Image creates an image submit button with graphical representation. Example: input.Image("submit", "/images/submit.png") Renders: <input name="submit" type="image" src="/images/submit.png" />
func Month ¶
func Month(name string) *element
Month creates a month picker input field. Example: input.Month("expiry") Renders: <input name="expiry" type="month" />
func New ¶
func New() *element
New creates a new input element without any initial attributes. Example: input.New().Type(inputtype.Text).Name("username") Renders: <input name="username" type="text" />
func Number ¶
func Number(name string) *element
Number creates a numeric input field with spinner controls. Example: input.Number("quantity") Renders: <input name="quantity" type="number" />
func Password ¶
func Password(name string) *element
Password creates a password input field that obscures entered characters. Example: input.Password("password") Renders: <input name="password" type="password" />
func Radio ¶
Radio creates a radio button input for exclusive selection within a group. Example: input.Radio("gender", "male") Renders: <input name="gender" value="male" type="radio" />
func Range ¶
func Range(name string) *element
Range creates a range slider input for selecting numeric values. Example: input.Range("volume") Renders: <input name="volume" type="range" />
func Reset ¶
func Reset(value string) *element
Reset creates a reset button input that clears form values. Example: input.Reset("Clear Form") Renders: <input value="Clear Form" type="reset" />
func Search ¶
func Search(name string) *element
Search creates a search input field optimised for search queries. Example: input.Search("query") Renders: <input name="query" type="search" />
func Submit ¶
func Submit(value string) *element
Submit creates a submit button input for form submission. Example: input.Submit("Submit Form") Renders: <input value="Submit Form" type="submit" />
func Tel ¶
func Tel(name string) *element
Tel creates a telephone number input field. Example: input.Tel("phone") Renders: <input name="phone" type="tel" />
func Text ¶
Text creates a text input field for single-line text entry. Example: input.Text("title", "Mr") Renders: <input name="title" value="Mr" type="text" />
func Time ¶
func Time(name string) *element
Time creates a time picker input field. Example: input.Time("appointment") Renders: <input name="appointment" type="time" />