Components Forms
Input group
Attach a visible prefix or suffix to a labeled input.
https://
Enter the domain without the protocol.
Usage
Use Prefix or Suffix for a shared unit, domain, or currency. Label should describe the complete value. Only the input value is submitted.
Register input-group with Head and pass its properties to Render. Go setup guide
Go usage
err := mono.UI.Render(w, "input-group", mono.Props{
"Hint": "Enter the domain without the protocol.",
"Label": "Studio website",
"Name": "site",
"Placeholder": "studio.example",
"Prefix": "https://",
})Rendered HTML
<div id="demo-input-group" data-mono="input-group" class="mu-stack">
<label class="mu-label" for="demo-input-group-value">Studio website</label>
<div class="mu-input-joined">
<span>https://</span>
<input id="demo-input-group-value" type="text" name="site" value="" placeholder="studio.example" aria-describedby="demo-input-group-hint" >
</div>
<p id="demo-input-group-hint" class="mu-muted mu-small">Enter the domain without the protocol.</p>
</div>Go template
<div id="{{.ID}}" data-mono="input-group" class="mu-stack">
<label class="mu-label" for="{{.ID}}-value">{{.Label}}</label>
<div class="mu-input-joined">
{{if .Prefix}}<span>{{.Prefix}}</span>{{end}}
<input id="{{.ID}}-value" type="{{or .Type "text"}}" name="{{or .Name .ID}}" value="{{.Value}}" placeholder="{{.Placeholder}}" {{if .Hint}}aria-describedby="{{.ID}}-hint"{{end}} {{if .Required}}required{{end}} {{if .Disabled}}disabled{{end}}>
{{if .Suffix}}<span>{{.Suffix}}</span>{{end}}
</div>
{{if .Hint}}<p id="{{.ID}}-hint" class="mu-muted mu-small">{{.Hint}}</p>{{end}}
</div>Component CSS
[data-mono="input-group"] .mu-input-joined { display: flex; align-items: stretch; border: 1px solid var(--mu-line,#aaa); border-radius: .45rem; overflow: hidden; }
[data-mono="input-group"] .mu-input-joined:focus-within { outline: 2px solid currentColor; outline-offset: 2px; }
[data-mono="input-group"] .mu-input-joined span { display: flex; align-items: center; background: #f1f1f1; color: #454545; padding: .5rem .7rem; }
[data-mono="input-group"] input { flex: 1; width: 0; padding: .6rem; border: 0; outline: 0; color: inherit; font: inherit; background: transparent; }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">
<link rel="stylesheet" href="./input-group.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 input-groupExample properties (JSON)
{
"Hint": "Enter the domain without the protocol.",
"Label": "Studio website",
"Name": "site",
"Placeholder": "studio.example",
"Prefix": "https://"
}