Components Disclosure
Accordion
Group related questions into individually expandable rows. Opening a question closes the previous answer.
Which paper is used?
Every edition is printed on uncoated, 120 gsm recycled paper.
How large is the print?
The finished sheet measures 210 × 297 mm, with a 12 mm white border.
Can I order a proof?
Request a proof when placing your order to review the finish before printing.
Usage
Give each item a Label and Description. Set Open on the initial item. The native summary works with Enter or Space and its expanded state is announced automatically.
Register accordion with Head and pass its properties to Render. Go setup guide
Go usage
err := mono.UI.Render(w, "accordion", mono.Props{
"Items": []any{
map[string]any{
"Description": "Every edition is printed on uncoated, 120 gsm recycled paper.",
"Label": "Which paper is used?",
"Open": true,
},
map[string]any{
"Description": "The finished sheet measures 210 × 297 mm, with a 12 mm white border.",
"Label": "How large is the print?",
},
map[string]any{
"Description": "Request a proof when placing your order to review the finish before printing.",
"Label": "Can I order a proof?",
},
},
"Label": "Print questions",
})Rendered HTML
<section id="demo-accordion" data-mono="accordion" aria-label="Print questions">
<details name="demo-accordion-questions" open>
<summary class="mu-label mu-disclosure">Which paper is used?</summary>
<p class="mu-muted">Every edition is printed on uncoated, 120 gsm recycled paper.</p>
</details><details name="demo-accordion-questions">
<summary class="mu-label mu-disclosure">How large is the print?</summary>
<p class="mu-muted">The finished sheet measures 210 × 297 mm, with a 12 mm white border.</p>
</details><details name="demo-accordion-questions">
<summary class="mu-label mu-disclosure">Can I order a proof?</summary>
<p class="mu-muted">Request a proof when placing your order to review the finish before printing.</p>
</details>
</section>Go template
<section id="{{.ID}}" data-mono="accordion" aria-label="{{.Label}}">
{{range .Items}}<details name="{{$.ID}}-questions"{{if .Open}} open{{end}}>
<summary class="mu-label mu-disclosure">{{.Label}}</summary>
<p class="mu-muted">{{.Description}}</p>
</details>{{end}}
</section>Component CSS
[data-mono="accordion"] { width: min(100%, 28rem); }
[data-mono="accordion"] details { border-bottom: 1px solid #d5d5d5; }
[data-mono="accordion"] summary { cursor: pointer; padding: .9rem 0; }
[data-mono="accordion"] p { margin: 0 0 1rem; }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="./accordion.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 accordionExample properties (JSON)
{
"Items": [
{
"Description": "Every edition is printed on uncoated, 120 gsm recycled paper.",
"Label": "Which paper is used?",
"Open": true
},
{
"Description": "The finished sheet measures 210 × 297 mm, with a 12 mm white border.",
"Label": "How large is the print?"
},
{
"Description": "Request a proof when placing your order to review the finish before printing.",
"Label": "Can I order a proof?"
}
],
"Label": "Print questions"
}