Components Forms
Input
Collect a single line of text with a persistent label and optional hint.
Used for delivery updates.
Usage
Choose a native Type such as email or text. Name is submitted with the form. Required, Disabled, AutoComplete, and Value map to native input attributes.
Register input with Head and pass its properties to Render. Go setup guide
Go usage
err := mono.UI.Render(w, "input", mono.Props{
"AutoComplete": "email",
"Hint": "Used for delivery updates.",
"Label": "Work email",
"Name": "email",
"Placeholder": "name@studio.com",
"Required": true,
"Type": "email",
})Rendered HTML
<div id="demo-input" data-mono="input" class="mu-stack">
<label for="demo-input-value" class="mu-label">Work email</label>
<input id="demo-input-value" class="mu-field" name="email" type="email" value="" placeholder="name@studio.com" aria-describedby="demo-input-hint" autocomplete="email" required >
<p id="demo-input-hint" class="mu-small mu-muted">Used for delivery updates.</p>
</div>Go template
<div id="{{.ID}}" data-mono="input" class="mu-stack">
<label for="{{.ID}}-value" class="mu-label">{{.Label}}</label>
<input id="{{.ID}}-value" class="mu-field" name="{{or .Name .ID}}" type="{{or .Type "text"}}" value="{{.Value}}" placeholder="{{.Placeholder}}" {{if .Hint}}aria-describedby="{{.ID}}-hint"{{end}} {{if .AutoComplete}}autocomplete="{{.AutoComplete}}"{{end}} {{if .Required}}required{{end}} {{if .Disabled}}disabled{{end}}>
{{if .Hint}}<p id="{{.ID}}-hint" class="mu-small mu-muted">{{.Hint}}</p>{{end}}
</div>Use the HTML in a static site
Copy the rendered HTML above. Download these assets into the same folder as your page, then add the tags below to its head.
<link rel="stylesheet" href="./base.css">Copy into your project
Run this command from the Mono checkout. Set -out to the component directory in your application.
go run ./cmd/mono-ui add -out ./components inputExample properties (JSON)
{
"AutoComplete": "email",
"Hint": "Used for delivery updates.",
"Label": "Work email",
"Name": "email",
"Placeholder": "name@studio.com",
"Required": true,
"Type": "email"
}