• English
  • ProLayout - Advanced Layout

    ProLayout provides a standard, yet flexible, middle and backend layout, with one-click layout switching and automatic menu generation. It can be used with PageContainer to automatically generate breadcrumbs, page headers, and provide a low-cost solution to access the footer toolbar.

    When to use

    ProLayout can be used to reduce layout costs when content needs to be carried on a page.

    Issue regression scenarios

    Mobile layout, navigation theme, and component tokens
    import {
      CheckCard,
      PageContainer,
      ProCard,
      ProConfigProvider,
      ProLayout,
    } from '@ant-design/pro-components';
    import { Alert, ConfigProvider, Segmented, Space } from 'antd';
    import { useState } from 'react';
    
    const routes = [
      {
        path: '/dashboard',
        name: 'Dashboard',
        children: [
          { path: '/dashboard/analysis', name: 'Analysis' },
          { path: '/dashboard/monitor', name: 'Monitor' },
        ],
      },
      { path: '/settings', name: 'Settings' },
    ];
    
    export default () => {
      const [navTheme, setNavTheme] = useState<'light' | 'realDark'>('light');
    
      return (
        <Space direction="vertical" size={16} style={{ width: '100%' }}>
          <Alert
            type="info"
            showIcon
            message="布局与主题 token 回归场景"
            description="切换导航主题并悬停 Dashboard,检查深色菜单、弹层背景和 Card token。缩窄窗口可验证移动抽屉。"
          />
          <Segmented
            value={navTheme}
            options={[
              { label: '浅色导航', value: 'light' },
              { label: '真实深色', value: 'realDark' },
            ]}
            onChange={(value) => setNavTheme(value as 'light' | 'realDark')}
          />
          <ConfigProvider theme={{ components: { Card: { headerFontSize: 22 } } }}>
            <ProConfigProvider
              token={{
                colorPrimary: '#722ed1',
                components: { Card: { headerBg: '#f9f0ff' } },
                layout: {
                  header: { colorBgMenuElevated: '#141414' },
                },
              }}
            >
              <ProCard title="ProConfigProvider Card token">
                <CheckCard title="CheckCard 继承主题" description="#8929 #9125" />
              </ProCard>
              <div style={{ height: 480, marginBlockStart: 16 }}>
                <ProLayout
                  title="Regression Demo"
                  layout="top"
                  navTheme={navTheme}
                  route={{ routes }}
                  location={{ pathname: '/dashboard/analysis' }}
                  menu={{ request: async () => routes }}
                >
                  <PageContainer title="首屏布局稳定">
                    移动端抽屉、菜单分组、SSR 与首屏 padding 由对应自动化测试覆盖。
                  </PageContainer>
                </ProLayout>
              </div>
            </ProConfigProvider>
          </ConfigProvider>
        </Space>
      );
    };
    

    Use with umi plugins

    ProLayout works best with umi. umi automatically injects the routes from config.ts into the configured layout for us, so we don't have to write the menus by hand.

    ProLayout extends umi's router configuration, adding name, icon, locale, hideInMenu, hideChildrenInMenu and other configurations, so that it is easier to generate menus in one place. The data format is as follows.

    export interface MenuDataItem {
      /** @name submenu */
      routes?: MenuDataItem[];
      /** @name Hide child nodes in the menu */
      hideChildrenInMenu?: boolean;
      /** @name hideSelf and children in menu */
      hideInMenu?: boolean;
      /** @name Icon of the menu */
      icon?: React.ReactNode;
      /** @name Internationalization key for custom menus */
      locale?: string | false;
      /** @name The name of the menu */
      name?: string;
      /** @name is used to calibrate the selected value, default is path */
      key?: string;
      /** @name disable menu option */
      disabled?: boolean;
      /** @name path */
      path?: string;
      /**
       * When this node is selected, the node of parentKeys is also selected
       *
       * @name custom parent node
       */
      parentKeys?: string[];
      /** @name hides itself and elevates child nodes to its level */
      flatMenu?: boolean;
      /** @name specify the external link opening form, same as a tag */
      target?: string;
    
      [key: string]: any;
    }

    ProLayout will automatically select the menu based on location.pathname and automatically generate the corresponding breadcrumbs. If you don't want to use it, you can configure selectedKeys and openKeys yourself for controlled configuration.

    API

    ProLayout

    All methods suffixed with Render can be made not to render by passing false.

    ParametersDescriptionTypeDefault
    titleThe title of the top-left corner of the layoutReactNode'Ant Design Pro'
    logourl to the top-left corner of layout's logoReactNode | JSX.Element | WithFalse<() => ReactNode | JSX.Element>-
    pureSimple mode, does not render any layout things after setting, but there will be context, you can get the current menuboolean-
    loadingThe loading state of the layoutboolean-
    locationThe location information of the current application session. If your application creates a custom history, you will need to display the location attribute as described in issueRouterTypes['location']isBrowser ? window.location : undefined
    appListCross-site navigation listAppListProps-
    appListRenderCustom render method for cross-site navigation list(props: AppListProps, defaultDom: React.ReactNode) => ReactNode-
    menuHeaderRenderrender logo and title, has a higher priority than headerTitleRenderWithFalse<(logo: ReactNode, title: ReactNode, props?: SiderMenuProps) => ReactNode>-
    menuFooterRenderRender a block at the bottom of the layoutWithFalse<(props?: SiderMenuProps) => ReactNode>-
    onMenuHeaderClickmenu menu menu's header click event(e: React.MouseEvent<HTMLDivElement>) => void-
    menuExtraRenderRenders a region below the menu headerWithFalse<(props: SiderMenuProps) => ReactNode>-
    onTopMixMenuHeaderClickthe header click event of the top bar in mix mode(e: React.MouseEvent<HTMLDivElement>) => void-
    contentStylelayout's content area styleCSSProperties-
    layoutlayout's menu mode,side: right-hand navigation,top: top navigation'side' | 'top' | 'mix''side'
    contentWidthcontent mode of layout,Fluid: adaptive,Fixed: fixed 1200px'Fluid' | 'Fixed''Fluid'
    actionRefCommon operations of layout, such as reloading menuReact.MutableRefObject<{reload: () => void} | undefined>-
    fixedHeaderWhether to fix the header to the topbooleanfalse
    fixSiderbarwhether to fix the navigationbooleantrue
    breakpointTrigger breakpoint for responsive layoutsEnum { 'xs', 'sm', 'md', 'lg', 'xl', 'xxl' }lg
    menuAbout menu configuration, temporarily only locale, locale can close the menu's own globalizationmenuConfig{ locale: true }
    iconfontUrlUse the icon configuration of IconFontURL-
    localeLanguage settings for the current layoutLocaleType ('zh-CN' | 'zh-TW' | 'en-US' | 'it-IT' | 'ko-KR')navigator.language
    settingssettings for layoutSettings-
    siderWidthwidth of the side menunumbermix mode: 215, other: 256
    suppressSiderWhenMenuEmptyHide Sider when menu is emptyboolean-
    defaultCollapsedThe default collapsed and expanded menus, will be affected by breakpoint, breakpoint=false workboolean-
    collapsedControls the collapse and expansion of the menu, layout is strictly controlled, can be set to true, always collapsedboolean-
    onCollapseThe collapsed event of the menu(collapsed: boolean) => void-
    onPageChangeTriggered on page switch(location?: RouterTypes['location']) => void-
    headerRenderCustom header render methodWithFalse<(props: ProLayoutProps & {hasSiderMenu?: boolean}, defaultDom: ReactNode) => ReactNode>-
    headerTitleRenderCustom header title method, works in mix mode and top modeWithFalse<(logo: ReactNode, title: ReactNode, props: HeaderViewProps) => ReactNode>-
    headerContentRenderCustom header content methodsWithFalse<(props: HeaderViewProps, defaultDom: ReactNode) => ReactNode>-
    avatarPropslayout's avatar setting, different layouts are placed in different positionsWithFalse<AvatarProps & {title?: ReactNode, render?: (avatarProps: AvatarProps, defaultDom: ReactNode, props: SiderMenuProps) => ReactNode}>-
    actionsRenderLayout's operation function list, different layouts will be placed in different positionsWithFalse<(props: HeaderViewProps) => ReactNode[] | ReactNode>-
    collapsedButtonRenderCustom method for collapsed buttonWithFalse<(collapsed: boolean) => ReactNode>-
    footerRenderCustom render method for footerWithFalse<(props: ProLayoutProps & {hasSiderMenu?: boolean}, defaultDom: ReactNode) => ReactNode>-
    pageTitleRenderThe render method for custom page titlesWithFalse<(props: GetPageTitleProps, defaultPageTitle?: string, info?: {title: string, id: string, pageName: string}) => string>-
    menuRenderAlthough called menuRender, it is actually the render function of the entire SiderMenu panelWithFalse<(props: HeaderViewProps, defaultDom: ReactNode) => ReactNode>-
    postMenuDataView the menu data before displaying it, changes will not trigger a re-render(menuData: MenuDataItem[]) => MenuDataItem[]-
    menuItemRenderThe render method for custom menu items(itemProps: MenuDataItem, defaultDom: ReactNode, props: BaseMenuProps) => ReactNode-
    subMenuItemRenderCustomize the render method with submenu items(itemProps: MenuDataItem) => ReactNode-
    menuDataRenderThe render method of menuData, used to customize menuData(menuData: MenuDataItem[]) => MenuDataItem[]-
    breadcrumbRenderSet PageHeader breadcrumbs, can only process dataWithFalse<(routers: BreadcrumbProps['items']) => BreadcrumbProps['items']>-
    breadcrumbPropsPageHeader's BreadcrumbProps configuration, will be passed down transparentlyOmit<BreadcrumbProps, 'itemRender'> & LayoutBreadcrumbProps-
    itemRenderHandle the configuration of each breadcrumb, need to return dom directlyBreadcrumbProps['itemRender']-
    routeUsed to generate menus and breadcrumbs. umi's Layout will automatically haveroute-
    disableMobiledisable automatic switching to mobile pagesbooleanfalse
    ErrorBoundaryError handling componentReact.ComponentClass<any, any> | booleanBuilt-in ErrorBoundary
    linksShow shortcut actions in the lower right corner of the menuReactNode[]-
    menuPropsThe props passed to the antd menu component, see Navigation MenuMenuProps-
    waterMarkPropsWatermark related configurationWatermarkProps-
    formatMessageInternationalization method(message: MessageDescriptor) => string-
    siderMenuTypeThe type of side menu, shortcut for menu.type'sub' | 'group'-
    isChildrenLayoutWhether it is a child layoutboolean-
    bgLayoutImgListLayout's brand configuration, represented as a background image{src?: string, width?: string, height?: string, left?: number, top?: number, bottom?: number, right?: number}[]-
    stylishStyle configuration{header?: GenerateStyle<SiderMenuToken>, sider?: GenerateStyle<SiderMenuToken>}-
    classNameclassName of the outer containerstring-
    stylestyle of the outer containerReact.CSSProperties-
    tokenLayout token configurationProTokenType['layout']-

    menu supports some commonly used menu configurations to help us better manage menus

    ParametersDescriptionTypeDefault
    localeWhether the menu uses internationalization, also requires formatMessage.booleantrue
    defaultOpenAllOpen all menu items by default, note that it only takes effect before layout mount, asynchronous loading of menus is not supportedbooleanfalse
    ignoreFlatMenuWhether to ignore the manually collapsed menu state, combined with defaultOpenAll can achieve expansion of all submenus after the toggle button switchesbooleanfalse
    typeType of menusub | groupgroup
    autoCloseWhether to automatically close the menu when selectedfalsetrue
    collapsedShowGroupTitleShow group menu titles when collapsedboolean-
    collapsedShowTitleShow titles when collapsedboolean-
    collapsedWidthMenu width when collapsednumber-
    defaultOpenAllOpen all menu items by default, only works before layout mounts; async menus are not supportedbooleanfalse
    hideMenuWhenCollapsedHide the menu panel when collapsedboolean-
    ignoreFlatMenuIgnore manually collapsed menu state; with defaultOpenAll, all submenus can still expand after toggling the collapse buttonbooleanfalse
    localeWhether the menu uses i18n, requires formatMessagebooleantrue
    paramsParams for remote menu requests; request is re-triggered only when params changeRecord<string, any>-
    loadingWhether the menu is loadingbooleanfalse
    onLoadingChangeMenu loading state change(loading)=>void-
    requestMethod for remote loading of menus, will automatically modify loading state(params,defaultMenuDat) => Promise<MenuDataItem[]>-
    typeMenu type'sub' | 'group''group'

    SettingDrawer

    ParametersDescriptionTypeDefault
    collapseControl SettingDrawer collapse and expandboolean-
    onCollapseChangeSettingDrawer collapse event(collapsed: boolean) => void-
    settingslayout settingsSettings | Settings-
    onSettingChangeSettings A change event occurred(settings: [Settings](#Settings)) => void-
    hideHintAlertDelete the prompt message belowboolean-
    hideCopyButtonDo not show copy functionboolean-
    disableUrlParamsDisable synchronization settings to query parametersbooleanfalse
    enableDarkThemeTurn on black theme switching function | booleanfalse
    colorListBuilt-in color switching system (ColorList title will be displayed as Tooltip) | {key,color,title?}[]ColorList

    Built-in color list

    const colorList = [
      { key: 'daybreak', color: '#1890ff' },
      { key: 'dust', color: '#F5222D' },
      { key: 'volcano', color: '#FA541C' },
      { key: 'sunset', color: '#FAAD14' },
      { key: 'cyan', color: '#13C2C2' },
      { key: 'green', color: '#52C41A' },
      { key: 'geekblue', color: '#2F54EB' },
      { key: 'purple', color: '#722ED1' },
    ];

    PageLoading

    A simple loading page

    parametersdescriptiontypedefault
    (...)support all other antd Spin component parameters--

    getMenuData

    Generate menuData and breadcrumb based on router information.

    import { getMenuData } from '@ant-design/pro-components';
    
    const { breadcrumb, menuData } = getMenuData(
      routes,
      menu,
      formatMessage,
      menuDataRender,
    );
    parametersdescriptiontypedefault
    routesThe configuration information for the routeroute[]-
    menuThe configuration entry for menu, default {locale: true}{ locale: boolean }-
    menuDataRenderThe render method of menuData, used to customize menuData(menuData: MenuDataItem[]) => MenuDataItem[]-
    formatMessageThe formatMessage method of react-intl(data: { id: any; defaultMessage?: string }) => string;-

    getPageTitle

    getPageTitle encapsulates the logic of the title generated on the menuData.

    import { getPageTitle } from '@ant-design/pro-components';
    
    const title = getPageTitle({
      pathname,
      breadcrumb,
      menu,
      title,
      formatMessage,
    });
    parametersdescriptiontypedefault
    pathnamecurrent pathnamelocation.pathname-
    breadcrumbthe collection of MenuDataItem{ [path: string]: MenuDataItem }-
    menuThe configuration item for menu, default {locale: true}{ locale: boolean }-
    titletype of titlestring'Ant Design Pro'
    formatMessageformatMessage method of react-intl(data: { id: any; defaultMessage?: string }) => string;-

    Settings

    // You can get this type by importing { Settings } from '@ant-design/pro-layout/defaultSettings'
    // to get this type
    export interface Settings {
      /** theme of nav */
      navTheme: 'light' | 'realDark';
      /** Primary color of ant design */
      colorPrimary: string;
      /** Nav menu position: `side` or `top` or `mix` */
      layout: 'side' | 'top' | 'mix';
      /** Layout of content: `Fluid` or `Fixed`, only works when layout is top */
      contentWidth: 'Fluid' | 'Fixed';
      /** Sticky header */
      fixedHeader: boolean;
      /** Sticky siderbar */
      fixSiderbar: boolean;
      /** menu configuration */
      menu?: {
        locale?: boolean;
        hideMenuWhenCollapsed?: boolean;
        collapsedShowTitle?: boolean;
        collapsedShowGroupTitle?: boolean;
        defaultOpenAll?: boolean;
        ignoreFlatMenu?: boolean;
        loading?: boolean;
        onLoadingChange?: (loading?: boolean) => void;
        params?: Record<string, any>;
        request?: (
          params: Record<string, any>,
          defaultMenuData: MenuDataItem[],
        ) => Promise<MenuDataItem[]>;
        type?: 'sub' | 'group';
        autoClose?: false;
        collapsedWidth?: number;
      };
      /** Layout title, also displayed in the browser tab */
      title?: string | false;
      /** Your custom iconfont Symbol script Url */
      iconfontUrl?: string;
      /** Global color filter */
      colorWeak?: boolean;
      /** Split menus, only works in mix mode */
      splitMenus?: boolean;
      /** Hide Sider when menu is empty */
      suppressSiderWhenMenuEmpty?: boolean;
      /** Sider menu type */
      siderMenuType?: 'sub' | 'group';
    }
    // You can get this type by importing { MenuDataItem } from '@ant-design/pro-components'
    // to get this type
    export interface MenuDataItem {
      authority?: string[] | string;
      children?: MenuDataItem[];
      hideChildrenInMenu?: boolean;
      hideInMenu?: boolean;
      icon?: string;
      locale?: string;
      name?: string;
      path: string;
    
      [key: string]: any;
    }

    Route

    // You can get this type by importing { RouterTypes } from '@ant-design/pro-layout/lib/typings';
    // to get this type
    export interface Route {
      path: string;
      children: Array<{
        exact?: boolean;
        emoji: string;
        name: string;
        path: string;
        // Optional secondary menu
        children?: Route['children'];
      }>;
    }

    The default ProLayout does not provide a footer, but does provide a DefaultFooter component that supports the configuration of some hyperlinks and some copyright information.

    import { GithubOutlined } from '@ant-design/icons';
    import { DefaultFooter } from '@ant-design/pro-components';
    
    <DefaultFooter
      copyright="@2019 by Ant Financial Experience Technology Department"
      links={[
        {
          key: 'Ant Design Pro',
          title: 'Ant Design Pro',
          href: 'https://pro.ant.design',
          blankTarget: true,
        },
        {
          key: 'github',
          title: <GithubOutlined />,
          href: 'https://github.com/ant-design/ant-design-pro',
          blankTarget: true,
        },
        {
          key: 'Ant Design',
          title: 'Ant Design',
          href: 'https://ant.design',
          blankTarget: true,
        },
      ]}
    />;

    GridContent

    GridContent is a simple syntactic sugar that encapsulates ProLayout's contentWidth configuration. contentWidth, if set to Fixed fixed-width mode, is only 1200px at its widest.

    Usage.

    <GridContent>{children}</GridContent>

    GridContent encapsulates the equal-width and flow logic. You can see the preview effect in preview.

    parametersdescriptiontypedefault
    contentWidthContentModeFluid | Fixed-

    RouteContext

    RouteContext can provide built-in data for Layout. For example, isMobile and collapsed, which you can consume to customize some of the behavior.

    RouteContext also allows you to perform operations based on layout data, and PageContainer and FooterToolbar rely on RouteContext data to function.

    import { RouteContext, RouteContextType } from '@ant-design/pro-components';
    
    const Page = () => (
      <RouteContext.Consumer>
        {(value: RouteContextType) => {
          const { isMobile, hasHeader, hasSiderMenu, collapsed } = value;
          // User's title
          return value.title;
        }}
      </RouteContext.Consumer>
    );

    Token

    Tokens are a basic element of a design system that allows you to quickly modify the underlying style of a component library using Tokens. These colors can be configured in Layout through the token property.

    Layout token

    tokendescriptiondefault value
    bgLayoutbackground color of layoutlinear-gradient(${antdToken.colorBgContainer}, ${antdToken.colorBgLayout} 28%)
    colorTextAppListIconIcon color for cross-site apps#666
    colorTextAppListIconHoverIcon hover color for cross-site applicationsrgba(0, 0, 0, 0.65)
    colorBgAppListIconHoverIcon hover background color for cross-site applicationsrgba(0, 0, 0, 0.04)

    Sider Token

    Sider Token is the color value of the side menu, which is different from the top menu.

    tokendescriptiondefault value
    colorMenuBackgroundmenu background colortransparent
    colorTextMenuTitlesider's title font colorcolorTextHeading
    colorMenuItemDividermenuItem divider colorcolorSplit
    colorTextMenufont color of menuItemcolorText
    colorTextMenuSecondarySecondary font color for menu, such as footer and action iconscolorText
    colorTextMenuSelectedselected font color of menuItemrgb(0,0,0)
    colorTextMenuActiveactive font color of menuItemrgba(0, 0, 0, 0.85)
    colorTextMenuItemHoverhover font color of menuItemrgba(255,255,255,0.75)
    colorBgMenuItemActivebackground color of menuItem while clickingrgba(0, 0, 0, 0.15)
    colorBgMenuItemHoverhover background color of menuItemrgba(90, 75, 75, 0.03)
    colorBgMenuItemSelectedselected background color of menuItemrgba(0, 0, 0, 0.04)
    colorBgMenuItemCollapsedElevatedThe popup menu background color of the collapsed menuItemtransparent
    colorBgCollapsedButtonCollapse button background color#fff
    colorTextCollapsedButtonCollapse button hover font colorcolorTextMenuSecondary
    colorTextCollapsedButtonHoverCollapsed button font color on hovercolorTextMenu

    Header Token

    tokendescriptiondefault value
    colorBgHeaderThe background color of the headerrgba(240, 242, 245, 0.4)
    colorHeaderTitleheader font color for sidercolorTextHeading
    colorTextMenufont color of menuItemcolorText
    colorTextMenuSecondarySecondary font color for menu, such as footer and action iconscolorText
    colorTextMenuSelectedselected font color of menuItemrgb(0,0,0)
    colorTextMenuActiveactive font color of menuItemrgba(0, 0, 0, 0.85)
    colorBgMenuItemHoverhover background color of menuItemrgba(90, 75, 75, 0.03)
    colorBgMenuItemSelectedselected background color of menuItemrgba(0, 0, 0, 0.04)
    colorTextRightActionsItemTop right font colorcolorTextSecondary
    colorBgRightActionsItemHoverThe selected hover color in the upper right cornerrgba(0, 0, 0, 0.03)
    heightLayoutHeaderheader height56

    pageContainer Token

    tokendescriptiondefault value
    paddingBlockPageContainerContentpageContainer's own padding block24
    paddingInlinePageContainerContentpageContainer's own padding inline40
    colorBgPageContainerbackground color of pageContainertransparent
    colorBgPageContainerFixedThe background color of the pageContainer when it is fixed#FFF

    FAQ

    Customizing Layout

    ProLayout provides some api to remove areas that are not needed by the user. Some configurations are also provided in SettingDrawer to set them.

    setting-drawer-render

    • headerRender can customize the top bar
    • footerRender can customize the footer
    • menuRender can customize the menu area
    • menuHeaderRender Customizable menu header area
    • menuExtraRender can add an extra content to the menu, between the menu header and the menu

    All xxxRender in layout can be passed in false to turn off rendering.

    Use with Umi

    ProLayout works best with Umi, Umi will automatically inject the routes from config.ts into the configured layout, saving us the trouble of writing menus by hand.

    ProLayout extends Umi's router configuration, adding name, icon, locale, hideInMenu, hideChildrenInMenu and other configurations, so that it is easier to generate menus in one place. The data format is as follows:

    export interface MenuDataItem {
      /** @name submenu */
      children?: MenuDataItem[];
      /** @name Hide child nodes in the menu */
      hideChildrenInMenu?: boolean;
      /** @name hideSelf and children in menu */
      hideInMenu?: boolean;
      /** @name Hide in breadcrumb */
      hideInBreadcrumb?: boolean;
      /** @name Icon of the menu */
      icon?: React.ReactNode;
      /** @name Internationalization key for custom menus */
      locale?: string | false;
      /** @name The name of the menu */
      name?: string;
      /** @name is used to calibrate the selected value, default is path */
      key?: string;
      /** @name disable menu option */
      disabled?: boolean;
      /** @name path, can be set to a web link */
      path?: string;
      /**
       * @deprecated When this node is selected, the node of parentKeys is also selected
       * @name custom parent node
       */
      parentKeys?: string[];
      /** @name hides itself and elevates child nodes to its level */
      flatMenu?: boolean;
      /** @name specify the external link opening form, same as a tag */
      target?: string;
    
      [key: string]: any;
    }

    ProLayout will automatically select the menu based on location.pathname and automatically generate the corresponding breadcrumbs. If you don't want to use it, you can configure selectedKeys and openKeys yourself for controlled configuration.

    Collapse to expand

    Sometimes we find that collapsed and onCollapse do not work by default. This is because ProLayout has a built-in breakpoint mechanism to trigger collapse, we can set breakpoint={false} to turn off this mechanism.

    To toggle the sidebar from any component, lift collapsed into shared state and pass collapsed={collapsed} plus onCollapse={setCollapsed} to ProLayout. A reusable toggle action is () => setCollapsed(value => !value).

    Customize the width of the menu

    siderWidth can customize the width of the menu, you can set it shorter or longer FooterToolbar and other components will automatically support, but may need to do some style processing, otherwise the menu display may have some small problems.

    The width of the menu is not customizable because it involves animation and huge amount of css changes, which is very difficult to customize.

    Auto-cut menu

    Auto-cut menu is an exclusive ability of mix mode to place the first level of the menu into the top bar. We can set splitMenus=true to turn it on, and for a good experience it's best to set a redirect for each level of the menu, which will prevent switching to a white screen page.

    cutMenu

    Customizing menus

    ProLayout will automatically generate the menu and auto-select it according to pathname. Combined with PageContainer, this allows for automatic breadcrumb and page title projection. If used with the Umi configuration, you only need to hand the Page props to ProLayout to automatically generate the configuration of the menu based on the configuration of routers in config.

    In order to provide more functionality, we extended the routers configuration by adding several configurations for customization, with the following data structure definition:

    // You can get this type by importing { MenuDataItem } from '@ant-design/pro-components'
    // to get this type
    export interface MenuDataItem {
      children?: MenuDataItem[];
      hideChildrenInMenu?: boolean;
      hideInMenu?: boolean;
      icon?: string;
      locale?: string;
      name?: string;
      path: string;
      [key: string]: any;
    }
    • name is used to configure the name in the menu, and will be modified to the browser tab title
    • icon represents the body of the menu, only antd's icon, iconfont needs to be defined by yourself
    • locale can set the internationalization of the menu name
    • hideInMenu will be configured to hide this route in the menu, name will have the same effect if not filled
    • hideChildrenInMenu will hide the children of this route in the menu

    ProLayout actually reads the route and location from the props, which are injected by default by Umi.

    Getting from the server

    Sometimes we want the server to manage our routes, so we want the menus to be distributed by the server. We provide menuDataRender to modify the data, but note that menuDataRender will trigger re-rendering and will also support internationalization and permission configuration, so if you don't need internationalization, we recommend using postMenuData for a significant performance boost.

    The server needs to return the same data as MenuDataItem, menuDataRender needs to return an array, if you want to have better performance you can try using the route property in props, here is a demo.