Sidebar
A reusable navigation surface with independent scrolling.
Live TypeScript example
Try the component here, then use the source below in your application.
- JavaScript
- 1.2 KiB
- Component CSS
- 0.9 KiB
- Shared theme CSS
- 3.8 KiBonce per application
How sizes are measured
The JavaScript figure includes this component’s required helpers. CSS includes its styling dependencies. Each entry is bundled separately for ES2022, minified, then compressed with gzip level 9. Your bundler may share helpers across components. Images, fonts, examples and application code are excluded.
Before compression: JavaScript 2.3 KiB; component CSS 3.5 KiB. These figures describe browser assets, not the complete package download.
View all component measurements →Choose a page to update the main content, or hide the sidebar to expand the workspace.
import '@blukavantui/web/theme.css'
import {createSidebar} from '@blukavantui/web/sidebar';
import {createButton} from '@blukavantui/web/button';
import '@blukavantui/web/sidebar.css';
import '@blukavantui/web/button.css';
export function mount(host: HTMLElement) {
const frame = document.createElement("section");
frame.setAttribute("aria-label", "Workspace preview");
frame.style.cssText = "width:100%;min-width:0;border:1px solid var(--bluui-border);border-radius:10px;overflow:hidden;background:var(--bluui-surface)";
const toolbar = document.createElement("div");
toolbar.style.cssText = "display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px;border-bottom:1px solid var(--bluui-border)";
const brand = document.createElement("strong");
brand.textContent = "Atlas workspace";
brand.style.fontSize = "12px";
toolbar.append(brand);
const actions = document.createElement("div");
toolbar.append(actions);
const layout = document.createElement("div");
layout.style.cssText = "display:grid;grid-template-columns:minmax(108px,30%) minmax(0,1fr);min-height:310px";
const navigation = document.createElement("div");
navigation.style.minWidth = "0";
const content = document.createElement("section");
content.setAttribute("aria-label", "Workspace content");
content.style.cssText = "min-width:0;padding:20px 14px;overflow-wrap:anywhere;background:var(--bluui-background)";
layout.append(navigation, content);
frame.append(toolbar, layout);
host.append(frame);
const pages: Record<string, { title: string; description: string; rows: string[] }> = {
overview: { title: "Workspace overview", description: "A snapshot of your team’s work.", rows: ["3 active projects", "12 tasks completed", "2 reviews awaiting feedback"] },
customers: { title: "Customers", description: "Manage the people and teams you work with.", rows: ["Atlas Labs · Active", "Northstar Studio · Active", "Cedar & Co. · New"] },
reports: { title: "Reports", description: "Recent activity across your workspace.", rows: ["Weekly summary · Ready", "Project progress · Updated today", "Team activity · 12 updates"] },
};
function showPage(key: string) {
const page = pages[key];
content.replaceChildren();
const title = document.createElement("h3");
title.textContent = page.title;
title.style.cssText = "font-size:20px;margin:0 0 12px";
const description = document.createElement("p");
description.textContent = page.description;
description.style.cssText = "font-size:13px;line-height:1.6;color:var(--bluui-text-muted)";
const list = document.createElement("ul");
list.style.cssText = "list-style:none;padding:0;margin:20px 0 0;border:1px solid var(--bluui-border);border-radius:8px;background:var(--bluui-surface)";
page.rows.forEach((text, index) => {
const row = document.createElement("li");
row.textContent = text;
row.style.cssText = "padding:13px 10px;font-size:12px";
if (index) row.style.borderTop = "1px solid var(--bluui-border)";
list.append(row);
});
content.append(title, description, list);
}
const sidebar = createSidebar(navigation, {
ActiveKey: "overview",
AccessibleLabel: "Workspace navigation",
Items: [
{ Key: "group", Label: "Workspace", IsGroup: true },
{ Key: "overview", Label: "Overview" },
{ Key: "customers", Label: "Customers" },
{ Key: "reports", Label: "Reports" },
],
}, { Navigate: showPage });
sidebar.element.style.height = "100%";
let open = true;
const toggle = createButton(actions, { Label: "Hide sidebar", Variant: "Outlined", Size: "Small" }, {
Click: () => {
open = !open;
sidebar.update({ IsOpen: open });
navigation.hidden = !open;
layout.style.gridTemplateColumns = open ? "minmax(108px,30%) minmax(0,1fr)" : "minmax(0,1fr)";
toggle.update({ Label: open ? "Hide sidebar" : "Show sidebar" });
syncToggle();
},
});
function syncToggle() {
const button = toggle.element.querySelector("button")!;
button.setAttribute("aria-expanded", String(open));
button.setAttribute("aria-controls", sidebar.element.id);
button.focus({ preventScroll: true });
}
const toggleButton = toggle.element.querySelector("button")!;
toggleButton.setAttribute("aria-expanded", "true");
toggleButton.setAttribute("aria-controls", sidebar.element.id);
showPage("overview");
return { destroy() { sidebar.destroy(); toggle.destroy(); frame.remove(); } };
}
const instance = mount(document.getElementById('example')!)
// When this page or framework component is removed:
// instance.destroy()
Install the library and add the host element
npm install https://blukavantui.blutekmedia.com/downloads/blukavantui-web-0.6.0.tgz<div id="example"></div>This example uses the downloadable @blukavantui/web package. Your application handles persistence and authentication through its typed callbacks. The starter ZIP includes this same example.
createSidebar
Pass options as the second argument and callbacks in the third argument. Keep the returned instance to update options or dispose it when its view is removed.
import { createSidebar } from '@blukavantui/web/sidebar';
import '@blukavantui/web/sidebar.css';Load @blukavantui/web/theme.css once in your app shell.createSidebar(host: HTMLElement, options: SidebarOptions, events?: SidebarEvents)Reference for @blukavantui/web 0.6.0. Required and optional follow the shipped TypeScript declarations; optional does not imply a particular default. Pass typed arrays and objects directly where shown.
Options
6| Name | Type / requirement | Usage |
|---|---|---|
Items | NavigationItem[]Optional | |
Content | SlotOptional | Content slot: pass a DOM node or a text string. Strings are rendered as text. |
ActiveKey | stringOptional | |
IsOpen | booleanOptional | |
AccessibleLabel | stringOptional | Accessible name for assistive technology. |
ExtendedClass | stringOptional | Additional CSS class names on the component root. |
Callbacks
1| Name | Type / requirement | Usage |
|---|---|---|
Navigate | (key: string, event: MouseEvent) => void | Promise<void>Optional |
Instance methods & properties
3| Name | Signature / type | Usage |
|---|---|---|
element | HTMLElement | Root owned by this instance. Dispose before removing its host. |
update | (patch: Partial<SidebarOptions>) => void | Apply a partial options update to this instance. |
destroy | () => void | Dispose the instance and its listeners when the view is removed. |
Related data types
Expand a type for its fields and allowed values.
Callback
type Callback<T extends unknown[] = []> = (...args: T) => void | Promise<void>;CommonOptions
interface CommonOptions {
ExtendedClass?: string;
}Slot
type Slot = Node | string;Use these inputs, events, actions and structures in Service Studio. Names and data bindings are specific to the native Blocks.
Included in the planned free BluKavantUI Community edition. The official OutSystems Forge release is coming soon. View Community scope →
Open OutSystems showcase ↗- Web runtime
- Supported
- TypeScript
- Supported
- OutSystems
- Supported
Statuses describe the component’s rendered code and interactions. Supply accessible content and follow the component guidance when integrating it.
Accessibility guidance →Purpose and use
Keep recurring destinations in a stable sidebar. The application layout owns its open state and responsive placement.
Keyboard design guidance
The menu toggle announces expanded state. A closed sidebar is removed from keyboard navigation. Mark the current destination with aria-current.
See the support status above for review coverage and any limitations.
In your application
Provide useful labels, preserve visible focus, and test the component with your actual content. Use text alongside status colors and check contrast in each state.
Events0No events yet.
Interact with an example to see its events.