import{o as s,a,y as n}from"./vue-libs.b44bc779.js";const e={class:"van-doc-markdown-body"},l=n(`

NavBar

Intro

Provide navigation function for the page, often used at the top of the page.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

import { createApp } from 'vue';
import { NavBar } from 'vant';

const app = createApp();
app.use(NavBar);

Usage

Basic Usage

<van-nav-bar title="Title" />

Back

<van-nav-bar
  title="Title"
  left-text="Back"
  left-arrow
  @click-left="onClickLeft"
/>
export default {
  setup() {
    const onClickLeft = () => history.back();
    return {
      onClickLeft,
    };
  },
};

Right Button

<van-nav-bar
  title="Title"
  left-text="Back"
  right-text="Button"
  left-arrow
  @click-left="onClickLeft"
  @click-right="onClickRight"
/>
import { Toast } from 'vant';

export default {
  setup() {
    const onClickLeft = () => history.back();
    const onClickRight = () => Toast('Button');
    return {
      onClickLeft,
      onClickRight,
    };
  },
};

Use Slot

<van-nav-bar title="Title" left-text="Back" left-arrow>
  <template #right>
    <van-icon name="search" />
  </template>
</van-nav-bar>

API

Props

AttributeDescriptionTypeDefault
titleTitlestring''
left-textLeft Textstring''
right-textRight Textstring''
left-arrowWhether to show left arrowbooleanfalse
borderWhether to show bottom borderbooleantrue
fixedWhether to fixed topbooleanfalse
placeholderWhether to generate a placeholder element when fixedbooleanfalse
z-indexZ-indexnumber | string1
safe-area-inset-topWhether to enable top safe area adaptationbooleanfalse

Slots

NameDescription
titleCustom title
leftCustom left side content
rightCustom right side content

Events

EventDescriptionArguments
click-leftEmitted when the left button is clickedevent: MouseEvent
click-rightEmitted when the right button is clickedevent: MouseEvent

Types

The component exports the following type definitions:

import type { NavBarProps } from 'vant';

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-nav-bar-height46px-
--van-nav-bar-background-colorvar(--van-background-color-light)-
--van-nav-bar-arrow-size16px-
--van-nav-bar-icon-colorvar(--van-primary-color)-
--van-nav-bar-text-colorvar(--van-primary-color)-
--van-nav-bar-title-font-sizevar(--van-font-size-lg)-
--van-nav-bar-title-text-colorvar(--van-text-color)-
--van-nav-bar-z-index1-
`,15),d=[l],h={__name:"README",setup(r,{expose:t}){return t({frontmatter:{}}),(c,p)=>(s(),a("div",e,d))}};export{h as default};