Tuimorphic

SidebarLayout

Two-column layout with resizable and collapsible sidebar.

Import

import { SidebarLayout } from 'tuimorphic';

Basic Usage

Main Content

This is the main content area of the sidebar layout.

<SidebarLayout sidebar={<nav>Navigation</nav>}>
  <main>Main content</main>
</SidebarLayout>

Props

PropTypeDefaultDescription
sidebar*React.ReactNodeContent to render in the sidebar panel
children*React.ReactNodeMain content area
defaultSidebarWidthnumber200Default sidebar width in pixels
minSidebarWidthnumber100Minimum sidebar width in pixels
maxSidebarWidthnumber500Maximum sidebar width in pixels
showHandlebooleanfalseWhether to show the resize handle
collapsiblebooleanfalseWhether the sidebar can be collapsed
defaultCollapsedbooleanfalseWhether the sidebar starts collapsed
side'left' | 'right''left'Which side the sidebar appears on
classNamestringAdditional CSS class names

Variants

Resizable Sidebar

Add a drag handle to allow users to resize the sidebar:

Resizable Sidebar

Drag the handle to resize the sidebar.

<SidebarLayout
  sidebar={<nav>Menu</nav>}
  defaultSidebarWidth={180}
  minSidebarWidth={120}
  maxSidebarWidth={300}
  showHandle
>
  <main>Main content</main>
</SidebarLayout>

Collapsible Sidebar

Allow users to collapse and expand the sidebar:

Collapsible Sidebar

Click the button to collapse/expand.

<SidebarLayout
  sidebar={<nav>Files</nav>}
  collapsible
>
  <main>Main content</main>
</SidebarLayout>

Position the sidebar on the right side:

Right Sidebar

The sidebar can appear on either side.

<SidebarLayout
  sidebar={<aside>Details</aside>}
  side="right"
  collapsible
  defaultSidebarWidth={150}
>
  <main>Main content</main>
</SidebarLayout>

Combine resizing and collapsing capabilities:

Full-Featured Layout

Combines resizable handle and collapsible button.

Drag the handle or click [<] to interact.

<SidebarLayout
  sidebar={<nav>Navigation Menu</nav>}
  defaultSidebarWidth={160}
  minSidebarWidth={120}
  maxSidebarWidth={250}
  showHandle
  collapsible
>
  <main>Application Content</main>
</SidebarLayout>

Accessibility

  • Resize handle has proper ARIA attributes (role="separator", aria-orientation, aria-valuenow)
  • Keyboard support for resizing (Arrow keys)
  • Collapse button has aria-label and aria-expanded attributes
  • Collapsed sidebar has aria-hidden attribute

Styling

SidebarLayout uses CSS custom properties for theming:

VariableDescription
--theme-borderDivider and handle border color
--theme-backgroundSidebar background color
--theme-foregroundText and icon color

On this page