Components Forms
Calendar
Select a date from a compact month grid or enter it directly.
| Mo | Tu | We | Th | Fr | Sa | Su |
|---|
Usage
Value, Min, and Max accept ISO dates. In the grid, use arrows to move by day or week, Home and End for week boundaries, Page Up and Page Down for months, and Enter or Space to select. The named input carries the form value.
Register calendar with Head and pass its properties to Render. Go setup guide
For a full month of events with a daily agenda, see the Event calendar.
Go usage
err := mono.UI.Render(w, "calendar", mono.Props{
"Label": "Reserve a studio day",
"Name": "studio_day",
"Value": "2026-11-21",
})Rendered HTML
<div id="demo-calendar" data-mono="calendar" class="mu-stack">
<label for="demo-calendar-date" class="mu-label">Reserve a studio day</label>
<input id="demo-calendar-date" class="mu-field" type="date" name="studio_day" value="2026-11-21" >
<div class="mu-month" data-month hidden>
<div class="mu-month-controls">
<button type="button" class="mu-btn" data-prev aria-label="Previous month"><span class="mu-chevron mu-chevron-left" aria-hidden="true"></span></button>
<strong id="demo-calendar-month" class="mu-label" aria-live="polite"></strong>
<button type="button" class="mu-btn" data-next aria-label="Next month"><span class="mu-chevron" aria-hidden="true"></span></button>
</div>
<table aria-labelledby="demo-calendar-month"><thead><tr>
<th scope="col" abbr="Monday">Mo</th><th scope="col" abbr="Tuesday">Tu</th><th scope="col" abbr="Wednesday">We</th>
<th scope="col" abbr="Thursday">Th</th><th scope="col" abbr="Friday">Fr</th><th scope="col" abbr="Saturday">Sa</th><th scope="col" abbr="Sunday">Su</th>
</tr></thead><tbody></tbody></table>
</div>
</div>Go template
<div id="{{.ID}}" data-mono="calendar" class="mu-stack">
<label for="{{.ID}}-date" class="mu-label">{{.Label}}</label>
<input id="{{.ID}}-date" class="mu-field" type="date" name="{{or .Name .ID}}" value="{{.Value}}" {{if .Min}}min="{{.Min}}"{{end}} {{if .Max}}max="{{.Max}}"{{end}} {{if .Required}}required{{end}}>
<div class="mu-month" data-month hidden>
<div class="mu-month-controls">
<button type="button" class="mu-btn" data-prev aria-label="Previous month"><span class="mu-chevron mu-chevron-left" aria-hidden="true"></span></button>
<strong id="{{.ID}}-month" class="mu-label" aria-live="polite"></strong>
<button type="button" class="mu-btn" data-next aria-label="Next month"><span class="mu-chevron" aria-hidden="true"></span></button>
</div>
<table aria-labelledby="{{.ID}}-month"><thead><tr>
<th scope="col" abbr="Monday">Mo</th><th scope="col" abbr="Tuesday">Tu</th><th scope="col" abbr="Wednesday">We</th>
<th scope="col" abbr="Thursday">Th</th><th scope="col" abbr="Friday">Fr</th><th scope="col" abbr="Saturday">Sa</th><th scope="col" abbr="Sunday">Su</th>
</tr></thead><tbody></tbody></table>
</div>
</div>Component CSS
[data-mono="calendar"] { width: min(100%, 24rem); }
[data-mono="calendar"] .mu-month { border: 1px solid var(--mu-line,#bbb); border-radius: .55rem; padding: clamp(.4rem,2vw,.8rem); }
[data-mono="calendar"] .mu-month-controls { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-bottom: .4rem; }
[data-mono="calendar"] .mu-month-controls .mu-btn { width: 2rem; height: 2rem; min-height: 2rem; padding: .4rem; }
[data-mono="calendar"] table { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: center; }
[data-mono="calendar"] th { font-size: .72rem; font-weight: 550; color: #595959; }
[data-mono="calendar"] td { padding: .1rem; }
[data-mono="calendar"] tbody button { display: block; width: 100%; border: 1px solid transparent; border-radius: .28rem; padding: .35rem .1rem; background: transparent; color: inherit; text-align: center; font: inherit; cursor: pointer; }
[data-mono="calendar"] tbody button:hover:not(:disabled) { border-color: #999; }
[data-mono="calendar"] tbody button[aria-pressed="true"] { border-color: currentColor; background: #171717; color: white; }
[data-mono="calendar"] tbody button[aria-current="date"] { text-decoration: underline; text-underline-offset: .2em; }
[data-mono="calendar"] tbody button:disabled { opacity: .35; cursor: default; }
[data-mono="calendar"] tbody button:focus-visible { outline: 2px solid #171717; outline-offset: 1px; }JavaScript module
export function mount(root) {
const input = root.querySelector('input');
const panel = root.querySelector('[data-month]');
const tbody = panel.querySelector('tbody');
const previous = panel.querySelector('[data-prev]');
const next = panel.querySelector('[data-next]');
const heading = panel.querySelector('strong');
const monthFormat = new Intl.DateTimeFormat('en', { month: 'long', year: 'numeric' });
const dayFormat = new Intl.DateTimeFormat('en', { dateStyle: 'full' });
function date(year, month, day) {
const result = new Date(2000, 0, 1, 12);
result.setFullYear(year, month, day);
return result;
}
function parse(value) {
const [year, month, day] = value.split('-').map(Number);
return date(year, month - 1, day);
}
function iso(value) {
return [String(value.getFullYear()).padStart(4, '0'), String(value.getMonth() + 1).padStart(2, '0'), String(value.getDate()).padStart(2, '0')].join('-');
}
const min = parse(input.min || '0001-01-01');
const max = parse(input.max || '9999-12-31');
if (min > max) return;
const clamp = value => value < min ? min : value > max ? max : value;
const today = iso(new Date());
let cursor = clamp(parse(input.value || today));
const moveByMonth = (value, delta) => {
const year = value.getFullYear(), month = value.getMonth() + delta;
return date(year, month, Math.min(value.getDate(), date(year, month + 1, 0).getDate()));
};
function paint(focus = false) {
const year = cursor.getFullYear(), month = cursor.getMonth();
const offset = (date(year, month, 1).getDay() + 6) % 7;
const last = date(year, month + 1, 0).getDate();
heading.textContent = monthFormat.format(cursor);
previous.disabled = date(year, month, 0) < min;
next.disabled = date(year, month + 1, 1) > max;
tbody.replaceChildren();
let row;
for (let slot = 0; slot < Math.ceil((offset + last) / 7) * 7; slot++) {
if (slot % 7 === 0) row = tbody.insertRow();
const cell = row.insertCell();
const day = slot - offset + 1;
if (day < 1 || day > last) continue;
const value = date(year, month, day);
const key = iso(value);
const button = document.createElement('button');
button.type = 'button';
button.textContent = String(day);
button.dataset.day = key;
button.disabled = value < min || value > max;
button.tabIndex = day === cursor.getDate() ? 0 : -1;
button.setAttribute('aria-label', dayFormat.format(value));
button.setAttribute('aria-pressed', String(input.value === key));
if (key === today) button.setAttribute('aria-current', 'date');
cell.append(button);
}
if (focus) tbody.querySelector('[tabindex="0"]')?.focus();
}
function move(value, focus) {
cursor = clamp(value);
paint(focus);
}
previous.addEventListener('click', () => move(moveByMonth(cursor, -1), false));
next.addEventListener('click', () => move(moveByMonth(cursor, 1), false));
tbody.addEventListener('click', event => {
const day = event.target.closest('[data-day]');
if (!day || day.disabled) return;
input.value = day.dataset.day;
input.dispatchEvent(new Event('input', { bubbles: true }));
input.dispatchEvent(new Event('change', { bubbles: true }));
move(parse(day.dataset.day), true);
});
tbody.addEventListener('keydown', event => {
const button = event.target.closest('[data-day]');
if (!button) return;
const current = parse(button.dataset.day);
const weekday = (current.getDay() + 6) % 7;
const jumps = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7, Home: -weekday, End: 6 - weekday };
if (event.key in jumps) {
event.preventDefault();
current.setDate(current.getDate() + jumps[event.key]);
move(current, true);
} else if (event.key === 'PageUp' || event.key === 'PageDown') {
event.preventDefault();
move(moveByMonth(current, event.key === 'PageUp' ? -1 : 1), true);
}
});
const sync = () => move(parse(input.value || today), false);
input.addEventListener('change', sync);
input.form?.addEventListener('reset', () => setTimeout(sync, 0));
panel.hidden = false;
paint();
}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 Ready-to-use module
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./calendar.css">
<script type="module" src="./calendar.js"></script>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 calendarExample properties (JSON)
{
"Label": "Reserve a studio day",
"Name": "studio_day",
"Value": "2026-11-21"
}