NavBar navigation bar

introduce

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

Code Demo

Basic usage

Set the navigation bar title through the title attribute.

<z-nav-bar title="title" />

Return to previous page

Implement the return to previous function in the navigation bar.

<z-nav-bar title="Title" left-text="Return" left-arrow />

Right button

Add a clickable button to the right of the navigation bar.

<z-nav-bar
   title="title"
   left-text="Return"
   right-text="Button"
   left-arrow
   @click-right="toast.showToast('button')"
/>
import { useToast } from '../../uni_modules/zebra-ui'
const toast = useToast()

Using slots

The content on either side of the navigation bar can be customized via slots.

<z-nav-bar title="Title" left-text="Return" left-arrow>
   <template #right>
     <z-icon name="search" size="18" />
   </template>
</z-nav-bar>

Disable button

Disable buttons on both sides via the left-disabled or right-disabled properties. When a button is disabled, its transparency is reduced and it cannot be clicked.

<z-nav-bar
   title="title"
   left-text="Return"
   right-text="Button"
   left-arrow
   left-disabled
   right-disabled
/>

API

Props

ParametersDescriptionTypeDefault value
titletitlestring''
left-textleft copystring''
right-textright side copystring''
left-disabledWhether to disable the left button. When disabled, the transparency is reduced and cannot be clickedbooleanfalse
right-disabledWhether to disable the right button. When disabled, the transparency is reduced and cannot be clickedbooleanfalse
left-arrowWhether to display the left arrowbooleanfalse
borderWhether to display the bottom borderbooleantrue
fixedWhether to be fixed at the topbooleanfalse
placeholderWhether to generate a placeholder element of equal height at the label position when fixed at the topbooleanfalse
z-indexNavigation bar z-indexnumber | string1
safe-area-inset-topWhether to enable top safe area adaptationbooleanfalse
clickableWhether to enable click feedback for buttons on both sidesbooleantrue

Slots

NameDescription
titlecustom title
leftCustomize left area content
rightCustomize the content of the right area

Events

Event nameDescriptionCallback parameters
click-leftTriggered when the left button is clickedevent: MouseEvent
click-rightTriggered when the right button is clickedevent: MouseEvent

Theme customization

Style variables

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

NameDefaultDescription
--z-nav-bar-height92rpx-
--z-nav-bar-backgroundvar(--z-background-2)-
--z-nav-bar-arrow-size32rpx-
--z-nav-bar-icon-colorvar(--z-primary-color)-
--z-nav-bar-text-colorvar(--z-primary-color)-
--z-nav-bar-title-font-sizevar(--z-font-size-lg)-
--z-nav-bar-title-text-colorvar(--z-text-color)-
--z-nav-bar-z-index1-