Sidebar
Usage
Sidebar uses a native <aside> next to your page content. A3S UI owns the fixed positioning, overlay behavior, active states, nested lists, and details submenu styling. Your app still owns the navigation data and current route.
Include CSS
Import Tailwind and one full A3S UI style bundle.
Or import only the base CSS, Sidebar component CSS, and one style pack.
Using CDN or bundler imports? See the Installation page.
Include JavaScript
Copy or serve the full A3S UI JavaScript bundle.
Or copy or serve the A3S UI runtime and Sidebar script.
Using CDN or bundler imports? See the Installation page.
Add your sidebar HTML
RTL
Set dir="rtl" on the sidebar or a parent element. Logical spacing, nested borders, and item content follow document direction. data-side is physical: left and right refer to viewport sides.
HTML structure
A3S UI maps shadcn/ui's sidebar composition to regular navigation HTML: an <aside> root, one <nav>, optional header/footer regions, grouped lists, item controls, and native <details> for nested menus.
<aside class="sidebar">Sidebar root. Supports
id,data-side="left|right",data-initial-open="false",data-initial-mobile-open="true", anddata-breakpoint. JavaScript managesaria-hidden,inert, and the internaldata-sidebar-initializedflag.<nav aria-label="...">Navigation landmark inside the sidebar.
<header>- Optional header for branding, workspace controls, user controls, or persistent actions.
<section>Scrollable content region between the optional header and footer.
<div role="group" aria-labelledby="...">- Named navigation group. Use a heading element as the group label.
<ul>+<li>Menu and menu item structure. Top-level lists and nested submenu lists receive different spacing and borders.
<a>/<button>- Menu item control. Use links for navigation and buttons for actions. Supports
data-variant="default|outline",data-size="default|sm|lg",data-active="true",disabledon buttons, andaria-disabled="true"on custom-disabled controls. For links, prefer<a aria-current="page">for the current page. Adddata-keep-mobile-sidebar-openon a clicked link, button, or ancestor when that control should not close the mobile sidebar. <details>/<summary>- Native disclosure for collapsible submenus. Put the nested
<ul>directly after<summary>. The<summary>supports the same active, variant, and size attributes as menu item controls. Addidandaria-controlswhen the relationship is not obvious from nearby markup. <hr role="separator">- Optional separator between groups or menu sections.
<footer>- Optional footer for account controls, status, or persistent actions.
<main>- Sibling content wrapper. The desktop margin applies to the sibling immediately after the sidebar.
Set --sidebar-width and --sidebar-mobile-width on :root or the sidebar root to override the default 16rem desktop width and 18rem mobile width.
Desktop and mobile open states are tracked independently across data-breakpoint. Opening the mobile drawer moves focus to its first navigation control. Escape or a backdrop click closes it and returns focus to the control that opened it; ordinary mobile navigation closes the drawer without moving focus back to the previous page.