/*! For license information please see 9345.210bd0b9.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["9345"],{57672:function(t,n,s){"use strict";s.r(n);var a=s("80681");let e=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

NavBar

\n

Intro

\n

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

\n

Install

\n

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

\n
import { createApp } from 'vue';\nimport { NavBar } from 'vant';\n\nconst app = createApp();\napp.use(NavBar);\n
\n

Usage

\n

Basic Usage

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

Back

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

Right Button

\n
<van-nav-bar\n  title="Title"\n  left-text="Back"\n  right-text="Button"\n  left-arrow\n  @click-left="onClickLeft"\n  @click-right="onClickRight"\n/>\n
\n
import { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const onClickLeft = () => history.back();\n    const onClickRight = () => showToast('Button');\n    return {\n      onClickLeft,\n      onClickRight,\n    };\n  },\n};\n
\n

Use Slot

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

Disable Button

\n

Use the left-disabled or right-disabled props to disable the buttons on either side. The prop reduces the opacity of the button and makes it unclickable.

\n
<van-nav-bar\n  title="Title"\n  left-text="Back"\n  right-text="Button"\n  left-arrow\n  left-disabled\n  right-disabled\n/>\n
\n

API

\n

Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionTypeDefault
titleTitlestring\'\'
left-textLeft Textstring\'\'
right-textRight Textstring\'\'
left-disabled v4.6.8Whether to disable the left button, decrease opacity and make it unclickablebooleanfalse
right-disabled v4.6.8Whether to disable the right button, decrease opacity and make it unclickablebooleanfalse
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
clickableWhether to show click feedback when the left or right content is clickedbooleantrue
\n

Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescription
titleCustom title
leftCustom left side content
rightCustom right side content
\n

Events

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

Types

\n

The component exports the following type definitions:

\n
import type { NavBarProps } from 'vant';\n
\n

Theming

\n

CSS Variables

\n

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

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDefault ValueDescription
--van-nav-bar-height46px-
--van-nav-bar-backgroundvar(--van-background-2)-
--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-
\n
'},null,8,e))}}}]);