Components Layout

Direction

Set the base text direction and inline ordering for a local region.

Live previewGo + HTML

Usage

Pass Direction as ltr, rtl, or auto and a language tag in Lang. Supply Items as a list of links to see the ordering follow the inline direction. The browser applies the setting only within this region.

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

Go usage
Go usage
err := mono.UI.Render(w, "direction", mono.Props{
	"Direction": "rtl",
	"Items": []any{
		map[string]any{
			"Href":  "/docs/using-vite.html",
			"Label": "First",
		},
		map[string]any{
			"Href":  "/docs/using-the-cli.html",
			"Label": "Second",
		},
		map[string]any{
			"Href":  "/docs/component-templates.html",
			"Label": "Third",
		},
	},
	"Label": "Right-to-left layout preview",
	"Lang":  "en",
})
Rendered HTML
Rendered HTML
<nav data-mono="direction" id="demo-direction" dir="rtl" lang="en" class="mu-panel mu-stack" aria-labelledby="demo-direction-label">
  <p id="demo-direction-label" class="mu-small mu-muted">Right-to-left layout preview</p>
  <ol class="mu-row"><li><a class="mu-btn" href="/docs/using-vite.html"><bdi>First</bdi></a></li><li><a class="mu-btn" href="/docs/using-the-cli.html"><bdi>Second</bdi></a></li><li><a class="mu-btn" href="/docs/component-templates.html"><bdi>Third</bdi></a></li></ol>
</nav>
Go template
Go template
<nav data-mono="direction" id="{{.ID}}" dir="{{.Direction}}" {{with .Lang}}lang="{{.}}"{{end}} class="mu-panel mu-stack" aria-labelledby="{{.ID}}-label">
  <p id="{{.ID}}-label" class="mu-small mu-muted">{{.Label}}</p>
  <ol class="mu-row">{{range .Items}}<li><a class="mu-btn" href="{{.Href}}"><bdi>{{.Label}}</bdi></a></li>{{end}}</ol>
</nav>
Component CSS
Component CSS
[data-mono="direction"] { text-align:start; }
[data-mono="direction"] ol { list-style:none; margin:0; padding:0; flex-wrap:wrap; }
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="./direction.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 direction
Example properties (JSON)
example.json
{
  "Direction": "rtl",
  "Items": [
    {
      "Href": "/docs/using-vite.html",
      "Label": "First"
    },
    {
      "Href": "/docs/using-the-cli.html",
      "Label": "Second"
    },
    {
      "Href": "/docs/component-templates.html",
      "Label": "Third"
    }
  ],
  "Label": "Right-to-left layout preview",
  "Lang": "en"
}