# Layout

### Using Pre-built Layouts

Jumbo comes with several pre-built layouts that you can use out of the box. These layouts are designed to cater to common use cases and provide a quick way to get started with your project. To use a pre-built layout, simply import it into your component and wrap your content with the layout component.

Here's an example of using a pre-built layout:

```jsx
import { CustomizerButton } from '@/components/CustomizerButton';
import { CustomizerButton1 } from '@/components/CustomizerButton1';
import { CustomizerSettings } from '@/components/CustomizerSettings';
import { CustomizerSettings1 } from '@/components/CustomizerSettings1';
import { Footer } from '@/components/Footer';
import { Header } from '@/components/Header';
import { Sidebar } from '@/components/Sidebar';
import { getMenus } from '@/components/Sidebar/menus-items';
import { defaultLayoutConfig } from '@/config/layouts';
import {
  JumboLayout,
  JumboLayoutProvider,
} from '@jumbo/components/JumboLayout';
import { Navigate, Outlet, useLocation } from 'react-router-dom';

export function StretchedLayout() {
  const location = useLocation();
  const menus = getMenus();
  return (
    <JumboLayoutProvider
      layoutConfig={defaultLayoutConfig}
      debugOptions={{ name: 'StrechedLayout' }}
    >
      <JumboLayout
        header={<Header />}
        footer={<Footer />}
        sidebar={<Sidebar menus={menus} />}
      >
        {location.pathname === '/' && <Navigate to={'/dashboards/misc'} />}
        <Outlet />
        <CustomizerSettings />
        <CustomizerButton />
        <CustomizerSettings1 />
        <CustomizerButton1 />
      </JumboLayout>
    </JumboLayoutProvider>
  );
}

```

In this example, `preBuiltLayoutConfig` is an object containing the configuration for a pre-built layout. You can customize this object to fit your needs or choose a different pre-built layout configuration from the provided ones.

### Creating a Custom Layout

If the pre-built layouts do not meet your requirements, you can create a custom layout by providing your own layout configuration. The layout configuration allows you to customize various aspects of the layout, such as the sidebar, header, and footer.

Here’s how you can create a custom layout:

1. **Define the Layout Configuration**<br>

   Create a layout configuration object that specifies how you want your layout to behave. Below is an example of a layout configuration object:<br>

   ```jsx
   import { LayoutOptions } from '@jumbo/types';
   import {
     SIDEBAR_ANCHOR_POSITIONS,
     SIDEBAR_SCROLL_TYPES,
     SIDEBAR_STYLES,
     SIDEBAR_VARIANTS,
     SIDEBAR_VIEWS,
   } from '@jumbo/utilities/constants';

   const defaultLayoutConfig: LayoutOptions = {
     sidebar: {
       open: true,
       hide: false,
       variant: SIDEBAR_VARIANTS.PERSISTENT,
       style: SIDEBAR_STYLES.FULL_HEIGHT,
       view: SIDEBAR_VIEWS.FULL,
       scrollType: SIDEBAR_SCROLL_TYPES.FIXED,
       anchor: SIDEBAR_ANCHOR_POSITIONS.LEFT,
       width: 240,
       minWidth: 80,
       drawer: true,
       drawerBreakpoint: 'xl',
     },
     header: {
       hide: false,
       fixed: true,
       sx: {
         height: 80,
       },
       drawerBreakpoint: 'xl',
     },
     footer: {
       hide: false,
     },
     root: {},
     content: {
       sx: {
         py: 4,
       },
     },
     wrapper: {},
     main: {},
   };

   export const CONTAINER_MAX_WIDTH = 1320;

   export { defaultLayoutConfig };

   ```
2. **Wrap Your Content with Jumbo Layout Components**

   \
   Use the `JumboLayoutProvider` and `JumboLayout` components to apply your custom layout configuration. Here’s an example:<br>

   ```jsx
   import {
     JumboLayout,
     JumboLayoutProvider,
     JumboTheme,
   } from "@jumbo/components";
   import { Outlet } from "react-router-dom";
   import { Header1 } from "./Header1";
   import { Footer1 } from "./Footer1";
   import { config1 } from "./config";
   import { CustomizerSettings } from "@/components/CustomizerSettings";
   import { CustomizerButton } from "@/components/CustomizerButton";
   import { CssBaseline } from "@mui/material";
   import { CONFIG1 } from "./themes";

   export function Demo1Layout() {
     return (
       <JumboTheme init={CONFIG1.THEME}>
         <CssBaseline />
         <JumboLayoutProvider layoutConfig={config1}>
           <JumboLayout header={<Header1 />} footer={<Footer1 />}>
             <Outlet />
             <CustomizerSettings />
             <CustomizerButton />
           </JumboLayout>
         </JumboLayoutProvider>
       </JumboTheme>
     );
   }

   ```

### Using Multipel Demo Layouts <a href="#using-multipel-demo-layouts" id="using-multipel-demo-layouts"></a>

Jumbo supports defining multiple custom layouts for different use cases such as demos, themes, or application variants. If your project includes multiple demo layouts (e.g., `Demo1Layout`, `Demo2Layout`, etc.), you can organize them in a modular way using the same base structure, while providing distinct configurations and UI components for each.

* **Each demo layout typically includes:**
  * A custom layout configuration (e.g., `demoConfig1`, `demoConfig2`, etc).
  * Custom header and footer components (e.g., `Header1`, `Footer1`, etc).
  * Optionally, dynamic content such as menus based on language or user

{% hint style="info" %}
Each layout can reuse the same logic but import its own `Header`, `Footer`, `layoutConfig`, and menu-fetching function.
{% endhint %}

## Layout Configuration Options

Below are the configuration options available for customizing your layout:

* **Sidebar**
  * `open`: Boolean to control the open or close state of the sidebar.
  * `hide`: Boolean to hide or show the sidebar.
  * `variant`: Variant of the sidebar, either `PERSISTENT`, `PERMANENT`, or `TEMPORARY`.
  * `style`: Style of the sidebar, either `FULL_HEIGHT` or `CLIPPED_UNDER_HEADER`.
  * `view`: View of the sidebar, either `FULL` or `MINI`.
  * `scrollType`: Scroll type of the sidebar, either `FIXED` or `DEFAULT`.
  * `anchor`: Anchor position of the sidebar, either `LEFT`, `RIGHT`, `TOP`, or `BOTTOM`.
  * `width`: Width of the sidebar.
  * `minWidth`: Minimum width of the sidebar in collapsed state.
* **Header**
  * `hide`: Boolean to show or hide the header.
  * `fixed`: Boolean to keep the header fixed or move with scroll.
  * `height`: Height of the header.
  * `sx`: Style object to set additional styling.
* **Footer**
  * `hide`: Boolean to show or hide the footer.
  * `sx`: Style object to set additional styling.
* **Root and Content**
  * `sx`: Style object to set additional styling for root and content.

By customizing these options, you can create a layout that perfectly fits your application's needs.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-jumbo.g-axon.work/v7.0-vite/structure/layout.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
