JumboLayout

JumboLayout is the core layout shell in the @jumbo framework. It composes a fixed header, collapsible sidebar, optional right sidebar, scrollable content area, and footer into a single configurable component. JumboLayoutProvider wraps it to supply context and the layout reducer.

Setup

Every layout group that uses the full chrome must wrap JumboLayout in JumboLayoutProvider:

tsx
// src/app/[lang]/(common)/layout.tsx
import { JumboLayout } from '@jumbo/components/JumboLayout';
import { JumboLayoutProvider } from '@jumbo/components/JumboLayout';
import { defaultLayoutConfig } from '@/config/layouts/default';
import { Header } from '@/components/Header/Header';
import { Footer } from '@/components/Footer/Footer';
import { SidebarWithMenus } from '@/components/SidebarWithMenus/SidebarWithMenus';
 
export default function CommonLayout({ children }: { children: React.ReactNode }) {
  return (
    <JumboLayoutProvider defaultLayoutConfig={defaultLayoutConfig}>
      <JumboLayout
        header={<Header />}
        sidebar={<SidebarWithMenus />}
        footer={<Footer />}
      >
        {children}
      </JumboLayout>
    </JumboLayoutProvider>
  );
}

Props

JumboLayoutProvider

PropTypeDefaultDescription
defaultLayoutConfigLayoutOptionsrequiredInitial layout options passed to the reducer
childrenReactNoderequiredMust include JumboLayout

JumboLayout

PropTypeDefaultDescription
headerReactNodeHeader slot (rendered above content)
sidebarReactNodeLeft sidebar slot
rightSidebarReactNodeRight sidebar slot
footerReactNodeFooter slot (rendered below content)
childrenReactNoderequiredPage content

Layout options

The LayoutOptions type (from @jumbo/types) controls every aspect of the layout:

typescript
// @jumbo/types/JumboLayoutTypes.ts
interface LayoutOptions {
  sidebar: LayoutSidebarOptions;
  header:  LayoutHeaderOptions;
  footer:  LayoutFooterOptions;
  content: LayoutContentOptions;
  root:    LayoutRootOptions;
  wrapper: object;
  main:    object;
}
OptionTypeDefaultDescription
openbooleantrueWhether the sidebar is open
hidebooleanfalseCompletely remove the sidebar slot
variantSIDEBAR_VARIANTSPERSISTENTPERSISTENT, TEMPORARY, PERMANENT
styleSIDEBAR_STYLESFULL_HEIGHTFULL_HEIGHT or CLIPPED_UNDER_HEADER
viewSIDEBAR_VIEWSFULLFULL or MINI (icon-only collapsed state)
scrollTypeSIDEBAR_SCROLL_TYPESFIXEDFIXED or DEFAULT
anchorSIDEBAR_ANCHOR_POSITIONSLEFTLEFT, RIGHT, TOP, BOTTOM
widthnumber240Sidebar width in pixels
minWidthnumber80Mini mode width in pixels
drawerbooleantrueUse a Drawer below drawerBreakpoint
drawerBreakpointBreakpoint'xl'Breakpoint below which the drawer activates

Header options

OptionTypeDefaultDescription
hidebooleanfalseCompletely remove the header slot
fixedbooleantrueStick header to top on scroll
sxSxProps{ height: 80 }MUI sx overrides (use to set height)
drawerBreakpointBreakpoint'xl'Breakpoint for the hamburger menu trigger

Layout actions

The reducer accepts actions dispatched through the context hooks. Use these to update layout options from any client component:

typescript
// @jumbo/utilities/constants.ts
export enum LAYOUT_ACTIONS {
  SET_OPTIONS          = 'set-options',
  SET_SIDEBAR_OPTIONS  = 'set-sidebar-options',
  SET_HEADER_OPTIONS   = 'set-header-options',
  SET_FOOTER_OPTIONS   = 'set-footer-options',
  SET_CONTENT_OPTIONS  = 'set-content-options',
  SET_ROOT_OPTIONS     = 'set-root-options',
}

Context hooks

HookProvides
useJumboLayoutSidebarOptions(){ sidebarOptions, setSidebarOptions }
useJumboLayoutHeaderOptions(){ headerOptions, setHeaderOptions }
useJumboLayoutFooterOptions(){ footerOptions, setFooterOptions }
useJumboLayoutOptions(){ layoutOptions, setLayoutOptions } (full options object)

Example — toggling the sidebar from a button:

tsx
'use client';
 
import { useJumboLayoutSidebarOptions } from '@jumbo/components/JumboLayout';
 
export function SidebarToggle() {
  const { sidebarOptions, setSidebarOptions } = useJumboLayoutSidebarOptions();
 
  return (
    <button onClick={() => setSidebarOptions({ open: !sidebarOptions.open })}>
      {sidebarOptions.open ? 'Close Sidebar' : 'Open Sidebar'}
    </button>
  );
}

Default layout config

The baseline config is exported from src/config/layouts/default.ts and used by the (common) layout group. Each demo layout has its own config file under src/components/Demo*Layout/config/index.ts. See the Layouts guide for a full comparison table.