Sidebar
A bordered panel of links with one sliding highlight, placed inside the content: the sections of a settings page, the folders of an inbox. Not the frame of the app.
Usage
Use it when
- A page has its own secondary sections listed beside the content: Settings (Profile, Notifications, Billing), a help center category, inbox folders.
- A two-column layout (
split-2) where the left column lists what the right column shows.
Use something else when
- The main navigation of the whole app, sticky at full height with a phone drawer: use App shell. The shell already has a highlight, groups and sections.
- Site-wide links across the top: use Top nav.
- Jumping to headings of one long page: use Outline.
- Two to five sibling sections that fit across the page: use Tabs.
- A tree of folders that open and close: use Tree.
Where it goes. In the left column of a split-2 inside the content, 240 px wide, at the top of that column. Below 860 px split-2 stacks it above the content; on phones prefer a list of links that each open a page.
Examples
<nav class="sidebar" aria-label="Workspace">
<span class="sidebar__hl" aria-hidden="true" style="transform: translateY(120px);"></span>
<span class="sidebar__head">Workspace</span>
<a class="sidebar__item" href="/home"><span class="ic" aria-hidden="true">home</span>Home</a>
<a class="sidebar__item" href="/courses" aria-current="page"><span class="ic" aria-hidden="true">menu_book</span>Courses<span class="sidebar__badge">6</span></a>
</nav>
<script type="module">
// Move the one highlight to the current item
const nav = document.querySelector('.sidebar');
const cur = nav.querySelector('[aria-current="page"]');
nav.querySelector('.sidebar__hl').style.transform = `translateY(${cur.offsetTop}px)`;
</script>split-2; stacks above the content below 860 px.Profile
How your name and photo appear to lecturers and classmates.
<div class="split-2" style="--side: 240px;">
<nav class="sidebar" aria-label="Settings">
<span class="sidebar__hl" aria-hidden="true" style="transform: translateY(10px);"></span>
<a class="sidebar__item" href="#sb2" aria-current="page"><span class="ic" aria-hidden="true">person</span>Profile</a>
<a class="sidebar__item" href="#sb2"><span class="ic" aria-hidden="true">notifications</span>Notifications</a>
<a class="sidebar__item" href="#sb2"><span class="ic" aria-hidden="true">lock</span>Password and sign in</a>
</nav>
<div class="section" id="sb2">
<div class="section__head"><h2>Profile</h2><p class="section__sub">How your name and photo appear to lecturers and classmates.</p></div>
</div>
</div>Anatomy
| Part | What it is |
|---|---|
nav.sidebar | Required. The panel with aria-label; base background, 1 px line, 16 px radius. |
.sidebar__hl | Required. The single highlight; first child, aria-hidden. Move it with transform: translateY(<item offsetTop>px). |
.sidebar__head | A caption above a group of items. |
.sidebar__item | Required. A link or button: .ic + text (+ .sidebar__badge). aria-current="page" on the current one. |
.sidebar__badge | A quiet count at the end of the item. |
States
| State | How |
|---|---|
aria-current="page" | Accent text at weight 500 and a filled icon; the highlight sits behind it. |
hover | A quiet tint on the item. |
focus | System focus ring. |
Motion and microinteractions
- Highlight: one
.sidebar__hltranslates on--spring-smoothover--d-smooth(560 ms); a second click mid-glide retargets it smoothly. Item text color eases over--d-fast. - Set the first position without a transition (
transition: nonefor one frame) so the highlight does not fly in on load. - Reduced motion: the highlight moves in 120 ms linear.
Accessibility
- A
<nav aria-label>; items are links when they change the URL, buttons when they swap content in place. - Mark the current item with
aria-current="page", not only with the highlight. - Badges are read as part of the name; keep them numeric and meaningful.
Do and don't
Do
- Use one highlight and move it; never tint each item on its own.
- Keep the list short (under ten items) and the labels to a few words.
Don't
- Use the sidebar as the app frame; that is the app shell.
- Put a sidebar inside an app shell sidebar.
- Collapse it to icons only; labels are what make it scannable.
Behavior and code
Plain HTML. None. Move aria-current and set .sidebar__hl transform: translateY(<offsetTop>px) from your code. The app shell does this by itself for the main navigation.