Components Data display
Keyboard shortcut
Show a keyboard combination next to the action it describes.
Control plus K
CtrlK
Usage
Provide Keys in press order and provide Label as the announcement for the complete shortcut. Connect the actual shortcut to an action in your application.
Register kbd with Head and pass its properties to Render. Go setup guide
Go usage
err := mono.UI.Render(w, "kbd", mono.Props{
"Keys": []any{
"Ctrl",
"K",
},
"Label": "Control plus K",
})Rendered HTML
<span data-mono="kbd" id="demo-kbd" class="mu-row">
<span class="mu-sr-only">Control plus K</span>
<kbd aria-hidden="true">Ctrl</kbd><kbd aria-hidden="true">K</kbd>
</span>Go template
<span data-mono="kbd" id="{{.ID}}" class="mu-row">
<span class="mu-sr-only">{{.Label}}</span>
{{range .Keys}}<kbd aria-hidden="true">{{.}}</kbd>{{end}}
</span>Component CSS
[data-mono="kbd"] { display:inline-flex; gap:.25rem; }
[data-mono="kbd"] kbd { display:inline-block; min-width:1.55rem; padding:.18rem .38rem; border:1px solid #c3c3c3; border-bottom-width:2px; border-radius:.3rem; background:#fafafa; text-align:center; font:.78rem/1.4 ui-monospace,monospace; }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="./kbd.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 kbdExample properties (JSON)
{
"Keys": [
"Ctrl",
"K"
],
"Label": "Control plus K"
}