MDK Logo

Sidebar

Application sidebar with collapsible state, persistent expansion (via `localStorage`), optional overlay mode, and item-click + active-item highlighting.

Application sidebar with collapsible state, persistent expansion (via localStorage), optional overlay mode, and item-click + active-item highlighting.

import { Sidebar } from "@tetherto/mdk-react-devkit";
PropStatusTypeDefaultDescription
activeIdRequiredstring | undefined
expandedRequiredboolean | undefined
visibleRequiredboolean | undefined
overlayRequiredboolean | undefined
classNameRequiredstring | undefined
defaultExpandedRequiredboolean | undefined
headerRequiredReact.ReactNode
onCloseRequiredVoidFunction | undefined
onExpandedChangeRequired((expanded: boolean) => void) | undefined
onItemClickRequired((item: SidebarMenuItem) => void) | undefined
itemsRequiredSidebarMenuItem[]

Usage

Application sidebar with collapsible state (persisted via localStorage), optional overlay mode, and item-click + active-item highlighting.

Data contracts

type SidebarMenuItem = {
  id: string;
  label: string;
  icon?: ReactNode;
  disabled?: boolean;
  items?: SidebarMenuItem[];
};

Example

/** * Runnable example for Sidebar. */import { useState } from 'react'import { Sidebar } from '@tetherto/mdk-react-devkit'const items = [  { id: '/dashboard', label: 'Dashboard' },  { id: '/alerts', label: 'Alerts' },  { id: '/devices', label: 'Devices' },  { id: '/settings', label: 'Settings' },]export const SidebarExample = () => {  const [active, setActive] = useState('/dashboard')  return (    <Sidebar      items={items}      activeId={active}      onItemClick={(item) => setActive(item.id)}      defaultExpanded    />  )}