Layout Component

The core component is <AntdLayout />, which is placed inside layout files, typically under src/layouts. There may be multiple instances, and their states are isolated from each other—including configuration stored in the browser.

After using the layout component, all pages will include the configured menu, toolbar, and branding information. Before using it, you need to configure the routes and menu properties.

The parameters are divided into two parts: props and child component slots.

Usage Example

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

/** menu data */
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!

Props

Props are mainly used to configure initialization parameters, most of which support dynamic updates.

NameTypeDefaultDescription
layoutConfigLayoutConfig-Layout configuration(including theme mode, primary color, layout type, menu display style, etc.)
menuDataMenuData-menu configuration data
themeSkinsThemeSkin[]-Custom theme skins resources
localeMessagesRecord<string, LocaleMessage>falsei18n localization data
localestringen-USForce a specific locale (e.g.,en-US)
themestring-Force brightness mode (e.g.,light)
disabledStorageConfigboolfalseDisable local storage configuration

Forced props will override values in layoutConfig and setLayoutConfig will not take effect.

Child Component Slots

Child elements provide mount points for UI components such as user info, branding, and extended toolbar content.

src/layouts/index.tsx
<AntdLayout layoutConfig={...} menuData={...}>
    <AntdLayout.BrandPopoverContent>
        <div className="brandContent">
            <dl>
                <dt>Title</dt>
                <dd>Username</dt>
                <dd>Email<dt>
            <dl>
        </div>
    </AntdLayout.BrandPopoverContent>
</AntdLayout>
Copied!
NameTypeDefaultDescription
BrandPopoverContentReactNode-Brand popover content in the top-left corner
AvatarPopoverContentReactNode-User info popover content
HeaderToolbarExtraReactNode[]-Extra content in the toolbar
AsideHeaderReactNode[]-Header content of the side panel
AsideFooterReactNode[]-ooter content of the side panel
FooterReactNode[]-Page footer content
SlotContentReactNode-Slot content that does not affect layout