Sidebar
A vertical list of navigation links in grouped sections that can collapse, with the current page highlighted.
<arc-sidebar>Overview
Sidebar is a vertical list of links grouped into SidebarSections. Use it when people move between many related pages, as in documentation or an admin dashboard. Each section can have a heading and an icon before it. Set active on the SidebarLink for the current page to highlight it.
A section is a static group until you set collapsible, which turns its heading into a toggle button. open then controls whether the links are showing, and defaults to expanded (no-open starts it collapsed). Clicking the heading fires arc-toggle with { open } in the detail. section.toggle() does the same from script, event included. Setting open directly doesn't fire it. toggle() does nothing on a section without collapsible, because the user would have no heading button to reopen it with.
Put Sidebar in the left column of an AppShell or PageLayout, with TopBar above. It sticks below the top bar, fills the viewport height under it, and scrolls on its own, so a long link list stays reachable on a long page.
Guidelines
Do
- Give every section a short heading, one to three words that name the group
- Set `active` on the link that matches the current route, and on only one link
- Start sections with `no-open` and call `toggle()` on the one holding the active route at page load, so a deep link arrives with its group open
- Show the Sidebar in a Drawer on narrow viewports
- Put the most-used sections first
Don't
- Don't nest Sidebars. Use sections, and the link `level` attribute for indentation
- Don't use it for top-level, site-wide navigation. Use TopBar
- Don't put more than eight to ten links in a section. Split it
Features
- `arc-toggle` carries `{ open }` and bubbles, so one listener on the sidebar covers every section
- Focus-visible ring on every link
- Only `arc-sidebar-link` children of a section are rendered
Preview
Usage
Its events and state need JavaScript, so use the Web Component or a framework wrapper for those.
<script type="module" src="@arclux/arc-ui"></script>
<arc-sidebar>
<arc-sidebar-section heading="Guide">
<arc-sidebar-link href="/docs/getting-started">Getting Started</arc-sidebar-link>
<arc-sidebar-link href="/docs/tokens">Design Tokens</arc-sidebar-link>
<arc-sidebar-link href="/docs/theming" active>Theming</arc-sidebar-link>
</arc-sidebar-section>
<arc-sidebar-section heading="Components">
<arc-sidebar-link href="/docs/components/button">Button</arc-sidebar-link>
<arc-sidebar-link href="/docs/components/card">Card</arc-sidebar-link>
<arc-sidebar-link href="/docs/components/modal">Modal</arc-sidebar-link>
</arc-sidebar-section>
</arc-sidebar>import { Sidebar, SidebarSection, SidebarLink } from '@arclux/arc-ui-react';
export function DocsSidebar() {
return (
<Sidebar>
<SidebarSection heading="Guide">
<SidebarLink href="/docs/getting-started">Getting Started</SidebarLink>
<SidebarLink href="/docs/tokens">Design Tokens</SidebarLink>
<SidebarLink href="/docs/theming" active>Theming</SidebarLink>
</SidebarSection>
<SidebarSection heading="Components">
<SidebarLink href="/docs/components/button">Button</SidebarLink>
<SidebarLink href="/docs/components/card">Card</SidebarLink>
<SidebarLink href="/docs/components/modal">Modal</SidebarLink>
</SidebarSection>
</Sidebar>
);
}<script setup>
import { Sidebar, SidebarSection, SidebarLink } from '@arclux/arc-ui-vue';
</script>
<template>
<Sidebar>
<SidebarSection heading="Guide">
<SidebarLink href="/docs/getting-started">Getting Started</SidebarLink>
<SidebarLink href="/docs/tokens">Design Tokens</SidebarLink>
<SidebarLink href="/docs/theming" active>Theming</SidebarLink>
</SidebarSection>
<SidebarSection heading="Components">
<SidebarLink href="/docs/components/button">Button</SidebarLink>
<SidebarLink href="/docs/components/card">Card</SidebarLink>
<SidebarLink href="/docs/components/modal">Modal</SidebarLink>
</SidebarSection>
</Sidebar>
</template><script>
import { Sidebar, SidebarSection, SidebarLink } from '@arclux/arc-ui-svelte';
</script>
<Sidebar>
<SidebarSection heading="Guide">
<SidebarLink href="/docs/getting-started">Getting Started</SidebarLink>
<SidebarLink href="/docs/tokens">Design Tokens</SidebarLink>
<SidebarLink href="/docs/theming" active>Theming</SidebarLink>
</SidebarSection>
<SidebarSection heading="Components">
<SidebarLink href="/docs/components/button">Button</SidebarLink>
<SidebarLink href="/docs/components/card">Card</SidebarLink>
<SidebarLink href="/docs/components/modal">Modal</SidebarLink>
</SidebarSection>
</Sidebar>import { Component } from '@angular/core';
import { Sidebar, SidebarSection, SidebarLink } from '@arclux/arc-ui-angular';
@Component({
imports: [Sidebar, SidebarSection, SidebarLink],
template: `
<arc-sidebar>
<arc-sidebar-section heading="Guide">
<arc-sidebar-link href="/docs/getting-started">Getting Started</arc-sidebar-link>
<arc-sidebar-link href="/docs/tokens">Design Tokens</arc-sidebar-link>
<arc-sidebar-link href="/docs/theming" active>Theming</arc-sidebar-link>
</arc-sidebar-section>
<arc-sidebar-section heading="Components">
<arc-sidebar-link href="/docs/components/button">Button</arc-sidebar-link>
<arc-sidebar-link href="/docs/components/card">Card</arc-sidebar-link>
<arc-sidebar-link href="/docs/components/modal">Modal</arc-sidebar-link>
</arc-sidebar-section>
</arc-sidebar>
`,
})
export class DocsSidebarComponent {}import { Sidebar, SidebarSection, SidebarLink } from '@arclux/arc-ui-solid';
export function DocsSidebar() {
return (
<Sidebar>
<SidebarSection heading="Guide">
<SidebarLink href="/docs/getting-started">Getting Started</SidebarLink>
<SidebarLink href="/docs/tokens">Design Tokens</SidebarLink>
<SidebarLink href="/docs/theming" active>Theming</SidebarLink>
</SidebarSection>
<SidebarSection heading="Components">
<SidebarLink href="/docs/components/button">Button</SidebarLink>
<SidebarLink href="/docs/components/card">Card</SidebarLink>
<SidebarLink href="/docs/components/modal">Modal</SidebarLink>
</SidebarSection>
</Sidebar>
);
}import { Sidebar, SidebarSection, SidebarLink } from '@arclux/arc-ui-preact';
export function DocsSidebar() {
return (
<Sidebar>
<SidebarSection heading="Guide">
<SidebarLink href="/docs/getting-started">Getting Started</SidebarLink>
<SidebarLink href="/docs/tokens">Design Tokens</SidebarLink>
<SidebarLink href="/docs/theming" active>Theming</SidebarLink>
</SidebarSection>
<SidebarSection heading="Components">
<SidebarLink href="/docs/components/button">Button</SidebarLink>
<SidebarLink href="/docs/components/card">Card</SidebarLink>
<SidebarLink href="/docs/components/modal">Modal</SidebarLink>
</SidebarSection>
</Sidebar>
);
}<arc-sidebar>
<arc-sidebar-section heading="Guide">
<arc-sidebar-link href="/docs/getting-started">Getting Started</arc-sidebar-link>
<arc-sidebar-link href="/docs/tokens">Design Tokens</arc-sidebar-link>
<arc-sidebar-link href="/docs/theming" active>Theming</arc-sidebar-link>
</arc-sidebar-section>
<arc-sidebar-section heading="Components">
<arc-sidebar-link href="/docs/components/button">Button</arc-sidebar-link>
<arc-sidebar-link href="/docs/components/card">Card</arc-sidebar-link>
<arc-sidebar-link href="/docs/components/modal">Modal</arc-sidebar-link>
</arc-sidebar-section>
</arc-sidebar><!-- arc-sidebar is hybrid — CSS handles layout, JS enhances interactivity -->
<arc-sidebar></arc-sidebar>API
activestring''- The href of the currently active sidebar link. Used to highlight the matching link with accent styling.
widthstring''- Width of the sidebar. Accepts any CSS length value. Unset by default, which lets the rail fill whatever container it is placed in, including
arc-app-shell, whose own rail is 280px wide and reads--sidebar-width. Set this only for a standalone sidebar; inside the shell the wrapper wins, and the token is the way to move both together. labelstring'Sidebar navigation'position'left' | 'right''left'- Controls which side the sidebar appears on. Moves the border line to the opposite edge.
collapsedbooleanfalse- When true, collapses the sidebar away entirely: width 0 with its contents clipped, which is the right behaviour for a rail that slides out of the way but is not an icon-only mode. For a persistent icon rail (the VS Code activity-bar shape), use
arc-rail, which is a different component with its own labels and tooltips. glowbooleanfalse- Enables an accent glow effect on the active sidebar link for enhanced visual emphasis.
Events
arc-navigate- Fired when a sidebar link is clicked
See also
- Navigation MenuHorizontal navigation bar whose top-level items open dropdowns of links on hover or click. Each link can carry a one-line description.
- DrawerA panel that slides in from the left or right edge, for navigation menus, filters and detail views.
- App ShellFull-page layout that puts a TopBar, a Sidebar and a scrolling content area into one frame, with a mobile sidebar toggle and an optional table-of-contents rail.
- Top BarThe header bar across the top of an app, with the brand on the left and user controls on the right.