Pattern
Sidebar Requires JS
Left navigation column for app shells. Collapsible sections, active-route indicator, footer for account / sign-out. The post-login surface that runs every workspace app.
About
Overview
Sidebars present persistent navigation in admin / dashboard apps. They give users a stable mental map of "what's in this app". Stay narrow (240–280 px), collapsible to icons-only on tight screens, scroll independently from the main content.
Live
Demo
<div class="ren-sidebar-layout">
<ren-sidebar class="ren-sidebar" aria-label="Workspace">
<div class="ren-sidebar-header">
<a class="ren-sidebar-item" href="/">
<span class="ren-sidebar-item-icon" aria-hidden="true">◆</span>
<span class="ren-sidebar-item-text">Acme</span>
</a>
<button class="ren-sidebar-toggle" type="button" aria-label="Toggle sidebar">
<span aria-hidden="true">☰</span>
</button>
</div>
<nav class="ren-sidebar-nav" aria-label="Workspace sections">
<a class="ren-sidebar-item active" href="/dashboard" aria-current="page" data-tooltip="Dashboard">
<span class="ren-sidebar-item-icon" aria-hidden="true">▤</span>
<span class="ren-sidebar-item-text">Dashboard</span>
</a>
<a class="ren-sidebar-item" href="/projects">…</a>
</nav>
</ren-sidebar>
<main class="ren-sidebar-main">…</main>
</div>The preview above is the same markup with one deviation: its content column is a <div class="ren-sidebar-main"> rather than a <main>, because this documentation page already owns the only main landmark on the page. In an app shell, use <main>.
Reference
API
| Class | Effect |
|---|---|
.ren-sidebar-layout | The app shell. Flex row holding the sidebar and the content column. |
.ren-sidebar | On the <ren-sidebar> host. Fixed width, own scroll, collapses to icons. |
.ren-sidebar-header | Top row: brand link plus the collapse toggle. |
.ren-sidebar-nav | The <nav> landmark wrapping the items. |
.ren-sidebar-item | One link. Holds .ren-sidebar-item-icon and .ren-sidebar-item-text; the text fades out when collapsed. |
.ren-sidebar-section | One group of links. Optional .ren-sidebar-section-label as its caption. |
.ren-sidebar-footer | Bottom-pinned slot for account menu, version info. |
.ren-sidebar-toggle | Collapse button. Needs an aria-label; hidden under 48rem. |
.ren-sidebar-main | The content column beside the sidebar. |
[data-collapsed] | State attribute on the host for icon-only mode. Set by the toggle, persisted in localStorage. |
[data-open] | State attribute on the host for the mobile drawer, paired with .ren-sidebar-overlay. |
Inclusive by default
Accessibility
- The landmark is the inner
<nav class="ren-sidebar-nav">— label it whenever the page carries more than one navigation. - Mark active route with
aria-current="page"; the.activeclass only exists for styling parity. - Collapsed items keep their link text in the accessibility tree, so their names survive icon-only mode.
- Under 48rem the sidebar becomes an off-canvas drawer:
[data-open]on the host, dismissed with Escape or a click on.ren-sidebar-overlay.