Layout Configuration

The LayoutConfig covers almost all initialization and dynamic parameters of the layout component <AntdLayout />. Most of these configurations can be dynamically updated. However, some parameters are intentionally restricted in specific scenarios.

Configuration data can be persisted in the browser (localStorage) based on the routing context. Updates must be performed using the designated method (setLayoutConfig).

At the same time, configuration changes can be dynamically updated via setLayoutConfig, and the latest state can be accessed through layoutConfig. These two operations are handled separately via a write hook (setLayoutConfig) and a read-only hook (useConfigState).

Initial Layout Configuration

These are the initial parameters passed into the layout component on first load.

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

const layoutConfig:LayoutConfig = {
    layoutType:"leftMenu",  
    asideMenuInline:true,
    hideAsideMenuDataEmpty:true,
    skinName:"parkWavesLight",
    collapsedPosition:"center",
    menuIconSize:16,
    disabledLocale:false,
    menuItemSelectColor:"default",
    largeBrand:true,
}
export default function(){    
    return(
        <AntdLayout layoutConfig={layoutConfig} menuData={...}>        
    )
}
Copied!

Dynamically Updating Layout Configuration

There are two approaches:

  1. Using external state management (not recommended)
src/layouts/index.tsx
export default function(){    
    const [config,setConfig] = useState<LayoutConfig>({...})
    return(
        <AntdLayout layoutConfig={config} menuData={...}>        
    )
}
Copied!

This works in practice, but is not recommended because some configuration parameters are intentionally restricted

  1. Using hooks inside components (recommended)
src/layouts/index.tsx
export default function(){    
    const config:LayoutConfig = {
        layoutType:"leftMenu",  
        asideMenuInline:true,
        ...
    }
    return(
        <AntdLayout layoutConfig={config} menuData={...}>        
    )
}
Copied!

Inside pages, you can use the hooks useConfigAction and the action method setLayoutConfig

src/pages/transaction/order.tsx
const { layoutConfig } = useConfigState()
const { setLayoutConfig } = useConfigAction()
...
setLayoutConfig( {...layoutConfig, layoutType:'headMenu' })
...
Copied!

Configuration Restrictions

Some projects only require an initial layout configuration, while others need dynamic updates and persistence. In more advanced scenarios, configurations may need to be saved locally and restored on reload or next visit. To support these cases, certain behaviors are restricted at the framework level, for example:

When disabledStorageConfig = true, browser-based storage is disabled. After refresh, configuration changes will not persist.

Properties and Types

LayoutConfig

NameTypeDefaultDescription
layoutTypeLayoutTypeleftMenuLayout type
primaryColorstringrgb(65, 127, 251)Global theme color
themeThemesystemTheme mode
localestringen-USlocale
skinNamestring-Current theme skin name
headerHeightnumber56Header height
asideWidthnumber260Maximum sidebar width
colorLinkstringrgb(65, 127, 251)Link color
menuIconSizenumber16Menu icon size
menuFontSizenumber14Menu font size
containerMarginnumber0Container margin
compactboolfalseCompact layout
splitMenuboolfalseSplit top/bottom menu
flatedboolfalseFlat mode
noneHeaderboolfalseRemove header
largeBrandboolfalseEnlarge brand logo
asideMenuInlineboolfalseInline sidebar menu
asideMenuGroupboolfalseGroup sidebar menu
disabledLocaleboolfalseDisable i18n
hideBorderboolfalseHide borders
hideTitleboolfalseHide title
hideFooterboolfalseHide footer
hideBreadcrumbboolfalseHide breadcrumb
asideTransparentboolfalseTransparent sidebar
headerTransparentboolfalseTransparent header
containerTransparentboolfalseTransparent container
asideBlurboolfalseSidebar blur effect
headerBlurboolfalseHeader blur effect
containerBlurboolfalseContainer blur effect
hideAsideMenuDataEmptyboolfalseHide empty sidebar menus
menuItemSelectColorMenuItemSelectColordefaultMenu selection style
collapsedPositionPositioncenterCollapse button position
avatarPositionAvatarPositionrightTopAvatar position
visibleBreadcrumbIconBreadcrumbIconVisiblenoneBreadcrumb icon visibility
userInfoUserInfo-User information
brandInfoBrandInfo-Brand information

LayoutType

Theme

Position

AvatarPosition

UserInfo

BrandInfo