Components Navigation
Radial navigation
Browse a curved dial of links with a scroll, a drag, or the arrow keys.
Usage
Set Brand, an accessible Label, and an optional Description. Each entry in Items takes a Label and Href, with an optional Mark or ImageURL for its artwork. Scroll, drag vertically, or use the Up and Down arrow keys to turn the dial. Click or tap an off-center link to center it, then activate the centered link to visit its destination. With the keyboard, press Enter to follow the focused link. Escape returns focus to the menu button. When JavaScript is off, visitors can follow the links in a regular list. Use the copy command below to add the component to your project.
Register radial-navigation with Head and pass its properties to Render. Go setup guide
Go usage
err := mono.UI.Render(w, "radial-navigation", mono.Props{
"Brand": "Mono Studio",
"Description": "Open the menu to explore the studio.",
"Items": []any{
map[string]any{
"Href": "../index.html",
"ImageURL": "../curated/compass.svg",
"Label": "Home",
"Mark": "M",
},
map[string]any{
"Href": "../index.html#showcase",
"Label": "Showcase",
"Mark": "S",
},
map[string]any{
"Href": "../index.html#motion",
"ImageURL": "../curated/sliders.svg",
"Label": "Motion",
"Mark": "MO",
},
map[string]any{
"Href": "../components.html",
"Label": "Components",
"Mark": "C",
},
map[string]any{
"Href": "../icons.html",
"Label": "Icons",
"Mark": "I",
},
map[string]any{
"Href": "../docs.html#recipes",
"Label": "Recipes",
"Mark": "R",
},
map[string]any{
"Href": "../index.html#reference",
"ImageURL": "../curated/search.svg",
"Label": "Reference",
"Mark": "RE",
},
map[string]any{
"Href": "../docs.html",
"ImageURL": "../curated/file.svg",
"Label": "Handbook",
"Mark": "H",
},
},
"Label": "Studio navigation",
})Rendered HTML
<section id="demo-radial-navigation" data-mono="radial-navigation" aria-label="Studio navigation">
<div class="mu-wheel-cover">
<div class="mu-wheel-bar">
<span class="mu-wheel-brand">Mono Studio</span>
<button type="button" class="mu-wheel-open" data-wheel-open hidden aria-label="Open navigation menu" aria-haspopup="dialog" aria-expanded="false" aria-controls="demo-radial-navigation-dialog">
<span>Menu</span>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="M2 5h20M2 12h20M2 19h20"/></svg>
</button>
</div>
<p class="mu-wheel-description">Open the menu to explore the studio.</p>
</div>
<nav class="mu-wheel-fallback" data-wheel-fallback aria-label="Studio navigation">
<a href="../index.html">Home</a><a href="../index.html#showcase">Showcase</a><a href="../index.html#motion">Motion</a><a href="../components.html">Components</a><a href="../icons.html">Icons</a><a href="../docs.html#recipes">Recipes</a><a href="../index.html#reference">Reference</a><a href="../docs.html">Handbook</a>
</nav>
<dialog id="demo-radial-navigation-dialog" class="mu-wheel-dialog" data-wheel-dialog aria-label="Studio navigation" aria-describedby="demo-radial-navigation-help">
<span class="mu-wheel-signature" aria-hidden="true">Mono Studio</span>
<button type="button" class="mu-wheel-close" data-wheel-close aria-label="Close navigation menu">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="m4 4 16 16M20 4 4 20"/></svg>
</button>
<nav class="mu-wheel-track" data-wheel-track aria-label="Studio navigation">
<span class="mu-wheel-ticks" aria-hidden="true"></span>
<span class="mu-wheel-indicator" aria-hidden="true"></span>
<div class="mu-wheel-row" data-wheel-row>
<a href="../index.html" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Home</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>M</span>
<img src="../curated/compass.svg" width="40" height="40" alt="" loading="lazy" decoding="async" draggable="false">
</span>
</a>
</div>
<div class="mu-wheel-row" data-wheel-row>
<a href="../index.html#showcase" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Showcase</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>S</span>
</span>
</a>
</div>
<div class="mu-wheel-row" data-wheel-row>
<a href="../index.html#motion" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Motion</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>MO</span>
<img src="../curated/sliders.svg" width="40" height="40" alt="" loading="lazy" decoding="async" draggable="false">
</span>
</a>
</div>
<div class="mu-wheel-row" data-wheel-row>
<a href="../components.html" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Components</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>C</span>
</span>
</a>
</div>
<div class="mu-wheel-row" data-wheel-row>
<a href="../icons.html" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Icons</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>I</span>
</span>
</a>
</div>
<div class="mu-wheel-row" data-wheel-row>
<a href="../docs.html#recipes" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Recipes</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>R</span>
</span>
</a>
</div>
<div class="mu-wheel-row" data-wheel-row>
<a href="../index.html#reference" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Reference</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>RE</span>
<img src="../curated/search.svg" width="40" height="40" alt="" loading="lazy" decoding="async" draggable="false">
</span>
</a>
</div>
<div class="mu-wheel-row" data-wheel-row>
<a href="../docs.html" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">Handbook</span>
<span class="mu-wheel-mark" aria-hidden="true">
<span>H</span>
<img src="../curated/file.svg" width="40" height="40" alt="" loading="lazy" decoding="async" draggable="false">
</span>
</a>
</div>
</nav>
<p class="mu-wheel-help" id="demo-radial-navigation-help">Scroll or drag to browse.<br>Select the centered link to visit.</p>
</dialog>
</section>Go template
<section id="{{.ID}}" data-mono="radial-navigation" aria-label="{{or .Label "Site navigation"}}">
<div class="mu-wheel-cover">
<div class="mu-wheel-bar">
<span class="mu-wheel-brand">{{or .Brand "Menu"}}</span>
{{if .Items}}<button type="button" class="mu-wheel-open" data-wheel-open hidden aria-label="Open navigation menu" aria-haspopup="dialog" aria-expanded="false" aria-controls="{{.ID}}-dialog">
<span>Menu</span>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="M2 5h20M2 12h20M2 19h20"/></svg>
</button>{{end}}
</div>
{{with .Description}}<p class="mu-wheel-description">{{.}}</p>{{end}}
</div>
{{if .Items}}
<nav class="mu-wheel-fallback" data-wheel-fallback aria-label="{{or .Label "Site navigation"}}">
{{range .Items}}<a href="{{.Href}}">{{.Label}}</a>{{end}}
</nav>
<dialog id="{{.ID}}-dialog" class="mu-wheel-dialog" data-wheel-dialog aria-label="{{or .Label "Site navigation"}}" aria-describedby="{{.ID}}-help">
<span class="mu-wheel-signature" aria-hidden="true">{{.Brand}}</span>
<button type="button" class="mu-wheel-close" data-wheel-close aria-label="Close navigation menu">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="m4 4 16 16M20 4 4 20"/></svg>
</button>
<nav class="mu-wheel-track" data-wheel-track aria-label="{{or .Label "Destinations"}}">
<span class="mu-wheel-ticks" aria-hidden="true"></span>
<span class="mu-wheel-indicator" aria-hidden="true"></span>
{{range .Items}}
<div class="mu-wheel-row" data-wheel-row>
<a href="{{.Href}}" class="mu-wheel-link" data-wheel-link draggable="false">
<span class="mu-wheel-number" aria-hidden="true"></span>
<span class="mu-wheel-name">{{.Label}}</span>
{{if or .ImageURL .Mark}}<span class="mu-wheel-mark" aria-hidden="true">
{{with .Mark}}<span>{{.}}</span>{{end}}
{{with .ImageURL}}<img src="{{.}}" width="40" height="40" alt="" loading="lazy" decoding="async" draggable="false">{{end}}
</span>{{end}}
</a>
</div>
{{end}}
</nav>
<p class="mu-wheel-help" id="{{.ID}}-help">Scroll or drag to browse.<br>Select the centered link to visit.</p>
</dialog>
{{end}}
</section>Component CSS
[data-mono="radial-navigation"] {
width: 100%;
color: #f6f6f6;
background: #0c0c0c;
border-radius: .6rem;
--wheel-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.mu-wheel-cover {
position: relative;
isolation: isolate;
overflow: hidden;
padding: clamp(1.25rem, 4%, 2.5rem);
border-radius: inherit;
}
.mu-wheel-cover:has(.mu-wheel-description) {
display: flex;
min-height: 14rem;
flex-direction: column;
justify-content: space-between;
gap: 3rem;
}
.mu-wheel-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.mu-wheel-brand, .mu-wheel-signature { font-size: clamp(1.6rem, 3vw, 2.25rem); font-weight: 500; line-height: 1; letter-spacing: -.065em; }
.mu-wheel-open, .mu-wheel-close {
display: inline-flex; min-width: 2.75rem; min-height: 2.75rem;
align-items: center; justify-content: center; gap: .65rem;
padding: .45rem; border: 0; border-radius: .25rem; background: transparent; color: inherit;
}
.mu-wheel-open span { font: .75rem/1.2 var(--wheel-mono); }
.mu-wheel-open:hover, .mu-wheel-close:hover { background: #292929; }
.mu-wheel-description { max-width: 15rem; color: #c1c1c1; font-size: 1rem; line-height: 1.45; }
.mu-wheel-cover:has(.mu-wheel-description)::after {
content: ""; position: absolute; z-index: -1; pointer-events: none;
width: 21rem; aspect-ratio: 1; right: -9rem; bottom: -15.2rem; border-radius: 50%;
background: repeating-conic-gradient(#898989 0 .5deg, transparent .5deg 4deg);
mask: radial-gradient(closest-side, transparent 88%, #000 88.5% 99.5%, transparent);
}
.mu-wheel-fallback { display: flex; flex-wrap: wrap; gap: .6rem 1.15rem; border-top: 1px solid #393939; padding: 1rem 1.5rem; }
.mu-wheel-fallback a { color: inherit; text-underline-offset: .2em; }
.mu-wheel-dialog {
--wheel-hub: 1.5rem;
--wheel-radius: min(69dvh, calc(100vw + var(--wheel-hub) - 1.3rem), 37rem);
position: fixed; inset: 0;
width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none;
margin: 0; padding: 0; overflow: hidden; overscroll-behavior: contain;
border: 0; background: transparent; color: #f8f8f8;
}
.mu-wheel-dialog:not([open]) { display: none; }
html:has(.mu-wheel-dialog[open]) { overflow: hidden; }
.mu-wheel-dialog::backdrop { background: linear-gradient(90deg, rgb(6 6 6 / 96%) 36%, #090909 77%); }
.mu-wheel-signature { position: absolute; left: max(1.25rem, 3vw); top: max(1.5rem, env(safe-area-inset-top)); color: #bdbdbd; }
.mu-wheel-close {
position: absolute; z-index: 2; right: max(.9rem, env(safe-area-inset-right)); top: max(.8rem, env(safe-area-inset-top));
background: #101010; border: 1px solid #434343; border-radius: 50%;
}
.mu-wheel-help {
position: absolute; pointer-events: none; bottom: max(1.25rem, env(safe-area-inset-bottom)); left: max(1.25rem, 3vw);
color: #acacac; font: .73rem/1.55 var(--wheel-mono);
}
.mu-wheel-track {
display: block; position: absolute; top: 0; bottom: 0; right: 0;
width: min(100%, calc(var(--wheel-radius) - var(--wheel-hub) + 1.25rem));
overflow: clip; touch-action: none; user-select: none; cursor: grab;
color: #fff; counter-reset: wheel-destination;
}
.mu-wheel-track:active { cursor: grabbing; }
.mu-wheel-ticks {
position: absolute; top: 50%; right: calc(0px - var(--wheel-radius) - var(--wheel-hub));
width: calc(2 * var(--wheel-radius)); aspect-ratio: 1;
transform: translateY(-50%) rotate(calc(0deg - var(--wheel-turn, 0deg)));
background: repeating-conic-gradient(from -90deg, #8a8a8a 0 .14deg, transparent .14deg 3.2deg);
mask: radial-gradient(closest-side, transparent calc(100% - .65rem), #000 calc(100% - .62rem) 99.9%, transparent);
pointer-events: none;
}
.mu-wheel-indicator {
position: absolute; top: 50%; right: calc(var(--wheel-radius) - var(--wheel-hub) - 1.45rem);
width: 1.75rem; height: 2px; background: #fff; pointer-events: none;
}
.mu-wheel-row {
position: absolute; top: 50%; right: calc(0px - var(--wheel-hub));
width: var(--wheel-radius); height: 0; transform-origin: 100% 50%;
transform: rotate(calc(0deg - var(--wheel-angle, 0deg)));
opacity: var(--wheel-opacity, 0); counter-increment: wheel-destination;
}
.mu-wheel-link {
position: absolute; top: 0; left: 1.85rem; transform: translateY(-50%);
display: flex; align-items: center; gap: clamp(.55rem, 1.1vw, 1.15rem);
width: min(16rem, calc(var(--wheel-radius) - var(--wheel-hub) - 2.4rem)); min-height: 2.75rem;
color: inherit; text-decoration: none; border-radius: .3rem; cursor: pointer;
}
.mu-wheel-number { flex: none; align-self: center; font: .72rem/1 var(--wheel-mono); font-variant-numeric: tabular-nums; }
.mu-wheel-number::before { content: counter(wheel-destination, decimal-leading-zero); }
.mu-wheel-row[data-active] .mu-wheel-name { font-weight: 650; }
.mu-wheel-name { flex: 1; min-width: 0; text-align: end; overflow-wrap: anywhere; font-weight: 520; font-size: clamp(1rem, 1.65vw, 1.4rem); line-height: 1.12; letter-spacing: -.035em; }
.mu-wheel-link:hover { text-decoration: none; }
.mu-wheel-link:hover .mu-wheel-name { text-decoration: underline; text-underline-offset: .18em; }
.mu-wheel-mark {
display: grid; flex: none; position: relative; place-items: center; overflow: hidden;
width: clamp(2rem, 3.3vw, 2.8rem); aspect-ratio: 1; border-radius: 50%;
background: #dedede; color: #121212; font: 700 .8rem/1 var(--wheel-mono);
}
.mu-wheel-row:nth-of-type(even) .mu-wheel-mark { border: 1px solid #b1b1b1; color: #f5f5f5; background: #333; }
.mu-wheel-mark img { position: absolute; width: 100%; height: 100%; object-fit: cover; background: #d8d8d8; filter: grayscale(1); }
.mu-wheel-mark img[src$=".svg"] { padding: 22%; object-fit: contain; }
@media (max-width: 40rem) {
.mu-wheel-dialog { --wheel-hub: 2.75rem; }
.mu-wheel-track { width: 100%; }
.mu-wheel-link { gap: .7rem; width: min(13.5rem, calc(var(--wheel-radius) - var(--wheel-hub) - 2.4rem)); }
.mu-wheel-signature { font-size: 1.5rem; }
.mu-wheel-help { font-size: .65rem; }
}
@media (prefers-reduced-motion: no-preference) {
.mu-wheel-dialog[open] .mu-wheel-track { animation: mu-wheel-unfold .43s cubic-bezier(.2,.7,.2,1) both; }
.mu-wheel-dialog[open]::backdrop { animation: mu-wheel-dim .25s ease-out both; }
.mu-wheel-dialog[data-closing], .mu-wheel-dialog[data-closing]::backdrop { animation: mu-wheel-close-out 160ms ease-in both; }
@keyframes mu-wheel-close-out { to { opacity: 0; } }
@keyframes mu-wheel-unfold { from { opacity: 0; transform: translateX(4.5rem); } }
@keyframes mu-wheel-dim { from { opacity: 0; } }
}
@media (forced-colors: active) {
.mu-wheel-dialog { background: Canvas; color: CanvasText; }
.mu-wheel-track, .mu-wheel-signature, .mu-wheel-help { color: CanvasText; }
.mu-wheel-indicator { background: Highlight; forced-color-adjust: none; }
}JavaScript module
export function mount(root) {
const opener = root.querySelector('[data-wheel-open]');
const dialog = root.querySelector('[data-wheel-dialog]');
const closer = dialog?.querySelector('[data-wheel-close]');
const track = dialog?.querySelector('[data-wheel-track]');
const links = track ? [...track.querySelectorAll('[data-wheel-link]')] : [];
if (!opener || !closer || typeof dialog.showModal !== 'function' || !links.length) return;
const rows = links.map(link => link.closest('[data-wheel-row]'));
const count = links.length;
const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
const wrap = value => ((value % count) + count) % count;
const distance = value => wrap(value + count / 2) - count / 2;
let active = -1;
let position = Math.max(0, links.findIndex(link => link.getAttribute('aria-current') === 'page'));
let target = position;
let frame = 0;
let drag = null;
let suppressClick = false;
let settleTimer;
let closeTimer;
const pixelsPerStep = () => Math.max(52, Math.min(110, track.clientHeight * .12));
function stopMovement() {
clearTimeout(settleTimer);
cancelAnimationFrame(frame);
}
function paint() {
// With two links the second link always sits below the first as they exchange places.
const pairPosition = 1 - Math.abs(wrap(position) - 1);
for (let i = 0; i < count; i++) {
const offset = count === 2 ? i - pairPosition : distance(i - position);
const prominence = Math.max(0, 1 - Math.abs(offset) / 4.6);
const visibility = prominence || i === active ? '' : 'hidden';
if (visibility === 'hidden' && rows[i].style.visibility === visibility) continue;
rows[i].style.setProperty('--wheel-angle', (offset * 16).toFixed(2) + 'deg');
rows[i].style.setProperty('--wheel-opacity', prominence.toFixed(3));
rows[i].style.visibility = visibility;
}
track.style.setProperty('--wheel-turn', (-position * 16).toFixed(2) + 'deg');
}
function select(step, focus = false) {
const next = wrap(Math.round(step));
if (next !== active) {
if (active !== -1) {
rows[active].removeAttribute('data-active');
links[active].tabIndex = -1;
}
active = next;
rows[active].setAttribute('data-active', '');
links[active].tabIndex = 0;
}
if (focus) {
rows[active].style.visibility = '';
links[active].focus({ preventScroll: true });
}
}
function snap(step, focus = track.contains(document.activeElement)) {
stopMovement();
target = Math.round(step);
select(target, focus);
const start = position;
const time = performance.now();
function tick(now) {
const t = motion.matches ? 1 : Math.min(1, (now - time) / 250);
position = target + (start - target) * (1 - t) ** 3;
paint();
frame = t < 1 ? requestAnimationFrame(tick) : 0;
}
tick(time);
}
links.forEach(link => { link.tabIndex = -1; });
select(position);
paint();
opener.hidden = false;
const fallback = root.querySelector('[data-wheel-fallback]');
if (fallback) fallback.hidden = true;
for (const image of track.querySelectorAll('img')) {
const useMark = () => {
const badge = image.parentElement;
image.remove();
if (!badge.textContent.trim()) badge.hidden = true;
};
if (image.complete && !image.naturalWidth) useMark();
else image.addEventListener('error', useMark, { once: true });
}
opener.addEventListener('click', () => {
if (dialog.open) return;
clearTimeout(closeTimer);
dialog.removeAttribute('data-closing');
suppressClick = false;
dialog.showModal();
opener.setAttribute('aria-expanded', 'true');
links[active].focus({ preventScroll: true });
});
function dismiss() {
if (!dialog.open || dialog.hasAttribute('data-closing')) return;
stopMovement();
drag = null;
if (motion.matches) {
dialog.close();
return;
}
dialog.setAttribute('data-closing', '');
// The timeout also finishes dismissal if the consuming page overrides animations.
closeTimer = setTimeout(() => dialog.close(), 190);
}
closer.addEventListener('click', dismiss);
dialog.addEventListener('cancel', event => {
event.preventDefault();
dismiss();
});
dialog.addEventListener('animationend', event => {
if (event.target === dialog && event.animationName === 'mu-wheel-close-out' && dialog.hasAttribute('data-closing')) {
dialog.close();
}
});
dialog.addEventListener('close', () => {
if (dialog.open) return;
clearTimeout(closeTimer);
dialog.removeAttribute('data-closing');
stopMovement();
drag = null;
position = target = active;
paint();
opener.setAttribute('aria-expanded', 'false');
if (document.activeElement === document.body || dialog.contains(document.activeElement)) {
opener.focus({ preventScroll: true });
}
});
dialog.addEventListener('keydown', event => {
if (count < 2 || dialog.hasAttribute('data-closing') || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
let step;
switch (event.key) {
case 'ArrowUp': case 'ArrowLeft': step = target - 1; break;
case 'ArrowDown': case 'ArrowRight': step = target + 1; break;
case 'Home': step = target + distance(-active); break;
case 'End': step = target + distance(count - 1 - active); break;
default: return;
}
event.preventDefault();
snap(step, true);
});
dialog.addEventListener('wheel', event => {
if (event.ctrlKey) return;
event.preventDefault();
if (drag || count < 2 || dialog.hasAttribute('data-closing')) return;
const delta = Math.abs(event.deltaY) >= Math.abs(event.deltaX) ? event.deltaY : event.deltaX;
const unit = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? track.clientHeight : 1;
stopMovement();
position += Math.max(-4, Math.min(4, delta * unit / pixelsPerStep()));
target = position;
const next = wrap(Math.round(position));
select(position, next !== active && track.contains(document.activeElement));
paint();
settleTimer = setTimeout(() => snap(position), 100);
}, { passive: false });
dialog.addEventListener('pointerdown', event => {
if (event.button !== 0 || !event.isPrimary || dialog.hasAttribute('data-closing')) return;
suppressClick = false;
if (!track.contains(event.target) || count < 2) return;
drag = { id: event.pointerId, y: event.clientY, origin: position, last: position, time: event.timeStamp, speed: 0 };
});
track.addEventListener('dragstart', event => event.preventDefault());
dialog.addEventListener('pointermove', event => {
if (!drag || event.pointerId !== drag.id) return;
const travel = drag.y - event.clientY;
if (!suppressClick) {
if (Math.abs(travel) < 6) return;
suppressClick = true;
stopMovement();
track.setPointerCapture(drag.id);
}
position = drag.origin + travel / pixelsPerStep();
const elapsed = Math.max(1, event.timeStamp - drag.time);
drag.speed = .4 * drag.speed + .6 * (position - drag.last) / elapsed;
drag.last = position;
drag.time = event.timeStamp;
select(position);
paint();
});
function finishDrag(event) {
if (!drag || event.pointerId !== drag.id) return;
if (suppressClick) {
const coast = event.type === 'pointerup' && event.timeStamp - drag.time < 100
? Math.max(-1.5, Math.min(1.5, drag.speed * 100)) : 0;
snap(position + coast);
}
drag = null;
}
dialog.addEventListener('pointerup', finishDrag);
dialog.addEventListener('pointercancel', finishDrag);
dialog.addEventListener('lostpointercapture', finishDrag);
dialog.addEventListener('click', event => {
if (dialog.hasAttribute('data-closing') || (suppressClick && event.detail)) {
event.preventDefault();
return;
}
const link = event.target.closest('[data-wheel-link]');
if (link) {
if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;
const index = links.indexOf(link);
if (index !== active) {
event.preventDefault();
snap(target + distance(index - active), true);
} else {
dialog.close();
}
} else if (!track.contains(event.target) && !closer.contains(event.target) && dialog.open) {
dismiss();
}
});
}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="./radial-navigation.css">
<script type="module" src="./radial-navigation.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 radial-navigationExample properties (JSON)
{
"Brand": "Mono Studio",
"Description": "Open the menu to explore the studio.",
"Items": [
{
"Href": "../index.html",
"ImageURL": "../curated/compass.svg",
"Label": "Home",
"Mark": "M"
},
{
"Href": "../index.html#showcase",
"Label": "Showcase",
"Mark": "S"
},
{
"Href": "../index.html#motion",
"ImageURL": "../curated/sliders.svg",
"Label": "Motion",
"Mark": "MO"
},
{
"Href": "../components.html",
"Label": "Components",
"Mark": "C"
},
{
"Href": "../icons.html",
"Label": "Icons",
"Mark": "I"
},
{
"Href": "../docs.html#recipes",
"Label": "Recipes",
"Mark": "R"
},
{
"Href": "../index.html#reference",
"ImageURL": "../curated/search.svg",
"Label": "Reference",
"Mark": "RE"
},
{
"Href": "../docs.html",
"ImageURL": "../curated/file.svg",
"Label": "Handbook",
"Mark": "H"
}
],
"Label": "Studio navigation"
}