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

ActionBar

Intro

Used to provide convenient interaction for page-related operations.

Install

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

import { createApp } from 'vue';
import { ActionBar, ActionBarIcon, ActionBarButton } from 'vant';

const app = createApp();
app.use(ActionBar);
app.use(ActionBarIcon);
app.use(ActionBarButton);

Usage

Basic Usage

<van-action-bar>
  <van-action-bar-icon icon="chat-o" text="Icon1" @click="onClickIcon" />
  <van-action-bar-icon icon="cart-o" text="Icon2" @click="onClickIcon" />
  <van-action-bar-icon icon="shop-o" text="Icon3" @click="onClickIcon" />
  <van-action-bar-button type="danger" text="Button" @click="onClickButton" />
</van-action-bar>
import { Toast } from 'vant';

export default {
  setup() {
    const onClickIcon = () => Toast('Click Icon');
    const onClickButton = () => Toast('Click Button');
    return {
      onClickIcon,
      onClickButton,
    };
  },
};

Icon Badge

Use badge prop to show badge in icon.

<van-action-bar>
  <van-action-bar-icon icon="chat-o" text="Icon1" dot />
  <van-action-bar-icon icon="cart-o" text="Icon2" badge="5" />
  <van-action-bar-icon icon="shop-o" text="Icon3" badge="12" />
  <van-action-bar-button type="warning" text="Button" />
  <van-action-bar-button type="danger" text="Button" />
</van-action-bar>

Custom Icon Color

<van-action-bar>
  <van-action-bar-icon icon="chat-o" text="Icon1" color="#ee0a24" />
  <van-action-bar-icon icon="cart-o" text="Icon2" />
  <van-action-bar-icon icon="star" text="Collected" color="#ff5000" />
  <van-action-bar-button type="warning" text="Button" />
  <van-action-bar-button type="danger" text="Button" />
</van-action-bar>

Custom Button Color

<van-action-bar>
  <van-action-bar-icon icon="chat-o" text="Icon1" />
  <van-action-bar-icon icon="shop-o" text="Icon2" />
  <van-action-bar-button color="#be99ff" type="warning" text="Button" />
  <van-action-bar-button color="#7232dd" type="danger" text="Button" />
</van-action-bar>

API

ActionBar Props

AttributeDescriptionTypeDefault
safe-area-inset-bottomWhether to enable bottom safe area adaptationbooleantrue
placeholder v3.5.1Whether to generate a placeholder elementbooleanfalse

ActionBarIcon Props

AttributeDescriptionTypeDefault
textButton textstring-
iconIconstring-
colorIcon colorstring#323233
icon-classIcon class namestring | Array | object''
icon-prefix v3.0.17Icon className prefixstringvan-icon
dotWhether to show red dotboolean-
badgeContent of the badgenumber | string-
badge-props v3.2.8Props of Badge, see Badge - propsBadgeProps-
urlLink URLstring-
toTarget route of the link, same as to of vue-routerstring | object-
replaceIf true, the navigation will not leave a history recordbooleanfalse

ActionBarButton Props

AttributeDescriptionTypeDefault
textButton textstring-
typeButton type, Can be set to primary info warning dangerstringdefault
colorButton color, support linear-gradientstring-
iconLeft Iconstring-
disabledWhether to disable buttonbooleanfalse
loadingWhether to show loading statusbooleanfalse
urlLinkstring-
toTarget route of the link, same as to of vue-routerstring | object-
replaceIf true, the navigation will not leave a history recordbooleanfalse

ActionBarIcon Slots

NameDescription
defaultText
iconCustom icon

ActionBarButton Slots

NameDescription
defaultButton content

Types

The component exports the following type definitions:

import type {
  ActionBarProps,
  ActionBarIconProps,
  ActionBarButtonProps,
} 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-action-bar-background-colorvar(--van-background-color-light)-
--van-action-bar-height50px-
--van-action-bar-icon-width48px-
--van-action-bar-icon-height100%-
--van-action-bar-icon-colorvar(--van-text-color)-
--van-action-bar-icon-size18px-
--van-action-bar-icon-font-sizevar(--van-font-size-xs)-
--van-action-bar-icon-active-colorvar(--van-active-color)-
--van-action-bar-icon-text-colorvar(--van-gray-7)-
--van-action-bar-icon-background-colorvar(--van-background-color-light)-
--van-action-bar-button-height40px-
--van-action-bar-button-warning-colorvar(--van-gradient-orange)-
--van-action-bar-button-danger-colorvar(--van-gradient-red)-
`,17),c=[l],h={__name:"README",setup(e,{expose:t}){return t({frontmatter:{}}),(p,r)=>(s(),a("div",o,c))}};export{h as default};