A sectioned workspace sidebar: a workspace select and a new page button on top, main links, titled groups of pages, and settings pinned to the bottom. A button in the page header slides it away and the page follows its edge.
Dependencies
Interaction Type
An aside with a labelled nav and plain link lists; the current page has aria-current and an accent icon. Toggles are buttons with aria-expanded and aria-controls. Below the medium breakpoint the sidebar becomes a sheet opened from a menu button: focus moves in and is trapped, Escape or the backdrop closes it, and focus returns to the menu button. Only transform and clip-path animate, and reduced motion turns it off.
Props
Options you can pass to customize this component.
workspacesOptions in the native workspace select.
workspaceControlled workspace value.
defaultWorkspaceInitial workspace when uncontrolled.
onWorkspaceChangeCalled when a workspace is picked.
primaryLinks at the top of the sidebar.
groupsTitled lists under the main links, such as recent and favorite pages.
secondaryLinks pinned to the bottom edge.
valueControlled id of the current item. It gets aria-current="page".
defaultValueInitial current item when uncontrolled.
onValueChangeCalled with the item id when a link is pressed.
openControlled state: whether the sidebar is shown from the medium breakpoint.
defaultOpenInitial state when uncontrolled. Defaults to true.
onOpenChangeCalled when the toggle is pressed.
onNewPageCalled when the new page button is pressed.
workspaceLabel, newPageLabel, showLabel, hideLabelHidden label of the select and accessible names of the buttons.
titleHeading of the page area. Defaults to the label of the current item.
childrenContent of the page area. Defaults to a placeholder layout.
sidebarLabel, navLabel, menuLabel, closeLabelAccessible names of the sidebar, its navigation and the mobile menu buttons, all overridable for localization.
Installation
How to use
<SidebarWorkspace
workspace={workspace}
onWorkspaceChange={setWorkspace}
value={pageId}
onValueChange={setPageId}
onNewPage={createPage}
>
<Editor />
</SidebarWorkspace>Source Code
Click the code icon in the top-right corner to view the source code.
License & Usage
// No code loaded.