Layout Components

The core component, <AntdLayout />, is typically placed within the src/layouts directory. You may define multiple layout components; each maintains an isolated state, including any configurations stored in the browser. By implementing a layout component, all pages will automatically include the configured menus, toolbars, and branding information. Before using a layout component, you must first configure the necessary properties for routing and menus. These configuration options are divided into two categories: properties (attributes) and child elements. ## Usage Example

src/layouts/index.tsx
import { AntdLayout } from "@adminui-dev/antd-layout"
import type { LayoutConfig, MenuData } from "@adminui-dev/antd-layout"

/** menu data */
export const menuData:MenuData = {
    name:"",
    path:"/",
    label:"Dashboard",
    children:[
        {name:"welcome", path:"welcome", label:"Welcome"},
        {name:"transaction", path:"transaction", label:"Transaction", children:[
            {name:"order", path:"order", label:"Order"},
            {name:"product", path:"product", label:"Product"},
        ]}
    ]
}

export default function(){
// layout config
    const layoutConfig:LayoutConfig = {
        disabledLocale:true,
        layoutType:"leftMenu",
        primaryColor:"#4dbae9"
    }
    return(
        <>
            <AntdLayout layoutConfig={layoutConfig} menuData={menuData} />
        </>
    )
}
Copied!

Layout Style

When using the <AntdLayout /> component for a unified layout, the page is divided into three sections: the top bar, the side bar, and the content area. The content area—the largest section—is primarily used to display the pages located in pages/*, while the top and side bars are mainly used for menus. The layout’s appearance can be adjusted via various configuration properties. If a “skin theme” is applied, theme-specific elements are loaded into a slot beneath the main content; these three sections can also be configured to feature transparency and blur effects. ### Layout Panels

Split Menu

src/layouts/index.tsx
import { AntdLayout } from "@adminui-dev/antd-layout"
import type { LayoutConfig } from "@adminui-dev/antd-layout"

export default function layout(){
    const layoutConfig:LayoutConfig = {    
        "layoutType":"leftMenu",
        "collapsedPosition":"top",
        "avatarPosition":"leftBottom",
        "theme":"system",
        "visibleBreadcrumbIcon":"none",
        "primaryColor":"#222222",
        "asideMenuInline":true,
        "disabledLocale":false,
        "menuItemSelectColor":"invert",
        "largeBrand":true,
        "noneHeader":true,
        "headerTransparent":true,
        "asideTransparent":true,
        "hideTitle":true,
        "containerMargin":8
    }
    return(        
        <AntdLayout layoutConfig={layoutConfig}></AntdLayout>        
    )
}
Copied!

Built-in Elements

Brand Information

A component for displaying the brand logo and information (configured via LayoutConfig.brandInfo). Its position—either in the top bar or the side bar—adjusts automatically based on the chosen layout style (LayoutConfig.layoutType), while always remaining in the top-left corner. You can use LayoutConfig.largeBrand to enlarge the logo, and hovering the mouse reveals the content defined in <AntdLayout.BrandPopoverContent>.

User Information

A component for displaying the logged-in user’s profile (configured via LayoutConfig.userInfo). You can set its display position (or hide it entirely) using LayoutConfig.avatarPosition. Hovering the mouse reveals the content defined in <AntdLayout.AvatarPopoverContent>.

Properties

Properties are primarily used to configure initialization parameters, most of which are dynamically responsive. | Parameter Name | Type | Default Value | Description | |-------|-------|-------|-------| |layoutConfig|LayoutConfig|-|Layout configuration (includes theme mode, theme color, layout type, menu display style, etc.)| |menuData|MenuData|-|Menu configuration data| |themeSkins|ThemeSkin[]|-|Custom skin resources| |localeMessages|Record<string, LocaleMessage>|-|i18n (internationalization) data| |locale|string|-|Forces the use of a specific locale (e.g., en-US)| |theme|Theme|-|Forces a specific theme mode (e.g., light)| |layoutIcons|IconComponents|-|Configuration for built-in element icons| |disabledStorageConfig|bool|false|Disables local storage configuration|

Parameters that enforce specific settings will override those defined in layoutConfig, and any changes made via setLayoutConfig will have no effect.

Child Element Tags

Child elements include various UI components, such as user information, brand information, extended toolbar components, etc.

src/layouts/index.tsx
import { AntdLayout } from "@adminui-dev/antd-layout"
import { CarryOutOutlined, ProductOutlined, DesktopOutlined } from "@ant-design/icons"

export default function layout(){
    return(
        <>
            <AntdLayout layoutConfig={...} menuData={...}>
            <AntdLayout.HeaderToolbarExtra>
            <Button icon={<CarryOutOutlined />}></Button>
            <Button icon={<ProductOutlined />}></Button>
            <Button icon={<DesktopOutlined />}></Button>
            </AntdLayout.HeaderToolbarExtra>
            </AntdLayout>
        </>
    )
}
Copied!
ParameterTypeDefaultDescription
BrandPopoverContentReactNode-Content for the brand popover
AvatarPopoverContentReactNode-Content for the user popover
HeaderToolbarExtraReactNode[]-Additional content for the toolbar
AsideHeaderReactNode[]-Content for the sidebar header
AsideFooterReactNode[]-Content for the sidebar footer
FooterReactNode-Content for the main content footer
SlotContentReactNode[]-Slot content that does not affect the layout

IconComponents

This parameter expects an array with a length of 2, used for state toggling. It is mandatory; any additional elements will be ignored.

Parameter NameTypeDefault ValueDescription
fullScreenIconsReactNode[]-Full-screen button icons
collapsedIconsReactNode[]-Sidebar collapse button icons
mobileAsideIconsReactNode[]-Mobile-side slide-out button icons
expandIconReactNode[]-Menu expansion icon
itemMoreIconReactNode-Item “more” icon