Components Disclosure

Collapsible

Keep supporting details within reach using a native disclosure.

Live previewGo + HTML
Production notes

Printed in two passes using carbon black ink. Allow one working day for drying before trimming.

Usage

Choose a Label that describes the hidden content. Set Open to show it initially. The disclosure works with pointer, touch, Enter, and Space.

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

Go usage
Go usage
err := mono.UI.Render(w, "collapsible", mono.Props{
	"Description": "Printed in two passes using carbon black ink. Allow one working day for drying before trimming.",
	"Label":       "Production notes",
})
Rendered HTML
Rendered HTML
<details id="demo-collapsible" data-mono="collapsible" class="mu-card">
  <summary class="mu-label mu-disclosure">Production notes</summary>
  <p class="mu-muted">Printed in two passes using carbon black ink. Allow one working day for drying before trimming.</p>
</details>
Go template
Go template
<details id="{{.ID}}" data-mono="collapsible" class="mu-card"{{if .Open}} open{{end}}>
  <summary class="mu-label mu-disclosure">{{.Label}}</summary>
  <p class="mu-muted">{{.Description}}</p>
</details>
Component CSS
Component CSS
[data-mono="collapsible"] { width: min(100%, 24rem); }
[data-mono="collapsible"] summary { cursor: pointer; }
[data-mono="collapsible"] p { margin: .75rem 0 0; }
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="./collapsible.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 collapsible
Example properties (JSON)
example.json
{
  "Description": "Printed in two passes using carbon black ink. Allow one working day for drying before trimming.",
  "Label": "Production notes"
}