# Sidebar Compose an application sidebar with collapsible navigation, project actions and a responsive mobile sheet. [Interactive guide](/docs/components/sidebar) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use Sidebar for navigation that stays available inside an application workspace. ### How to compose it Wrap the sidebar and inset content in SidebarProvider when using the compound entry. Use links for destinations and sibling actions for row tools. ### What to verify Check collapsed labels, the mobile sheet and Escape focus restoration. Expose one desktop collapse command when using a separate trigger. ## Usage ```tsx import { Sidebar, SidebarProvider, SidebarHeader, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarInset, SidebarTrigger, } from 'wss3-forge' import { MailInbox20Regular, Settings20Regular } from '@fluentui/react-icons' ``` - Wrap the panel and SidebarInset in SidebarProvider. SidebarHeader and SidebarFooter stay in place while SidebarContent scrolls. - Choose floating to give the navigation its own inset frame. Choose inset to frame the adjacent SidebarInset content. Both open as an edge panel on mobile. - Pass account directly to either form of Sidebar for a profile menu. Provide the name and menu items. Include an email when the account needs a second identifier. The same control shows the avatar alone when collapsed and opens its menu above the footer. - Pass search with destination items and an onSelect handler. Forge supplies the search trigger and keyboard-accessible command palette in both expanded and collapsed navigation. - Pass teamSwitcher with teams, the selected team name and onChange. Include onAdd to expose the add-team action. Use headerContent or footerContent for additional workspace-specific controls. - Use SidebarMenu and SidebarMenuItem for lists. Use a native link for navigation and a button for actions. Keep SidebarMenuAction as a sibling of the row button. - Use SidebarCollapsibleGroup for a group that can open and close. Give it a label and an optional icon. Its action slot places a separate SidebarGroupAction beside the disclosure, as in Groups, actions and badges. - Submenus keep the same indentation with or without a guide line. The line is visible by default. Set showLine={false} on an individual SidebarMenuSub, as in the RTL example, or set showSubmenuLine={false} for sections-based navigation. A parent item can override that setting for its own children. - Choose a single visible control to toggle the desktop sidebar. These examples use SidebarTrigger or the sections-based collapse button. Ctrl+B or Command+B toggles the active sidebar. On mobile the trigger opens a modal sheet, and Escape returns focus. - Use controlled open/onOpenChange or defaultOpen. Desktop changes write the sidebar_state cookie for seven days unless persist is false. To restore it on initial render pass the cookie value to defaultOpen. - Override --sidebar-width and --sidebar-width-icon on the provider. Keep a readable label or tooltip for each icon. For a menu defined in data, pass sections, value and onNavigate directly to Sidebar. ```tsx Workspace Mail } tooltip="Inbox"> Inbox } tooltip="Settings"> Settings ``` ## Runnable examples ### Workspace sidebar ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, Skeleton, DropdownMenu, HStack, Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, Text, useSidebar, useIsMobile } from 'wss3-forge' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } export default function Example() { return () } ``` ### Sections-based navigation ```tsx import { useState } from 'react' import { Archive20Regular, Calendar20Regular, Document20Regular, Folder20Regular, Home20Regular, MailInbox20Regular, People20Regular, Code20Regular, Grid20Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Grid, Select, Skeleton, Sidebar, SidebarInset, Switch, VStack, useForge, useIsMobile } from 'wss3-forge' import type { NavSection } from 'wss3-forge' function WebbaMark({size = 36}: {size?: number}) { return Webba } function WebbaWordmark() { const {isDark} = useForge() return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } const workspaceSections: NavSection[] = [ { title: 'Workspace', items: [ { id: 'Overview', label: 'Overview', icon: }, { id: 'Inbox', label: 'Inbox', icon: , badge: 4 }, { id: 'Projects', label: 'Projects', icon: , defaultOpen: true, children: [ { id: 'Roadmap', label: 'Roadmap', icon: }, { id: 'Releases', label: 'Releases', icon: }, ] }, ] }, { title: 'Library', items: [ { id: 'Documents', label: 'Documents', icon: }, { id: 'Assets', label: 'Assets', icon: }, { id: 'Archive', label: 'Archive', icon: }, ] }, { title: 'Team', items: [ { id: 'Members', label: 'Members', icon: }, { id: 'Settings', label: 'Settings', icon: }, ] }, ] function SectionsSidebarDemo() { const [page, setPage] = useState('Overview') const [density, setDensity] = useState<'compact' | 'comfortable'>('comfortable') const [hoverEffect, setHoverEffect] = useState<'bg' | 'border-left' | 'dot' | 'highlight' | 'none'>('bg') const [showSubmenuLine, setShowSubmenuLine] = useState(true) const isMobile = useIsMobile() const destinations = workspaceSections.flatMap(group => group.items.flatMap(item => item.children ?? [item])) return setHoverEffect(value as typeof hoverEffect)} /> } compactLogo={} collapsible width={isMobile ? 192 : 248} height="36rem" forceDesktop account={{...workspaceAccount, items:workspaceAccountItems(setPage)}} search={{title:'Search workspace', items:destinations, onSelect:setPage}} /> setPage('Overview')}]), {label:page}, ]} /> {page} } export default function Example() { return () } ``` ### Controlled sidebar ```tsx import { useEffect, useState } from 'react' import { Add16Regular, Folder20Regular, Apps20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, Skeleton, HStack, Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, Text, useSidebar, useIsMobile } from 'wss3-forge' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return () } ``` ### Groups, actions and badges ```tsx import { useEffect, useState } from 'react' import { Add16Regular, Folder20Regular, Apps20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, Skeleton, HStack, Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, Text, useSidebar, useIsMobile } from 'wss3-forge' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return () } ``` ### Loading menu ```tsx import { useEffect, useState } from 'react' import { Add16Regular, Folder20Regular, Apps20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, Skeleton, HStack, Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, Text, useSidebar, useIsMobile } from 'wss3-forge' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return () } ``` ### Floating sidebar ```tsx import { useEffect, useState } from 'react' import { Add16Regular, Folder20Regular, Apps20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, Skeleton, HStack, Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, Text, useSidebar, useIsMobile } from 'wss3-forge' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return () } ``` ### Inset sidebar ```tsx import { useEffect, useState } from 'react' import { Add16Regular, Folder20Regular, Apps20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, Skeleton, HStack, Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, Text, useSidebar, useIsMobile } from 'wss3-forge' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return () } ``` ### RTL ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, Skeleton, DropdownMenu, HStack, Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, Text, useSidebar, useIsMobile } from 'wss3-forge' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } export default function Example() { return () } ``` ## Primitive libraries ### Base UI Base UI supplies the mobile dialog and useRender composition for menu controls. ```sh npm install wss3-forge @base-ui/react ``` [Base UI API reference](https://base-ui.com/react/components/dialog) ```tsx import { SidebarProvider, Sidebar, SidebarMenuButton } from 'wss3-forge/base-ui' }>Inbox ``` #### Preview ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, DropdownMenu, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/base-ui' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } export default function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } ``` #### Controlled sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/base-ui' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Groups, actions and badges ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/base-ui' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Loading menu ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/base-ui' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Floating sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/base-ui' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Inset sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/base-ui' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### RTL ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, DropdownMenu, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/base-ui' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } export default function Example() { return } ``` ### Radix Use asChild to forward a row to a router link or native element. The mobile sheet uses Radix Dialog. ```sh npm install wss3-forge radix-ui ``` [Radix API reference](https://www.radix-ui.com/primitives/docs/components/dialog) ```tsx import { SidebarProvider, Sidebar, SidebarMenuButton } from 'wss3-forge/radix' Inbox ``` #### Preview ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, DropdownMenu, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/radix' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } export default function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } ``` #### Controlled sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/radix' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Groups, actions and badges ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/radix' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Loading menu ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/radix' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Floating sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/radix' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Inset sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/radix' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### RTL ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, DropdownMenu, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/radix' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } export default function Example() { return } ``` ### React Aria Use href for a React Aria Link. SidebarTrigger accepts onPress and isDisabled. SidebarGroupAction accepts native button attributes and React Aria press handlers on the same element. Mobile navigation uses its modal dialog. ```sh npm install wss3-forge react-aria-components ``` [React Aria API reference](https://react-aria.adobe.com/Modal) ```tsx import { SidebarProvider, Sidebar, SidebarMenuButton } from 'wss3-forge/react-aria' Inbox ``` #### Preview ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, DropdownMenu, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/react-aria' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } export default function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } ``` #### Controlled sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/react-aria' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Groups, actions and badges ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/react-aria' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Loading menu ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/react-aria' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Floating sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/react-aria' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### Inset sidebar ```tsx import { useState, useEffect } from 'react' import { Add16Regular, Apps20Regular, Folder20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarCollapsibleGroup, SidebarContent, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/react-aria' function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } type FolderDemoMode = 'controlled' | 'groups' | 'loading' | 'floating' | 'inset' function SmallerSidebar({mode}: {mode:FolderDemoMode}) { const [open,setOpen] = useState(true) return } function MailFolders({mode}: {mode:FolderDemoMode}) { const {open, setOpenMobile} = useSidebar() const [ready,setReady] = useState(false) useEffect(() => { if (mode !== 'loading') return const timer = window.setTimeout(() => setReady(true), 3000) return () => window.clearTimeout(timer) }, [mode]) const [items,setItems] = useState(['Inbox','Archive']) const [active,setActive] = useState('Inbox') function selectFolder(id: string) { setActive(id) setOpenMobile(false) } const folderMenu = {mode === 'loading' && !ready ? : items.map((item,index) => selectFolder(item)}> {item} {index === 0 && 12} )} return <> ({id, label:id, icon:})), onSelect:selectFolder}}> {mode === 'groups' ? } action={ setItems(current => [...current, 'Folder ' + (current.length - 1)])}> }>{folderMenu} : Folders {folderMenu} } {mode === 'controlled' && {open ? 'Expanded' : 'Collapsed'}} } export default function Example() { return } ``` #### RTL ```tsx import { useId, useState } from 'react' import { BookOpen20Regular, Bot20Regular, ChevronDown16Regular, ChevronRight16Regular, Code20Regular, Map20Regular, DataPie20Regular, Grid20Regular, MoreHorizontal16Regular, Settings20Regular } from '@fluentui/react-icons' import { Box, Breadcrumbs, Divider, Grid, HStack, Skeleton, DropdownMenu, Text, useIsMobile } from 'wss3-forge' import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar } from 'wss3-forge/react-aria' const arabicLabels: Record = { 'Build Your Application':'إنشاء تطبيقك', 'Data Fetching':'جلب البيانات', 'Webba':'ويبّا', Enterprise:'المؤسسة', Playground:'ملعب', History:'السجل', Starred:'المميز', Settings:'الإعدادات', Models:'النماذج', Genesis:'جينيسيس', Explorer:'إكسبلورر', Quantum:'كوانتوم', Documentation:'التوثيق', Introduction:'مقدمة', 'Get Started':'ابدأ', Tutorials:'الدروس', Changelog:'سجل التغييرات', General:'عام', Team:'الفريق', Billing:'الفوترة', Limits:'الحدود', 'Design Engineering':'هندسة التصميم', 'Sales & Marketing':'المبيعات والتسويق', Travel:'السفر', Account:'الحساب', Notifications:'الإشعارات', 'Account menu':'قائمة الحساب', 'Upgrade to Pro':'الترقية إلى خطة المحترفين', 'Log out':'تسجيل الخروج', 'View project':'عرض المشروع','Archive project':'أرشفة المشروع',Teams:'الفرق', } const teams = [{name:'Webba',plan:'Enterprise'},{name:'Atlas Design',plan:'Startup'},{name:'Field Notes',plan:'Free'}] const navigation = [ {title:'Playground',icon:,children:['History','Starred','Settings']}, {title:'Models',icon:,children:['Genesis','Explorer','Quantum']}, {title:'Documentation',icon:,children:['Introduction','Get Started','Tutorials','Changelog']}, {title:'Settings',icon:,children:['General','Team','Billing','Limits']}, ] const projects = [{name:'Design Engineering',icon:},{name:'Sales & Marketing',icon:},{name:'Travel',icon:}] function WebbaMark({size = 36}: {size?: number}) { return Webba } function WorkspaceSkeletons() { const isMobile = useIsMobile() return {[1, 2, 3].map(slot => )} } const workspaceAccount = {name:'Maya Chen', email:'maya@example.org'} function workspaceAccountItems(onSelect: (page: string) => void, translate = (label: string) => label) { return ['Upgrade to Pro','Account','Billing','Notifications','Log out'].map(label => ({ id: label, label: translate(label), onClick: () => onSelect(label), })) } function Workspace({rtl = false, showLine = true}: {rtl?: boolean; showLine?: boolean}) { const base = useId() const t = (value:string) => rtl ? arabicLabels[value] ?? value : value const [teamList,setTeamList] = useState(teams) const [team,setTeam] = useState(teams[0].name) const [expanded,setExpanded] = useState(['Playground']) const [projectList,setProjectList] = useState(projects) const [view,setView] = useState('Data Fetching') const [account,setAccount] = useState('') const { setOpen, setOpenMobile, state, isMobile } = useSidebar() const compact = state === 'collapsed' && !isMobile const select = (title: string) => {setView(title); setOpenMobile(false)} const searchItems = [ ...navigation.flatMap(group => group.children.map(id => ({id, label:t(id), icon:group.icon}))), ...projectList.map(project => ({id:project.name, label:t(project.name), icon:project.icon})), ] function addTeam() { const name = 'Team ' + (teamList.length + 1) setTeamList([...teamList, {name, plan:'Free'}]) setTeam(name) } function selectSearchResult(id: string) { const group = navigation.find(item => item.children.includes(id)) if (group && !expanded.includes(group.title)) setExpanded([...expanded, group.title]) select(id) } return <> entry.name === 'Webba' ? {...entry, logo:} : entry), value:team, onChange:setTeam, onAdd:addTeam, }} headerContent={rtl ? مساحة العمل : undefined} search={{title:rtl ? 'البحث في مساحة العمل' : 'Search workspace', inputLabel:rtl ? 'البحث عن صفحة' : 'Find a page', items:searchItems, onSelect:selectSearchResult}} account={{...workspaceAccount, label:t('Account menu'), items:workspaceAccountItems(label => { setAccount(label) select(label) }, t)}}> {rtl?'المنصة':'Platform'} {navigation.map((group,i) => { const open = expanded.includes(group.title) const id = base + '-group-' + i return { if (state === 'collapsed' && !isMobile) {setOpen(true); if (!open) setExpanded([...expanded,group.title])} else setExpanded(open?expanded.filter(item=>item!==group.title):[...expanded,group.title]) }}> {group.icon}{t(group.title)}{open?:} {open && {group.children.map(label => {event.preventDefault();select(label)}}>{t(label)} )}} })} {rtl?'المشاريع':'Projects'} {projectList.map(project => select(project.name)}>{project.icon}{t(project.name)} } items={[{id:'open',label:t('View project'),onClick:()=>select(project.name)},{id:'share',label:rtl?'مشاركة المشروع':'Share project',onClick:()=>select('Share '+project.name)},{id:'archive',label:t('Archive project'),onClick:()=>setProjectList(list=>list.filter(item=>item.name!==project.name))}]} /> )}select(rtl?'المشاريع':'Projects')}>{rtl?'المزيد':'More'} select('Data Fetching')}]), {label:t(view)}, ]} /> {view === account ? t('Account') + ' · ' : ''}{t(view)} } function SidebarDemo({rtl = false, showLine = true}: {rtl?:boolean; showLine?:boolean}) { return } export default function Example() { return } ``` ## Root package API ### Sidebar Supply sections for configured navigation, or compose sidebar parts inside SidebarProvider. Props type: `SidebarProps | SidebarSectionsProps` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes **Composition exports** - `SidebarProvider` (named export) - `SidebarHeader` (named export) - `SidebarContent` (named export) - `SidebarFooter` (named export) - `SidebarGroup` (named export) - `SidebarGroupLabel` (named export) - `SidebarMenu` (named export) - `SidebarMenuItem` (named export) - `SidebarMenuButton` (named export) - `SidebarInset` (named export) - `SidebarTrigger` (named export) - `SidebarMenuSub` (named export) - `SidebarMenuSubItem` (named export) - `SidebarMenuSubButton` (named export) - `SidebarMenuAction` (named export) - `SidebarMenuSkeleton` (named export) - `SidebarMenuBadge` (named export) - `SidebarCollapsibleGroup` (named export) - `SidebarGroupAction` (named export) - `SidebarGroupContent` (named export) - `headerContent?` — `ReactNode` - `footerContent?` — `ReactNode` Add content to the header or footer beside built-in sidebar features. - `account?` — `SidebarAccountMenuProps` Pinned account dropdown shared with composed sidebars. - `search?` — `SidebarSearchConfig` - `teamSwitcher?` — `SidebarTeamSwitcherConfig` - `side?` — `'left' | 'right'` Default `'left'`. Options `"left"`, `"right"`. - `variant?` — `'sidebar' | 'floating' | 'inset'` Default `'sidebar'`. Options `"floating"`, `"inset"`, `"sidebar"`. Select a physical edge, panel surface and collapsed presentation. - `collapsible?` — `'offcanvas' | 'icon' | 'none' | boolean` Options `"none"`, `"icon"`, `"offcanvas"`. Composed sidebars default to offcanvas. With sections, the boolean collapse toggle defaults to false. - `mode?` — `'inline' | 'drawer'` Default `'inline'`. Options `"inline"`, `"drawer"`. Inline navigation, or a modal drawer. - `open?` — `boolean` Default `true`. Visibility in drawer mode. - `onClose?` — `() => void` - `position?` — `'left' | 'right'` Default `'left'`. Options `"left"`, `"right"`. Screen edge for drawer mode. - `logo?` — `ReactNode` - `compactLogo?` — `ReactNode` Logo rendered in place of `logo` when the sidebar is in collapsed (icon-rail) mode. Typically a square mark (32x32 to 40x40) sized to fit the 64px collapsed rail. If omitted, no logo is shown when collapsed. - `sections?` — `NavSection[]` Navigation sections and their nested items. Supply an empty array for an empty navigation. - `value?` — `string` Build navigation from grouped items. Update value when onNavigate receives the selected item ID. - `onNavigate?` — `(id: string) => void` Build navigation from grouped items. Update value when onNavigate receives the selected item ID. - `showHeader?` — `boolean` Default `true`. Show the logo and search header. - `compactHeaderContent?` — `ReactNode` Header action shown instead of headerContent in the collapsed icon rail. - `headerContentGap?` — `string` Default `none`. Space after headerContent before search or navigation. - `showSearch?` — `boolean` Default `true`. Show the header search trigger. - `searchPlaceholder?` — `string` Default `'Search...'`. - `searchShortcut?` — `string` Default `'Ctrl+K'`. - `onSearchClick?` — `() => void` - `bottomItems?` — `NavItem[]` - `background?` — `'solid' | 'transparent'` Default `'solid'`. Options `"solid"`, `"transparent"`. Surface for the inline sidebar. Drawer mode keeps its own opaque surface. - `width?` — `number` Default `240`. Expanded sidebar width in pixels. - `drawerWidth?` — `number | string` Custom width when in drawer mode on mobile. Overrides the default `calc(100vw - 48px)`. Accepts a number (px) or any CSS length string. Use this when 100vw - 48px is too wide for your design (e.g. a compact dashboard sidebar that should not eat the full screen). - `height?` — `string` Default `'100dvh'`. - `accentColor?` — `string` - `rounded?` — `boolean` Default `true`. Round the drawer's outer edge. - `forceDesktop?` — `boolean` Default `false`. Keep the desktop layout at narrow widths. - `density?` — `SidebarDensity` Default `'comfortable'`. Options `"compact"`, `"comfortable"`. Compact density reduces item padding and spacing. - `hoverEffect?` — `SidebarHoverEffect` Default `'bg'`. Options `"none"`, `"dot"`, `"bg"`, `"highlight"`, `"border-left"`. Hover and active indicator style for navigation items. - `showCollapseControl?` — `boolean` Default `true`. Show the built-in collapse control. Set false when an adjacent control updates `collapsed`. - `collapsed?` — `boolean` - `onCollapsedChange?` — `(collapsed: boolean) => void` - `resizable?` — `boolean` Default `false`. Allow drag-resizing the sidebar. - `minWidth?` — `number` Default `60`. Minimum resizable width in pixels. - `maxWidth?` — `number` Default `480`. Maximum resizable width in pixels. - `onWidthChange?` — `(width: number) => void` - `showSubmenuLine?` — `boolean` Default `true`. Show the vertical guide beside nested rows. Indentation is preserved when hidden. - `navigationEdgeToEdge?` — `boolean` Default `false`. Place the navigation scrollbar against the sidebar edge while keeping its links inset. - `ref?` — `React.LegacyRef | undefined` #### SidebarProps Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `headerContent?` — `ReactNode` - `footerContent?` — `ReactNode` Add content to the header or footer beside built-in sidebar features. - `account?` — `SidebarAccountMenuProps` - `search?` — `SidebarSearchConfig` - `teamSwitcher?` — `SidebarTeamSwitcherConfig` - `side?` — `'left' | 'right'` Default `'left'`. Options `"left"`, `"right"`. - `variant?` — `'sidebar' | 'floating' | 'inset'` Default `'sidebar'`. Options `"floating"`, `"inset"`, `"sidebar"`. Select a physical edge, panel surface and collapsed presentation. - `collapsible?` — `'offcanvas' | 'icon' | 'none'` Options `"none"`, `"icon"`, `"offcanvas"`. Composed sidebars default to offcanvas. With sections, the boolean collapse toggle defaults to false. #### SidebarSectionsProps - `mode?` — `'inline' | 'drawer'` Default `'inline'`. Options `"inline"`, `"drawer"`. Inline navigation, or a modal drawer. - `open?` — `boolean` Default `true`. Visibility in drawer mode. - `onClose?` — `() => void` - `position?` — `'left' | 'right'` Default `'left'`. Options `"left"`, `"right"`. Screen edge for drawer mode. - `logo?` — `ReactNode` - `compactLogo?` — `ReactNode` Logo rendered in place of `logo` when the sidebar is in collapsed (icon-rail) mode. Typically a square mark (32x32 to 40x40) sized to fit the 64px collapsed rail. If omitted, no logo is shown when collapsed. - `sections` — `NavSection[]` Navigation sections and their nested items. Supply an empty array for an empty navigation. - `value?` — `string` Build navigation from grouped items. Update value when onNavigate receives the selected item ID. - `onNavigate?` — `(id: string) => void` Build navigation from grouped items. Update value when onNavigate receives the selected item ID. - `showHeader?` — `boolean` Default `true`. Show the logo and search header. - `headerContent?` — `ReactNode` - `compactHeaderContent?` — `ReactNode` Header action shown instead of headerContent in the collapsed icon rail. - `headerContentGap?` — `string` Default `none`. Space after headerContent before search or navigation. - `showSearch?` — `boolean` Default `true`. Show the header search trigger. - `searchPlaceholder?` — `string` Default `'Search...'`. - `searchShortcut?` — `string` Default `'Ctrl+K'`. - `onSearchClick?` — `() => void` - `footerContent?` — `ReactNode` Add content to the header or footer beside built-in sidebar features. - `bottomItems?` — `NavItem[]` - `background?` — `'solid' | 'transparent'` Default `'solid'`. Options `"solid"`, `"transparent"`. Surface for the inline sidebar. Drawer mode keeps its own opaque surface. - `width?` — `number` Default `240`. Expanded sidebar width in pixels. - `drawerWidth?` — `number | string` Custom width when in drawer mode on mobile. Overrides the default `calc(100vw - 48px)`. Accepts a number (px) or any CSS length string. Use this when 100vw - 48px is too wide for your design (e.g. a compact dashboard sidebar that should not eat the full screen). - `height?` — `string` Default `'100dvh'`. - `accentColor?` — `string` - `rounded?` — `boolean` Default `true`. Round the drawer's outer edge. - `forceDesktop?` — `boolean` Default `false`. Keep the desktop layout at narrow widths. - `density?` — `SidebarDensity` Default `'comfortable'`. Options `"compact"`, `"comfortable"`. Compact density reduces item padding and spacing. - `hoverEffect?` — `SidebarHoverEffect` Default `'bg'`. Options `"none"`, `"dot"`, `"bg"`, `"highlight"`, `"border-left"`. Hover and active indicator style for navigation items. - `collapsible?` — `boolean` In section-based navigation, true shows the collapse toggle and false is the default. - `showCollapseControl?` — `boolean` Default `true`. Show the built-in collapse control. Set false when an adjacent control updates `collapsed`. - `collapsed?` — `boolean` - `onCollapsedChange?` — `(collapsed: boolean) => void` - `resizable?` — `boolean` Default `false`. Allow drag-resizing the sidebar. - `minWidth?` — `number` Default `60`. Minimum resizable width in pixels. - `maxWidth?` — `number` Default `480`. Maximum resizable width in pixels. - `onWidthChange?` — `(width: number) => void` - `account?` — `SidebarAccountMenuProps` Pinned account dropdown shared with composed sidebars. - `search?` — `SidebarSearchConfig` - `teamSwitcher?` — `SidebarTeamSwitcherConfig` - `showSubmenuLine?` — `boolean` Default `true`. Show the vertical guide beside nested rows. Indentation is preserved when hidden. - `navigationEdgeToEdge?` — `boolean` Default `false`. Place the navigation scrollbar against the sidebar edge while keeping its links inset. ### SidebarProvider Props type: `SidebarProviderProps` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `open?` — `boolean` - `defaultOpen?` — `boolean` Default `true`. - `onOpenChange?` — `(open: boolean) => void` - `style?` — `SidebarStyle` Persist desktop changes in the sidebar_state cookie for seven days. - `persist?` — `boolean` Default `true`. - `ref?` — `React.LegacyRef | undefined` ### SidebarHeader Props type: `ComponentPropsWithoutRef<'div'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarContent Props type: `ComponentPropsWithoutRef<'div'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarFooter Props type: `ComponentPropsWithoutRef<'div'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarGroup Props type: `ComponentPropsWithoutRef<'div'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarGroupLabel Props type: `ComponentPropsWithoutRef<'div'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarMenu Props type: `ComponentPropsWithoutRef<'ul'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarMenuItem Props type: `ComponentPropsWithoutRef<'li'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes, LiHTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarMenuButton Props type: `SidebarMenuButtonProps` Native attributes: AriaAttributes, Attributes, ButtonHTMLAttributes, DOMAttributes, HTMLAttributes - `ref?` — `((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject | null | undefined` - `render?` — `Renderer` - `isActive?` — `boolean` Default `false`. - `size?` — `'sm' | 'default' | 'lg' | null` Default `'default'`. Options `null`, `"default"`, `"sm"`, `"lg"`. - `variant?` — `'default' | 'outline' | null` Default `'default'`. Options `null`, `"default"`, `"outline"`. - `tooltip?` — `ReactNode | { children: ReactNode; }` ### SidebarInset Props type: `ComponentPropsWithoutRef<'main'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarTrigger Props type: `Omit & {children?: ReactNode}` Native attributes: AriaAttributes, ButtonHTMLAttributes, DOMAttributes, HTMLAttributes - `variant?` — `ButtonVariant | null` Default `'primary'`. Options `null`, `"default"`, `"primary"`, `"secondary"`, `"danger"`, `"destructive"`, `"ghost"`, `"outline"`, `"link"`. - `icon?` — `ReactNode` - `loading?` — `boolean` Default `false`. - `size?` — `ButtonSize | null` Default `'md'`. Options `null`, `"default"`, `"icon"`, `"sm"`, `"md"`, `"lg"`, `"xs"`, `"xl"`, `"icon-xs"`, `"icon-sm"`, `"icon-lg"`, `"icon-xl"`. - `tone?` — `ButtonTone` Options `"default"`, `"danger"`. Semantic tone. When omitted, danger and destructive use the danger tone. - `loadingPosition?` — `'start' | 'end'` Default `'start'`. Options `"start"`, `"end"`. Side of the label where the spinner replaces the icon while loading. - `rightIcon?` — `ReactNode` - `fullWidth?` — `boolean` - `compact?` — `boolean` - `gradient?` — `boolean` Default `false`. - `children?` — `ReactNode` - `ref?` — `React.LegacyRef | undefined` ### SidebarMenuSub Props type: `SidebarMenuSubProps` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `showLine?` — `boolean` Default `true`. Display the indentation line beside the submenu. - `ref?` — `React.LegacyRef | undefined` ### SidebarMenuSubItem Props type: `ComponentPropsWithoutRef<'li'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes, LiHTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarMenuSubButton Props type: `SidebarMenuSubButtonProps` Native attributes: AnchorHTMLAttributes, AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `((instance: HTMLAnchorElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject | null | undefined` - `render?` — `Renderer` - `isActive?` — `boolean` Default `false`. - `size?` — `'sm' | 'md'` Default `'md'`. Options `"sm"`, `"md"`. ### SidebarMenuAction Props type: `SidebarMenuActionProps` Native attributes: AriaAttributes, Attributes, ButtonHTMLAttributes, DOMAttributes, HTMLAttributes - `showOnHover?` — `boolean` Default `false`. - `ref?` — `React.LegacyRef | undefined` ### SidebarMenuSkeleton Props type: `ComponentPropsWithoutRef<'div'> & {showIcon?: boolean}` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `showIcon?` — `boolean` - `ref?` — `React.LegacyRef | undefined` ### SidebarMenuBadge Props type: `ComponentPropsWithoutRef<'span'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarCollapsibleGroup Props type: `SidebarCollapsibleGroupProps & React.RefAttributes` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes, RefAttributes - `label` — `string` - `icon?` — `ReactNode` - `action?` — `ReactNode` A separate trailing control, typically SidebarGroupAction. - `open?` — `boolean` - `defaultOpen?` — `boolean` Default `true`. - `onOpenChange?` — `(open: boolean) => void` - `showLine?` — `boolean` Default `true`. Keep the menu indentation and optionally hide its guide. - `ref?` — `React.LegacyRef | undefined` Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). ### SidebarGroupAction Props type: `ComponentPropsWithoutRef<'button'>` Native attributes: AriaAttributes, Attributes, ButtonHTMLAttributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ### SidebarGroupContent Props type: `ComponentPropsWithoutRef<'div'>` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes - `ref?` — `React.LegacyRef | undefined` ## Related types ```ts export interface SidebarAccountMenuProps { name: string email?: string avatarSrc?: string items: DropdownItem[] /** Accessible name of the account button. */ label?: string /** Overrides the enclosing sidebar's icon-rail presentation. */ compact?: boolean } export interface DropdownItem { id: string label: string /** A boolean makes the item a checked menu choice. Update it in onClick. */ checked?: boolean /** Navigational entries render native links, including modifier-click and context menu support. */ href?: string icon?: ReactNode shortcut?: string // Raccourci clavier (ex: "Ctrl+K") onClick?: () => void disabled?: boolean destructive?: boolean divider?: boolean } export interface SidebarSearchConfig { items: { id: string; label: string; icon?: ReactNode }[] onSelect: (id: string) => void title?: string inputLabel?: string } export interface SidebarTeamSwitcherConfig { teams: { name: string; plan?: string; logo?: ReactNode }[] value: string onChange: (name: string) => void onAdd?: () => void label?: string } export interface NavSection { title?: string items: NavItem[] } export interface NavItem { id: string icon: ReactNode label: string badge?: number | string badgeColor?: string /** Destination for a leaf item. Regular clicks use onClick or onNavigate if supplied. */ href?: string onClick?: () => void // Collapsible children children?: NavItem[] defaultOpen?: boolean /** Overrides the sidebar's showSubmenuLine setting for this item's immediate child list. */ showSubmenuLine?: boolean } export type SidebarDensity = 'comfortable' | 'compact' export type SidebarHoverEffect = 'bg' | 'border-left' | 'dot' | 'highlight' | 'none' export interface SidebarProps extends ComponentPropsWithoutRef<'div'> { headerContent?: ReactNode footerContent?: ReactNode account?: SidebarAccountMenuProps search?: SidebarSearchConfig teamSwitcher?: SidebarTeamSwitcherConfig /** @default 'left' */ side?: 'left' | 'right' /** @default 'sidebar' */ variant?: 'sidebar' | 'floating' | 'inset' /** Composed sidebars default to offcanvas. With sections, the boolean collapse toggle defaults to false. */ collapsible?: 'offcanvas' | 'icon' | 'none' } export type SidebarSectionsProps = DrawerProps & { /** Pinned account dropdown shared with composed sidebars. */ account?: SidebarAccountMenuProps search?: SidebarSearchConfig teamSwitcher?: SidebarTeamSwitcherConfig /** Show the vertical guide beside nested rows. Indentation is preserved when hidden. @default true */ showSubmenuLine?: boolean /** Place the navigation scrollbar against the sidebar edge while keeping its links inset. @default false */ navigationEdgeToEdge?: boolean } export type DrawerProps = DrawerBaseProps & Partial export interface DrawerBaseProps { /** Inline navigation, or a modal drawer. @default 'inline' */ mode?: 'inline' | 'drawer' /** Visibility in drawer mode. @default true */ open?: boolean onClose?: () => void // Only used in drawer mode /** Screen edge for drawer mode. @default 'left' */ position?: 'left' | 'right' // Content logo?: ReactNode /** Logo rendered in place of `logo` when the sidebar is in collapsed * (icon-rail) mode. Typically a square mark (32x32 to 40x40) sized to fit * the 64px collapsed rail. If omitted, no logo is shown when collapsed. */ compactLogo?: ReactNode /** Navigation sections and their nested items. Supply an empty array for an empty navigation. */ sections: NavSection[] value?: string onNavigate?: (id: string) => void // Header /** Show the logo and search header. @default true */ showHeader?: boolean headerContent?: ReactNode // Custom content rendered between logo and search /** Header action shown instead of headerContent in the collapsed icon rail. */ compactHeaderContent?: ReactNode /** Space after headerContent before search or navigation. @default none */ headerContentGap?: string /** Show the header search trigger. @default true */ showSearch?: boolean /** @default 'Search...' */ searchPlaceholder?: string /** @default 'Ctrl+K' */ searchShortcut?: string onSearchClick?: () => void // Footer footerContent?: ReactNode bottomItems?: NavItem[] // Styling /** Surface for the inline sidebar. Drawer mode keeps its own opaque surface. @default 'solid' */ background?: 'solid' | 'transparent' /** Expanded sidebar width in pixels. @default 240 */ width?: number /** Custom width when in drawer mode on mobile. Overrides the default * `calc(100vw - 48px)`. Accepts a number (px) or any CSS length string. * Use this when 100vw - 48px is too wide for your design (e.g. a * compact dashboard sidebar that should not eat the full screen). */ drawerWidth?: number | string /** @default '100dvh' */ height?: string accentColor?: string /** Round the drawer's outer edge. @default true */ rounded?: boolean /** Keep the desktop layout at narrow widths. @default false */ forceDesktop?: boolean /** Compact density reduces item padding and spacing. @default 'comfortable' */ density?: SidebarDensity /** Hover and active indicator style for navigation items. @default 'bg' */ hoverEffect?: SidebarHoverEffect } export interface DrawerCollapsibleProps extends DrawerBaseProps { /** In section-based navigation, true shows the collapse toggle and false is the default. */ collapsible?: boolean /** Show the built-in collapse control. Set false when an adjacent control updates `collapsed`. @default true */ showCollapseControl?: boolean collapsed?: boolean // Controlled collapsed state (icon-only mode) onCollapsedChange?: (collapsed: boolean) => void // Callback when collapsed state changes } export interface DrawerResizableProps extends DrawerBaseProps { /** Allow drag-resizing the sidebar. @default false */ resizable?: boolean /** Minimum resizable width in pixels. @default 60 */ minWidth?: number /** Maximum resizable width in pixels. @default 480 */ maxWidth?: number onWidthChange?: (width: number) => void // Callback when width changes via resize } export type SidebarStyle = CSSProperties & {'--sidebar-width'?: string; '--sidebar-width-icon'?: string; '--sidebar-width-mobile'?: string} export interface SidebarProviderProps extends ComponentPropsWithoutRef<'div'> { open?: boolean defaultOpen?: boolean onOpenChange?: (open: boolean) => void /** Persist desktop changes in the sidebar_state cookie for seven days. */ style?: SidebarStyle persist?: boolean } type Renderer = ReactElement | ((attributes: Attributes, state: State) => ReactElement | null) type Attributes = Record export type SidebarMenuButtonProps = ForgePartProps<'button'> & { isActive?: boolean; size?: 'sm' | 'default' | 'lg' | null; variant?: 'default' | 'outline' | null; tooltip?: ReactNode | {children: ReactNode} } export type ForgePartProps> = ComponentPropsWithRef & { render?: Renderer } type Tag = keyof React.JSX.IntrinsicElements export type ButtonVariant = 'default' | 'destructive' | 'primary' | 'secondary' | 'ghost' | 'danger' | 'outline' | 'link' export type ButtonSize = ControlSize | 'default' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg' | 'icon-xl' export type ControlSize = keyof typeof SIZES export type ButtonTone = 'default' | 'danger' export interface ButtonProps extends ButtonAppearanceProps, Omit, 'children'> {} export interface SidebarMenuSubProps extends ComponentPropsWithoutRef<'ul'> { /** Display the indentation line beside the submenu. @default true */ showLine?: boolean } export type SidebarMenuSubButtonProps = ForgePartProps<'a'> & {isActive?: boolean; size?: 'sm' | 'md'} export interface SidebarMenuActionProps extends ComponentPropsWithoutRef<'button'> { showOnHover?: boolean } ``` ## Optional primitive contracts - [wss3-forge/base-ui · Sidebar contract](/ai/skill/primitive-api/Sidebar.json) - [wss3-forge/radix · Sidebar contract](/ai/skill/primitive-api/Sidebar.json) - [wss3-forge/react-aria · Sidebar contract](/ai/skill/primitive-api/Sidebar.json)