Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ant-design-vue/pro-layout

Package Overview
Dependencies
Maintainers
4
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ant-design-vue/pro-layout

Ant Design Pro Layout of Vue, easy to use pro scaffolding.

  • 3.2.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-22.25%
Maintainers
4
Weekly downloads
 
Created
Source

Ant Design Pro Layout

NPM version Vue Support Vue Grammar Level NPM downloads License

💻 Preview layout:

Basic Usage

Recommend look Examples or Use Template

Branch

Install

# yarn
yarn add @ant-design-vue/pro-layout
# npm
npm i @ant-design-vue/pro-layout -S

Simple Usage

First, you should add the @ant-design-vue/pro-layout that you need into the library.

// main.[js|ts]
import "@ant-design-vue/pro-layout/dist/style.css"; // pro-layout css or style.less

import { createApp } from "vue";
import App from "./App.vue";
import Antd from "ant-design-vue";
import ProLayout, { PageContainer } from "@ant-design-vue/pro-layout";

const app = createApp(App);

app.use(Antd).use(ProLayout).use(PageContainer).mount("#app");

After that, you can use pro-layout in your Vue components as simply as this:

<template>
  <pro-layout
    :locale="locale"
    v-bind="layoutConf"
    v-model:openKeys="state.openKeys"
    v-model:collapsed="state.collapsed"
    v-model:selectedKeys="state.selectedKeys"
  >
    <router-view />
  </pro-layout>
</template>

<script setup lang="ts">
import { reactive, useRouter } from "vue";
import { getMenuData, clearMenuItem } from "@ant-design-vue/pro-layout";

const locale = (i18n: string) => i18n;
const router = useRouter();

const { menuData } = getMenuData(clearMenuItem(router.getRoutes()));

const state = reactive({
  collapsed: false, // default value
  openKeys: ["/dashboard"],
  selectedKeys: ["/welcome"],
});
const layoutConf = reactive({
  navTheme: "dark",
  layout: "mix",
  splitMenus: false,
  menuData,
});
</script>

API

ProLayout

PropertyDescriptionTypeDefault Value
titlelayout in the upper left corner titleVNode | String'Ant Design Pro'
logolayout top left logo urlVNode | render-
loadinglayout loading statusboolean-
layoutlayout menu mode, sidemenu: right navigation, topmenu: top navigation'side' | 'top' | 'mix''side'
contentWidthcontent mode of layout, Fluid: adaptive, Fixed: fixed width 1200px'Fixed' | 'Fluid'Fluid
navThemeNavigation theme'light' |'dark''light'
headerThemeHeader Bar theme'light' |'dark''light'
menuDataVue-router routes propObject[{}]
collapsedcontrol menu's collapse and expansionbooleantrue
selectedKeysmenu selected keysstring[][]
openKeysmenu openKeysstring[][]
isMobileis mobilebooleanfalse
onCollapse | @collapsefolding collapse event of menu(collapsed: boolean) => void-
menuHeaderRenderrender header logo and titlev-slot | VNode | (logo,title)=>VNode | false-
menuExtraRenderrender extra menu itemv-slot | VNode | (props)=>VNode | false-
menuFooterRenderrender footer menu itemv-slot | VNode | (props)=>VNode | false-
menuItemRendercustom render Menu.Itemv-slot#menuItemRender="{ item, icon }" | ({ item, icon }) => VNodenull
subMenuItemRendercustom render Menu.SubItemv-slot#subMenuItemRender="{ item, icon }" | ({ item, icon }) => VNodenull
collapsedButtonRendercustom collapsed button methodslot | (collapsed: boolean) => VNode-
headerRendercustom header render methodslot | (props: BasicLayoutProps) => VNode-
headerContentRenderheader content render method only layout sideslot | (props: BasicLayoutProps) => VNode-
rightContentRenderheader right content render methodslot | (props: BasicLayoutProps) => VNode-
footerRendercustom footer render methodslot | ({ width, ...BasicLayoutProps }) => VNodefalse
tabRendercustom tab render methodslot | ({ width, ...BasicLayoutProps }) => VNodefalse
breadcrumbRendercustom breadcrumb render methodslot | ({ route, params, routes, paths, h }) => VNode[]-
localei18nFunction (key: string) => string | falsefalse

Menu generation requires getMenuData and clearMenuItem function e.g. const { menuData } = getMenuData(clearMenuItem(routes))

PageContainer

PropertyDescriptionTypeDefault Value
contentContent areaVNode | v-slot-
extraExtra content area, on the right side of contentVNode | v-slot-
extraContentExtra content area, on the right side of contentVNode | v-slot-
tabListTabs title listArray<{key: string, tab: sting}>-
tab-changeSwitch panel callback(key) => void-
tab-active-keyThe currently highlighted tab itemstring-
breadcrumbShow Bread crumbs barBoolean-

WaterMark

PropertyDescriptionTypeDefault Value
markStylemark styleCSSProperties-
markClassNamemark classstring-
gapXHorizontal spacing between water-marknumber212
gapYVertical spacing between watermarknumber222
offsetLeftHorizontal offsetnumberoffsetTop = gapX / 2
offsetTopVertical offsetnumberoffsetTop = gapY / 2
widthnumber120
heightnumber64
rotateAngle of rotation, unit °number-22
imageimage srcstring-
zIndexwater-mark z-indexnumber9
contentwater-mark Contentstring-
fontColorfont-colorstringrgba(0,0,0,.15)
fontSizefont-sizestring|number16

Custom Render

Custom rightContentRender
<template #rightContentRender>
  <div style="margin-right: 12px">
    <a-avatar shape="square" size="small">
      <template #icon>
        <UserOutlined />
      </template>
    </a-avatar>
  </div>
</template>
Custom menu.item
<template #menuItemRender="{ item, icon }">
  <a-menu-item
    :key="item.path"
    :disabled="item.meta?.disabled"
    :danger="item.meta?.danger"
    :icon="icon"
  >
    <router-link :to="{ path: item.path }">
      <span class="ant-pro-menu-item">
        <a-badge count="5" dot>
          <span class="ant-pro-menu-item-title">{{ item.meta.title }}</span>
        </a-badge>
      </span>
    </router-link>
  </a-menu-item>
</template>
Custom menuExtraRender
<template #menuExtraRender="{ collapsed }">
  <a-input-search v-if="!collapsed" />
</template>
Custom menuFooterRender
<template #menuFooterRender>
  <div>menu footer</div>
</template>
Custom breadcrumbRender
<template #breadcrumbRender="{ route, params, routes }">
  <span v-if="routes.indexOf(route) === routes.length - 1">
    {{ route.breadcrumbName }}
  </span>
  <router-link v-else :to="{ path: route.path, params }">
    {{ route.breadcrumbName }}
  </router-link>
</template>
Custom collapsedButtonRender
<template #collapsedButtonRender="collapsed">
  <HeartOutlined v-if="collapsed" />
  <SmileOutlined v-else />
</template>
Custom tabRender
<template #tabRender="{ width, fixedHeader }">
  <div>
    <header
      class="ant-layout-header"
      style="height: 36px; line-height: 36px; background: transparent"
      v-if="fixedHeader"
    ></header>
    <div
      :style="{
        margin: '0',
        height: '36px',
        lineHeight: '36px',
        right: '0px',
        top: '48px',
        position: fixedHeader ? 'fixed' : 'unset',
        zIndex: 14,
        padding: '4px 16px',
        width: width,
        background: '#fff',
        boxShadow: '0 1px 4px #0015291f',
        transition: 'background 0.3s, width 0.2s',
      }"
    >
      tabRender fixedHeader:{{fixedHeader}} width:{{ width }} 
    </div>
  </div>
</template>
<template #footerRender="{ width, headerTheme }">
  <div>
    <footer class="ant-layout-footer" style="height: 36px; line-height: 36px; background: transparent"></footer>
    <div
      :style="{
        margin: '0',
        height: '36px',
        lineHeight: '36px',
        right: '0px',
        bottom: '0px',
        position: headerTheme == 'dark' ? 'fixed' : 'unset',
        zIndex: 14,
        padding: '4px 16px',
        width: width,
        background: '#fff',
        boxShadow: '0 1px 4px #0015291f',
        transition: 'background 0.3s, width 0.2s'
      }"
    >
      footerRender headerTheme:{{ headerTheme }} width:{{ width }}
    </div>
  </div>
</template>
<GlobalFooter
  :links="[
    { title: 'Link 1', href: '#' },
    { title: 'Link 2', href: '#' },
  ]"
  copyright="Pro Layout &copy; 2021 Sendya."
/>

Use WaterMark

<router-view v-slot="{ Component }">
  <WaterMark content="Pro Layout">
    <component :is="Component" />
  </WaterMark>
</router-view>

Build project

pnpm build # Build library and .d.ts

FAQs

Package last updated on 21 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc