Sidebar
Responsive sidebar navigation - a checkbox-driven rail plus overlay variants with menu and section styles.
Left (default)
Slides in from the left edge. Escape, the backdrop or a menu link closes it.
- Sidebar menu
- Item one
- Item two
- Item three
<div class="ar-sidebar">
<input id="site-sidebar-left" type="checkbox" class="ar-sidebar-toggle" aria-label="Open sidebar">
<div class="ar-sidebar-content">
<button class="ar-btn ar-btn-outline ar-mt-2" data-ar-sidebar-toggle="site-sidebar-left">Open Sidebar</button>
<p class="ar-mt-4 ar-text-gray-600">Slides in from the left edge. <code>Escape</code>, the backdrop or a menu link closes it.</p>
</div>
<div class="ar-sidebar-panel">
<label for="site-sidebar-left" class="ar-sidebar-overlay" aria-label="Close"></label>
<ul class="ar-menu">
<li class="ar-px-2 ar-py-1 ar-font-bold">Sidebar menu</li>
<li><a href="#">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
<li><button type="button" class="ar-btn ar-btn-outline ar-btn-sm ar-m-2" data-ar-sidebar-close>Close</button></li>
</ul>
</div>
</div><div className="ar-sidebar">
<input id="site-sidebar-left" type="checkbox" className="ar-sidebar-toggle" aria-label="Open sidebar" />
<div className="ar-sidebar-content">
<button className="ar-btn ar-btn-outline ar-mt-2" data-ar-sidebar-toggle="site-sidebar-left">Open Sidebar</button>
<p className="ar-mt-4 ar-text-gray-600">Slides in from the left edge. <code>Escape</code>, the backdrop or a menu link closes it.</p>
</div>
<div className="ar-sidebar-panel">
<label htmlFor="site-sidebar-left" className="ar-sidebar-overlay" aria-label="Close"></label>
<ul className="ar-menu">
<li className="ar-px-2 ar-py-1 ar-font-bold">Sidebar menu</li>
<li><a href="#">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
<li><button type="button" className="ar-btn ar-btn-outline ar-btn-sm ar-m-2" data-ar-sidebar-close>Close</button></li>
</ul>
</div>
</div>Right
Add ar-sidebar-panel-end to the panel to anchor it to the right edge.
- Right menu
- Item one
- Item two
- Item three
<div class="ar-sidebar">
<input id="site-sidebar-right" type="checkbox" class="ar-sidebar-toggle" aria-label="Open sidebar">
<div class="ar-sidebar-content">
<button class="ar-btn ar-btn-outline ar-mt-2" data-ar-sidebar-toggle="site-sidebar-right">Open Sidebar</button>
<p class="ar-mt-4 ar-text-gray-600">Add <code>ar-sidebar-panel-end</code> to the panel to anchor it to the right edge.</p>
</div>
<div class="ar-sidebar-panel ar-sidebar-panel-end">
<label for="site-sidebar-right" class="ar-sidebar-overlay" aria-label="Close"></label>
<ul class="ar-menu">
<li class="ar-px-2 ar-py-1 ar-font-bold">Right menu</li>
<li><a href="#">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
</ul>
</div>
</div><div className="ar-sidebar">
<input id="site-sidebar-right" type="checkbox" className="ar-sidebar-toggle" aria-label="Open sidebar" />
<div className="ar-sidebar-content">
<button className="ar-btn ar-btn-outline ar-mt-2" data-ar-sidebar-toggle="site-sidebar-right">Open Sidebar</button>
<p className="ar-mt-4 ar-text-gray-600">Add <code>ar-sidebar-panel-end</code> to the panel to anchor it to the right edge.</p>
</div>
<div className="ar-sidebar-panel ar-sidebar-panel-end">
<label htmlFor="site-sidebar-right" className="ar-sidebar-overlay" aria-label="Close"></label>
<ul className="ar-menu">
<li className="ar-px-2 ar-py-1 ar-font-bold">Right menu</li>
<li><a href="#">Item one</a></li>
<li><a href="#">Item two</a></li>
<li><a href="#">Item three</a></li>
</ul>
</div>
</div>Drawer chrome
<nav class="ar-menu ar-max-w-sm ar-mt-2">
<div class="ar-sidebar-head">
<a class="ar-navbar-brand" href="#">Brand</a>
<button class="ar-btn ar-btn-ghost" aria-label="Close navigation">Close</button>
</div>
<p class="ar-sidebar-title">Guides</p>
<ul class="ar-menu">
<li><a href="#">Getting started</a></li>
<li><a href="#">Theming</a></li>
</ul>
<p class="ar-sidebar-title">Theme</p>
<div class="ar-sidebar-theme">
<button class="ar-btn ar-btn-outline ar-btn-sm">Light</button>
<button class="ar-btn ar-btn-outline ar-btn-sm">Dark</button>
</div>
</nav><nav className="ar-menu ar-max-w-sm ar-mt-2">
<div className="ar-sidebar-head">
<a className="ar-navbar-brand" href="#">Brand</a>
<button className="ar-btn ar-btn-ghost" aria-label="Close navigation">Close</button>
</div>
<p className="ar-sidebar-title">Guides</p>
<ul className="ar-menu">
<li><a href="#">Getting started</a></li>
<li><a href="#">Theming</a></li>
</ul>
<p className="ar-sidebar-title">Theme</p>
<div className="ar-sidebar-theme">
<button className="ar-btn ar-btn-outline ar-btn-sm">Light</button>
<button className="ar-btn ar-btn-outline ar-btn-sm">Dark</button>
</div>
</nav>ar-sidebar-head is the brand + close row, ar-sidebar-title (ar-sidebar-title-sub for the second level) groups the links and ar-sidebar-theme stretches the theme buttons. All three are drawer-mode chrome: inside ar-sidebar they hide at 1024px and above.
Placements: ar-sidebar-panel-end · default slides from the left · extra close control data-ar-sidebar-close · the panel is the .ar-menu inside ar-sidebar-panel · variants: ar-sidebar-nav ar-sidebar-responsive ar-sidebar-compact
Options
| Name | Type / values | Default | Meaning |
|---|---|---|---|
data-ar-sidebar-toggle="checkbox id" | attribute, JS | — | Flips that checkbox; the script also keeps aria-controls and aria-expanded on the button. |
data-ar-sidebar-close | attribute, JS | — | Closes the sidebar the control sits inside. |
ar-sidebar-toggle | class on the checkbox | — | Holds the open state; :checked is what the CSS-only path reads. |
ar-sidebar-is-open / ar-sidebar-is-close | class on .ar-sidebar, JS | — | State hooks for styling while the panel transitions. |
ar-sidebar-panel-end | class, CSS only | — | Panel slides in from the right instead of the left. |
ar-sidebar-nav, ar-sidebar-responsive, ar-sidebar-compact | classes, CSS only | — | The three variants demonstrated in the sections below. |
ar-sidebar-bp-md | class, CSS only | 1024px | Moves the persistent-rail breakpoint to 768px; the script reads the same class. |
ar-sidebar-head | class, CSS only | — | Drawer head: brand + close row with a bottom divider. Hidden at 1024px and above inside ar-sidebar. |
ar-sidebar-title, ar-sidebar-title-sub | classes, CSS only | — | Uppercase group headings for the drawer menu; the sub modifier is the smaller second level. |
ar-sidebar-theme | class, CSS only | — | Theme-button row in the drawer (children stretch). Also hidden at 1024px and above. |
no-JavaScript path | selector | — | .ar-sidebar-toggle:checked ~ .ar-sidebar-panel drives the panel; the script only adds the dialog role, scroll lock and focus trap. |
Navbar menu + sidebar
One list, two layouts. Above 1024px the panel joins the bar and the links sit in a row; below it the same markup is an off-canvas menu behind a burger. Nothing is duplicated, so the two can never drift apart.
Navbar with an off-canvas menu underneath
Shrink the window below 1024px: the row collapses into a burger and the same four links arrive from the left.
<div class="ar-sidebar ar-sidebar-nav">
<input id="nav" type="checkbox" class="ar-sidebar-toggle" aria-label="Open navigation">
<div class="ar-sidebar-content">
<button class="ar-sidebar-burger" data-ar-sidebar-toggle="nav" aria-label="Open navigation">...</button>
<a class="ar-navbar-brand" href="#">Brand</a>
</div>
<div class="ar-sidebar-panel">
<label for="nav" class="ar-sidebar-overlay" aria-label="Close"></label>
<ul class="ar-menu">
<li><a href="#">Home</a></li>
</ul>
</div>
<div class="ar-sidebar-actions"><!-- theme toggle, cart, ... --></div>
</div><div className="ar-sidebar ar-sidebar-nav">
<input id="nav" type="checkbox" className="ar-sidebar-toggle" aria-label="Open navigation" />
<div className="ar-sidebar-content">
<button className="ar-sidebar-burger" data-ar-sidebar-toggle="nav" aria-label="Open navigation">...</button>
<a className="ar-navbar-brand" href="#">Brand</a>
</div>
<div className="ar-sidebar-panel">
<label htmlFor="nav" className="ar-sidebar-overlay" aria-label="Close"></label>
<ul className="ar-menu">
<li><a href="#">Home</a></li>
</ul>
</div>
<div className="ar-sidebar-actions">{/* theme toggle, cart, ... */}</div>
</div>.ar-sidebar is the bar itself · ar-sidebar-content is the brand slot, ar-sidebar-actions the trailing slot · the panel has to stay a sibling of the checkbox so the CSS-only path keeps working, which is why the slots sit beside it rather than in an inner .ar-navbar
Always visible on large screens
Add ar-sidebar-responsive and the panel stops being an overlay from 1024px up: it joins the layout and pushes the page instead of covering it, with no backdrop, no scroll lock and nothing to open. Below that it opens over the page as usual.
Rail that becomes an overlay
<div class="ar-sidebar ar-sidebar-responsive">
<input id="rail" type="checkbox" class="ar-sidebar-toggle" aria-label="Open sidebar">
<div class="ar-sidebar-content">
<button class="ar-btn" data-ar-sidebar-toggle="rail">Open Sidebar</button>
</div>
<div class="ar-sidebar-panel">
<label for="rail" class="ar-sidebar-overlay" aria-label="Close"></label>
<ul class="ar-menu">...</ul>
</div>
</div><div className="ar-sidebar ar-sidebar-responsive">
<input id="rail" type="checkbox" className="ar-sidebar-toggle" aria-label="Open sidebar" />
<div className="ar-sidebar-content">
<button className="ar-btn" data-ar-sidebar-toggle="rail">Open Sidebar</button>
</div>
<div className="ar-sidebar-panel">
<label htmlFor="rail" className="ar-sidebar-overlay" aria-label="Close"></label>
<ul className="ar-menu">...</ul>
</div>
</div>The opener button and the checkbox are hidden from 1024px, so there is nothing left to press · while the rail is on screen the panel never advertises role="dialog", never locks the scroll and never traps Tab
Collapsible icon-only rail
Pair it with ar-sidebar-compact and a second checkbox to collapse a persistent rail down to its icons. Put checked on that checkbox and it starts collapsed. The label keeps its place in the accessibility tree, so a collapsed item still announces its name.
Icon rail
Press the handle at the top of the rail to bring the labels back. Below 1024px the same markup opens as an overlay with the labels showing, because collapse only applies to the persistent layout.
<div class="ar-sidebar ar-sidebar-compact">
<input id="rail" type="checkbox" class="ar-sidebar-toggle" aria-label="Open sidebar">
<input id="rail-collapse" type="checkbox" class="ar-sidebar-collapse-toggle" checked>
<div class="ar-sidebar-content">...</div>
<div class="ar-sidebar-panel">
<label for="rail" class="ar-sidebar-overlay" aria-label="Close"></label>
<label for="rail-collapse" class="ar-sidebar-collapse-btn" aria-label="Toggle labels">...</label>
<ul class="ar-menu">
<li><a href="#">
<span class="ar-menu-icon"><svg ... /></span>
<span class="ar-menu-text">Home</span>
</a></li>
</ul>
</div>
</div><div className="ar-sidebar ar-sidebar-compact">
<input id="rail" type="checkbox" className="ar-sidebar-toggle" aria-label="Open sidebar" />
<input id="rail-collapse" type="checkbox" className="ar-sidebar-collapse-toggle" checked />
<div className="ar-sidebar-content">...</div>
<div className="ar-sidebar-panel">
<label htmlFor="rail" className="ar-sidebar-overlay" aria-label="Close"></label>
<label htmlFor="rail-collapse" className="ar-sidebar-collapse-btn" aria-label="Toggle labels">...</label>
<ul className="ar-menu">
<li><a href="#">
<span className="ar-menu-icon"><svg ... /></span>
<span className="ar-menu-text">Home</span>
</a></li>
</ul>
</div>
</div>ar-menu-icon and ar-menu-text are the two halves of the row · .ar-sidebar-compact is a persistent rail on its own, so it does not also need ar-sidebar-responsive · collapsed rail is 4.5rem wide
Choosing the breakpoint
A persistent rail switches at 1024px, the same width ar-lg: already uses. Add ar-sidebar-bp-md and the whole persistent layout — the rail, the icon rail and the navbar row alike — starts at 768px instead, so a tablet gets the rail a laptop gets. JavaScript reads the same class, so the panel stops being a dialog at exactly the width the stylesheet stops overlaying the page.
Rail that arrives at 768px
<div class="ar-sidebar ar-sidebar-responsive ar-sidebar-bp-md">
<input id="rail" type="checkbox" class="ar-sidebar-toggle" aria-label="Open sidebar">
<div class="ar-sidebar-content">
<button class="ar-btn" data-ar-sidebar-toggle="rail">Open Sidebar</button>
</div>
<div class="ar-sidebar-panel">
<label for="rail" class="ar-sidebar-overlay" aria-label="Close"></label>
<ul class="ar-menu">...</ul>
</div>
</div><div className="ar-sidebar ar-sidebar-responsive ar-sidebar-bp-md">
<input id="rail" type="checkbox" className="ar-sidebar-toggle" aria-label="Open sidebar" />
<div className="ar-sidebar-content">
<button className="ar-btn" data-ar-sidebar-toggle="rail">Open Sidebar</button>
</div>
<div className="ar-sidebar-panel">
<label htmlFor="rail" className="ar-sidebar-overlay" aria-label="Close"></label>
<ul className="ar-menu">...</ul>
</div>
</div>Default is 1024px (ar-lg:) · ar-sidebar-bp-md moves it to 768px (ar-md:) · valid on ar-sidebar-responsive, ar-sidebar-compact and ar-sidebar-nav
Open and close state
ar-sidebar-is-open and ar-sidebar-is-close sit on the root while the panel is on and off screen, so a rule can react to the panel without having to know the toggle is a checkbox. Neither carries any styling of its own — they are hooks for yours. A persistent rail reports ar-sidebar-is-open, because its panel is in the layout whether or not anything was pressed.
Hooked to the panel state
.ar-sidebar-is-open .ar-menu {
box-shadow: 6px 6px 0 var(--ar-primary);
}
.ar-sidebar-is-close .ar-sidebar-content {
box-shadow: inset 4px 0 0 var(--ar-base-300);
}.ar-sidebar-is-open .ar-menu {
box-shadow: 6px 6px 0 var(--ar-primary);
}
.ar-sidebar-is-close .ar-sidebar-content {
box-shadow: inset 4px 0 0 var(--ar-base-300);
}Set by arekui.js, so they need JavaScript · the CSS-only equivalent is .ar-sidebar-toggle:checked ~ .ar-sidebar-panel .ar-menu, which is how every rule in the stylesheet already works · exactly one of the two is always present
Accessibility
Tabwraps at the first and last focusable element of the open panel, so the page behind it is unreachable.Escapecloses the panel and returns focus to whatever opened it.- The panel advertises
role="dialog"andaria-modalwhile open, and the page scroll is locked behind it. - The opener button carries
aria-expandedandaria-controls. - It works with JavaScript off: the checkbox stays focusable and is only painted out, so it shows a focus ring when you tab to it, and the label closes the panel.
- Add
data-ar-sidebar-closeto any control inside the panel for an explicit close button. - A persistent sidebar (
ar-sidebar-responsive,ar-sidebar-compact,ar-sidebar-navabove 1024px) is part of the page rather than over it, so it never becomes a dialog, never locks the scroll and never trapsTab— a rail in the flow has to stay reachable as ordinary content. - Collapsing an icon rail hides the label visually but keeps it announced, so an icon-only item still has a name.