Read inside a bounded viewport with a draggable scrollbar, chapter navigation, and a reading progress indicator.
Live previewGo + JavaScript
A study in light
Field notes on four spaces shaped by daylight.
Scroll position0%
/ 04
Beneath the arcade
Arcade Court · Turin
In the covered walk, a few steps carry you from cool shade into the bright court. Each arch draws the boundary again.
Look along the paving and the arches become a sequence of dark pools. Look across the court and the same openings frame the sunlit wall opposite.
/ 04
At the waterline
Harbor House · Seto Inland Sea
A concrete roof reaches past the glass. From under its edge, the horizon seems close enough to draw with a ruler.
The underside of the roof stays dark while the water catches the sky. The narrow band between them changes whenever a ripple passes.
/ 04
Inside the quarry
Quarry Baths · Limestone pool
At the foot of the cut stone, the pool holds a second set of walls. A passing ripple briefly breaks their straight edges.
The brightest surface is the narrow walkway beside the water. It leads the eye to the steps, where each tread catches a different amount of light.
/ 04
Among the cedars
Cedar Studio · Woodland elevation
Daylight reaches the studio in narrow shafts. The forest floor stays dim even as the branches overhead catch the sun.
From the slope below, the window reads as a pale rectangle among the trunks. The roof nearly disappears into the canopy behind it.
Usage
Give the viewport a Label. Pass Sections for a chapter reader or Items for a compact list. The reader works with a wheel, trackpad, touch, and keyboard.
Register scroll-area with Head and pass its properties to Render. Go setup guide
Choosing the content
Use Sections for a reader with a chapter index. Each mono.ScrollSection has a Title and can include Text, Paragraphs, ImageURL, Alt, and Caption. A list of maps with the same keys works as well. Serve your own photographs or reuse the WebP files in examples/components/projects/architecture.
For a compact list, pass Items as a slice of strings. To wrap existing content, pass Content. Plain strings are escaped. Use Go’s template.HTML for trusted markup from your application. The reader checks Sections, then Content, then Items.
Scrolling and sizing
Scroll naturally, drag the handle, or select a chapter. Focus the scrollbar to use the arrow keys, Page Up, Page Down, Home, or End. The percentage tracks the distance through the viewport. The custom rail appears when the contents overflow. With JavaScript disabled, the browser supplies the scrollbar.
Set --sa-height on a specific instance to size its viewport. For example, #delivery-notes { --sa-height: 16rem; } sets the height for the custom content sample below.
Use the scrollbar for a whole page
The rail at the edge of this page follows the document. On desktop, drag the handle or focus it and use the arrow keys, Page Up, Page Down, Home, or End. On phones, swipe anywhere to scroll. A slim indicator appears while the page is moving. A Scroll area inside the page keeps its own position.
To add the rail to your own pages, save the two files together and include them in your shared HTML head. The module attaches to the document automatically. Download the stylesheet · Download the module
err := mono.UI.Render(w, "scroll-area", mono.Props{
"Label": "Studio handbook",
"Sections": []mono.ScrollSection{
{Title: "Paper", Text: "Choose a stock and fold a mock-up.",
Paragraphs: []string{"Check the grain direction before folding."}},
{Title: "Binding", Text: "Mark your sewing stations along the spine.",
ImageURL: "/images/spine.webp", Alt: "Three sewing stations marked on a folded spine."},
},
})
// Import "html/template" for this application-owned markup.
err := mono.UI.Render(w, "scroll-area", mono.Props{
"ID": "delivery-notes",
"Label": "Delivery notes",
"Content": template.HTML("<ol><li>Inspect the proof.</li><li>Pack the print.</li></ol>"),
})
Go usageGo usage
err := mono.UI.Render(w, "scroll-area", mono.Props{
"Description": "Field notes on four spaces shaped by daylight.",
"Label": "A study in light",
"Sections": []any{
map[string]any{
"Alt": "A row of stone arches casts curved shadows across the floor of an open courtyard.",
"Caption": "Arcade Court · Turin",
"ImageURL": "../components/projects/architecture/arcade-court-720.webp",
"Paragraphs": []any{
"Look along the paving and the arches become a sequence of dark pools. Look across the court and the same openings frame the sunlit wall opposite.",
},
"Text": "In the covered walk, a few steps carry you from cool shade into the bright court. Each arch draws the boundary again.",
"Title": "Beneath the arcade",
},
map[string]any{
"Alt": "A long, low concrete house extends over a rocky stretch of water beneath pine branches.",
"Caption": "Harbor House · Seto Inland Sea",
"ImageURL": "../components/projects/architecture/harbor-house-720.webp",
"Paragraphs": []any{
"The underside of the roof stays dark while the water catches the sky. The narrow band between them changes whenever a ripple passes.",
},
"Text": "A concrete roof reaches past the glass. From under its edge, the horizon seems close enough to draw with a ruler.",
"Title": "At the waterline",
},
map[string]any{
"Alt": "A dark pool and a flight of steps sit between tall, pale quarry walls.",
"Caption": "Quarry Baths · Limestone pool",
"ImageURL": "../components/projects/architecture/quarry-baths-720.webp",
"Paragraphs": []any{
"The brightest surface is the narrow walkway beside the water. It leads the eye to the steps, where each tread catches a different amount of light.",
},
"Text": "At the foot of the cut stone, the pool holds a second set of walls. A passing ripple briefly breaks their straight edges.",
"Title": "Inside the quarry",
},
map[string]any{
"Alt": "A small timber studio stands on a wooded slope with light filtering between the trunks.",
"Caption": "Cedar Studio · Woodland elevation",
"ImageURL": "../components/projects/architecture/cedar-studio-720.webp",
"Paragraphs": []any{
"From the slope below, the window reads as a pale rectangle among the trunks. The roof nearly disappears into the canopy behind it.",
},
"Text": "Daylight reaches the studio in narrow shafts. The forest floor stays dim even as the branches overhead catch the sun.",
"Title": "Among the cedars",
},
},
})
Rendered HTMLRendered HTML
<section data-mono="scroll-area" id="demo-scroll-area" class="sa-reader sa-chapters" aria-labelledby="demo-scroll-area-heading">
<header class="sa-mast">
<div class="sa-title-block">
<h2 id="demo-scroll-area-heading">A study in light</h2>
<p>Field notes on four spaces shaped by daylight.</p>
</div>
<div class="sa-progress" data-sa-progress hidden>
<span>Scroll position</span>
<strong><svg width="20" height="20" viewBox="0 0 24 24" aria-hidden="true"><circle class="sa-ring" cx="12" cy="12" r="9" fill="none" stroke-width="2"/><circle class="sa-ring-value" cx="12" cy="12" r="9" fill="none" stroke-width="2" pathLength="1" transform="rotate(-90 12 12)"/></svg><span data-sa-percent>0%</span></strong>
</div>
</header>
<div class="sa-layout">
<nav class="sa-index" data-sa-nav aria-label="Section navigation" hidden>
<div class="sa-index-title"><svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.45" stroke-linecap="round" aria-hidden="true"><path d="M2.5 5h2m3 0h10m-15 5h2m3 0h10m-15 5h2m3 0h10"/></svg>Contents</div>
<ol class="sa-index-list">
<li><button type="button" data-sa-jump="0" aria-controls="demo-scroll-area-section-0"><span class="sa-index-num" aria-hidden="true"></span><span class="sa-index-name">Beneath the arcade</span><svg class="sa-index-arrow" width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 10h11m-4.5-4.5L15 10l-4.5 4.5"/></svg></button></li><li><button type="button" data-sa-jump="1" aria-controls="demo-scroll-area-section-1"><span class="sa-index-num" aria-hidden="true"></span><span class="sa-index-name">At the waterline</span><svg class="sa-index-arrow" width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 10h11m-4.5-4.5L15 10l-4.5 4.5"/></svg></button></li><li><button type="button" data-sa-jump="2" aria-controls="demo-scroll-area-section-2"><span class="sa-index-num" aria-hidden="true"></span><span class="sa-index-name">Inside the quarry</span><svg class="sa-index-arrow" width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 10h11m-4.5-4.5L15 10l-4.5 4.5"/></svg></button></li><li><button type="button" data-sa-jump="3" aria-controls="demo-scroll-area-section-3"><span class="sa-index-num" aria-hidden="true"></span><span class="sa-index-name">Among the cedars</span><svg class="sa-index-arrow" width="16" height="16" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 10h11m-4.5-4.5L15 10l-4.5 4.5"/></svg></button></li>
</ol>
</nav>
<div class="sa-reader-pane">
<div data-sa-viewport id="demo-scroll-area-viewport" class="sa-window mu-scroll-window" role="region" aria-labelledby="demo-scroll-area-heading" tabindex="0">
<div data-sa-content class="sa-content">
<article class="sa-section" data-sa-section id="demo-scroll-area-section-0" aria-labelledby="demo-scroll-area-section-title-0">
<header class="sa-section-head sa-cover">
<img class="sa-cover-img" src="../components/projects/architecture/arcade-court-720.webp" alt="A row of stone arches casts curved shadows across the floor of an open courtyard." decoding="async">
<div class="sa-section-titles"><span class="sa-folio" aria-hidden="true"><span></span> / 04</span>
<h3 id="demo-scroll-area-section-title-0">Beneath the arcade</h3>
</div>
</header>
<p class="sa-caption">Arcade Court · Turin</p>
<div class="sa-copy"><p class="sa-lead">In the covered walk, a few steps carry you from cool shade into the bright court. Each arch draws the boundary again.</p><p>Look along the paving and the arches become a sequence of dark pools. Look across the court and the same openings frame the sunlit wall opposite.</p></div>
</article>
<article class="sa-section" data-sa-section id="demo-scroll-area-section-1" aria-labelledby="demo-scroll-area-section-title-1">
<header class="sa-section-head sa-cover">
<img class="sa-cover-img" src="../components/projects/architecture/harbor-house-720.webp" alt="A long, low concrete house extends over a rocky stretch of water beneath pine branches." decoding="async" loading="lazy">
<div class="sa-section-titles"><span class="sa-folio" aria-hidden="true"><span></span> / 04</span>
<h3 id="demo-scroll-area-section-title-1">At the waterline</h3>
</div>
</header>
<p class="sa-caption">Harbor House · Seto Inland Sea</p>
<div class="sa-copy"><p class="sa-lead">A concrete roof reaches past the glass. From under its edge, the horizon seems close enough to draw with a ruler.</p><p>The underside of the roof stays dark while the water catches the sky. The narrow band between them changes whenever a ripple passes.</p></div>
</article>
<article class="sa-section" data-sa-section id="demo-scroll-area-section-2" aria-labelledby="demo-scroll-area-section-title-2">
<header class="sa-section-head sa-cover">
<img class="sa-cover-img" src="../components/projects/architecture/quarry-baths-720.webp" alt="A dark pool and a flight of steps sit between tall, pale quarry walls." decoding="async" loading="lazy">
<div class="sa-section-titles"><span class="sa-folio" aria-hidden="true"><span></span> / 04</span>
<h3 id="demo-scroll-area-section-title-2">Inside the quarry</h3>
</div>
</header>
<p class="sa-caption">Quarry Baths · Limestone pool</p>
<div class="sa-copy"><p class="sa-lead">At the foot of the cut stone, the pool holds a second set of walls. A passing ripple briefly breaks their straight edges.</p><p>The brightest surface is the narrow walkway beside the water. It leads the eye to the steps, where each tread catches a different amount of light.</p></div>
</article>
<article class="sa-section" data-sa-section id="demo-scroll-area-section-3" aria-labelledby="demo-scroll-area-section-title-3">
<header class="sa-section-head sa-cover">
<img class="sa-cover-img" src="../components/projects/architecture/cedar-studio-720.webp" alt="A small timber studio stands on a wooded slope with light filtering between the trunks." decoding="async" loading="lazy">
<div class="sa-section-titles"><span class="sa-folio" aria-hidden="true"><span></span> / 04</span>
<h3 id="demo-scroll-area-section-title-3">Among the cedars</h3>
</div>
</header>
<p class="sa-caption">Cedar Studio · Woodland elevation</p>
<div class="sa-copy"><p class="sa-lead">Daylight reaches the studio in narrow shafts. The forest floor stays dim even as the branches overhead catch the sun.</p><p>From the slope below, the window reads as a pale rectangle among the trunks. The roof nearly disappears into the canopy behind it.</p></div>
</article>
</div>
</div>
<div data-sa-track class="sa-track" hidden>
<div data-sa-thumb class="sa-thumb" role="scrollbar" aria-label="Scroll position" aria-controls="demo-scroll-area-viewport" aria-orientation="vertical" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" tabindex="0"><span aria-hidden="true"></span></div>
</div>
</div>
</div>
</section>
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 scroll-area
Example properties (JSON)example.json
{
"Description": "Field notes on four spaces shaped by daylight.",
"Label": "A study in light",
"Sections": [
{
"Alt": "A row of stone arches casts curved shadows across the floor of an open courtyard.",
"Caption": "Arcade Court · Turin",
"ImageURL": "../components/projects/architecture/arcade-court-720.webp",
"Paragraphs": [
"Look along the paving and the arches become a sequence of dark pools. Look across the court and the same openings frame the sunlit wall opposite."
],
"Text": "In the covered walk, a few steps carry you from cool shade into the bright court. Each arch draws the boundary again.",
"Title": "Beneath the arcade"
},
{
"Alt": "A long, low concrete house extends over a rocky stretch of water beneath pine branches.",
"Caption": "Harbor House · Seto Inland Sea",
"ImageURL": "../components/projects/architecture/harbor-house-720.webp",
"Paragraphs": [
"The underside of the roof stays dark while the water catches the sky. The narrow band between them changes whenever a ripple passes."
],
"Text": "A concrete roof reaches past the glass. From under its edge, the horizon seems close enough to draw with a ruler.",
"Title": "At the waterline"
},
{
"Alt": "A dark pool and a flight of steps sit between tall, pale quarry walls.",
"Caption": "Quarry Baths · Limestone pool",
"ImageURL": "../components/projects/architecture/quarry-baths-720.webp",
"Paragraphs": [
"The brightest surface is the narrow walkway beside the water. It leads the eye to the steps, where each tread catches a different amount of light."
],
"Text": "At the foot of the cut stone, the pool holds a second set of walls. A passing ripple briefly breaks their straight edges.",
"Title": "Inside the quarry"
},
{
"Alt": "A small timber studio stands on a wooded slope with light filtering between the trunks.",
"Caption": "Cedar Studio · Woodland elevation",
"ImageURL": "../components/projects/architecture/cedar-studio-720.webp",
"Paragraphs": [
"From the slope below, the window reads as a pale rectangle among the trunks. The roof nearly disappears into the canopy behind it."
],
"Text": "Daylight reaches the studio in narrow shafts. The forest floor stays dim even as the branches overhead catch the sun.",
"Title": "Among the cedars"
}
]
}