Skip to content

NoticeBar - Vant 4

NoticeBar

Intro

Used to display a group of message notifications in a continuons loop.

Install

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

js
import { createApp } from'vue'; import { NoticeBar } from'vant'; const app = createApp(); app.use(NoticeBar);

Usage

Basic Usage

html

Scrollable

html

Wrapable

html

Mode

html

Custom Style

html

Vertical Scroll

html

API

Props

AttributeDescriptionTypeDefault
modeMode, can be set to closeable``linkstring''
textNotice text contentstring''
colorText colorstring#ed6a0c

| background | Background color | string | #fffbe8 |

| left-icon | Left Icon | string | - | | delay | Animation delay (s) | number | string | 1 | | speed | Scroll speed (px/s) | number | string | 60 | | scrollable | Whether to scroll content | boolean | - | | wrapable | Whether to enable text wrap | boolean | false |

Events

EventDescriptionArguments
clickEmitted when NoticeBar is clickedevent: MouseEvent
closeEmitted when NoticeBar is closedevent: MouseEvent
replayEmitted when NoticeBar is replayed-

Methods

Use ref to get NoticeBar instance and call instance methods.

NameDescriptionAttributeReturn value
resetReset NoticeBar--

Types

The component exports the following type definitions:

ts
importtype { NoticeBarMode, NoticeBarProps, NoticeBarInstance } from'vant';

NoticeBarInstance is the type of component instance:

ts
import { ref } from'vue'; importtype { NoticeBarInstance } from'vant'; const noticeBarRef = ref<NoticeBarInstance>(); noticeBarRef.value?.reset();

Slots

NameDescription
defaultNotice text content
left-iconCustom left icon
right-iconCustom right icon

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-notice-bar-height40px-
--van-notice-bar-padding0 var(--van-padding-md)-
--van-notice-bar-wrapable-paddingvar(--van-padding-xs) var(--van-padding-md)-
--van-notice-bar-text-colorvar(--van-orange-dark)-
--van-notice-bar-font-sizevar(--van-font-size-md)-
--van-notice-bar-line-height24px-
--van-notice-bar-backgroundvar(--van-orange-light)-
--van-notice-bar-icon-size16px-
--van-notice-bar-icon-min-width24px-

Enterprise-level mobile solution based on Vant