input

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: 27 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func Checkbox(name string, value string) *element

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

func Hidden(name string, value string) *element

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

func Image(name string, src string) *element

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

func Radio(name string, value string) *element

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(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

func Text(name string, value string) *element

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" />

func URL

func URL(name string) *element

URL creates a URL input field with URL validation. Example: input.URL("website") Renders: <input name="website" type="url" />

func Week

func Week(name string) *element

Week creates a week picker input field. Example: input.Week("schedule") Renders: <input name="schedule" type="week" />

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