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
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} />
</>
)
}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
Top panel: Displays<HeaderToolbarExtra />, brand information, user information, and themenu.Side panel: Displays<AsideHeader />,<AsideFooter />, brand information, user information, and themenu. The side bar can be collapsed manually or automatically via responsive behavior.Content: Displays the breadcrumb navigation, title, footer, and page content.
Split Menu
- When the split menu feature is enabled via
LayoutConfig.splitMenu, the menu is displayed in two locations. TheLayoutConfig.layoutTypesetting determines whether the main menu appears in the top bar (headMenu) or the side bar (leftMenu). - If
LayoutConfig.noneHeaderis enabled, the menu is forced into the side bar, and both the split sub-menus and the top bar are removed. Therefore, the split menu feature should not be used in this configuration. This option is intended for highly customized layouts—for instance, to achieve a sidebar-style layout similar to that ofshadcn/ui. An example configuration is provided below:
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>
)
}Built-in Elements
Full-screen Button: A component for toggling full-screen mode. It is fixed at the far right of the top bar toolbar; it cannot be hidden, but itsicon can be changed.Collapse Button: A component for manually collapsing the side bar. Its position can be adjusted viaLayoutConfig.collapsedPosition, and itsicon can be changed.
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 viasetLayoutConfigwill have no effect.
Child Element Tags
Child elements include various UI components, such as user information, brand information, extended toolbar components, etc.
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>
</>
)
}| Parameter | Type | Default | Description |
|---|---|---|---|
| BrandPopoverContent | ReactNode | - | Content for the brand popover |
| AvatarPopoverContent | ReactNode | - | Content for the user popover |
| HeaderToolbarExtra | ReactNode[] | - | Additional content for the toolbar |
| AsideHeader | ReactNode[] | - | Content for the sidebar header |
| AsideFooter | ReactNode[] | - | Content for the sidebar footer |
| Footer | ReactNode | - | Content for the main content footer |
| SlotContent | ReactNode[] | - | 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 Name | Type | Default Value | Description |
|---|---|---|---|
| fullScreenIcons | ReactNode[] | - | Full-screen button icons |
| collapsedIcons | ReactNode[] | - | Sidebar collapse button icons |
| mobileAsideIcons | ReactNode[] | - | Mobile-side slide-out button icons |
| expandIcon | ReactNode[] | - | Menu expansion icon |
| itemMoreIcon | ReactNode | - | Item “more” icon |