Components Forms

Textarea

Offer space for a note, message, or longer answer.

Live previewGo + HTML

Up to 500 characters.

Usage

Pass Rows to set the starting height and MaxLength to limit input. The field remains vertically resizable; its associated hint is announced on focus.

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

Go usage
Go usage
err := mono.UI.Render(w, "textarea", mono.Props{
	"Hint":        "Up to 500 characters.",
	"Label":       "Production notes",
	"MaxLength":   500,
	"Name":        "notes",
	"Placeholder": "Describe the paper, trim, or binding…",
	"Rows":        3,
})
Rendered HTML
Rendered HTML
<div id="demo-textarea" data-mono="textarea" class="mu-stack">
  <label for="demo-textarea-value" class="mu-label">Production notes</label>
  <textarea id="demo-textarea-value" class="mu-field" rows="3" name="notes" placeholder="Describe the paper, trim, or binding…" maxlength="500" aria-describedby="demo-textarea-hint"  ></textarea>
  <p id="demo-textarea-hint" class="mu-small mu-muted">Up to 500 characters.</p>
</div>
Go template
Go template
<div id="{{.ID}}" data-mono="textarea" class="mu-stack">
  <label for="{{.ID}}-value" class="mu-label">{{.Label}}</label>
  <textarea id="{{.ID}}-value" class="mu-field" rows="{{or .Rows 3}}" name="{{or .Name .ID}}" placeholder="{{.Placeholder}}" {{if .MaxLength}}maxlength="{{.MaxLength}}"{{end}} {{if .Hint}}aria-describedby="{{.ID}}-hint"{{end}} {{if .Required}}required{{end}} {{if .Disabled}}disabled{{end}}>{{.Value}}</textarea>
  {{if .Hint}}<p id="{{.ID}}-hint" class="mu-small mu-muted">{{.Hint}}</p>{{end}}
</div>
Component CSS
Component CSS
[data-mono="textarea"] textarea { resize: vertical; min-height: 4.5rem; }
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 Component CSS

HTML head
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./textarea.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 textarea
Example properties (JSON)
example.json
{
  "Hint": "Up to 500 characters.",
  "Label": "Production notes",
  "MaxLength": 500,
  "Name": "notes",
  "Placeholder": "Describe the paper, trim, or binding…",
  "Rows": 3
}