Components Forms

Label

Give a control a visible, clickable name.

Live previewGo + HTML

Usage

Click the label to focus its field. When the target already exists elsewhere in your page, set For to its ID to render the label alone.

Register label with Head and pass its properties to Render. Go setup guide

Go usage
Go usage
err := mono.UI.Render(w, "label", mono.Props{
	"Label": "Publication title",
	"Name":  "title",
	"Value": "The field journal",
})
Rendered HTML
Rendered HTML
<div id="demo-label" data-mono="label" class="mu-stack">
  <label class="mu-label" for="demo-label-value">Publication title</label>
  <input id="demo-label-value" class="mu-field" type="text" name="title" value="The field journal">
</div>
Go template
Go template
<div id="{{.ID}}" data-mono="label" class="mu-stack">
  <label class="mu-label" for="{{or .For (printf "%s-value" .ID)}}">{{.Label}}</label>
  {{if not .For}}<input id="{{.ID}}-value" class="mu-field" type="text" name="{{or .Name .ID}}" value="{{.Value}}">{{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.

Shared CSS

HTML 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.

Terminal
go run ./cmd/mono-ui add -out ./components label
Example properties (JSON)
example.json
{
  "Label": "Publication title",
  "Name": "title",
  "Value": "The field journal"
}