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

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.

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

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

Usage

Basic Usage

<van-notice-bar
  text="Technology is the common soul of the people who developed it."
  left-icon="volume-o"
/>

Scrollable

<!-- Enable scroll when text is short -->
<van-notice-bar scrollable text="Short Content" />

<!-- Disable scroll when text is long -->
<van-notice-bar
  :scrollable="false"
  text="Technology is the common soul of the people who developed it."
/>

Wrapable

<van-notice-bar wrapable :scrollable="false">
  Technology is the common soul of the people who developed it.
</van-notice-bar>

Mode

<van-notice-bar mode="closeable">Short Content</van-notice-bar>

<van-notice-bar mode="link">Short Content</van-notice-bar>

Custom Style

<van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o">
  Short Content
</van-notice-bar>

Vertical Scroll

<van-notice-bar left-icon="volume-o" :scrollable="false">
  <van-swipe
    vertical
    class="notice-swipe"
    :autoplay="3000"
    :touchable="false"
    :show-indicators="false"
  >
    <van-swipe-item>Content 1</van-swipe-item>
    <van-swipe-item>Content 2</van-swipe-item>
    <van-swipe-item>Content 3</van-swipe-item>
  </van-swipe>
</van-notice-bar>

<style>
  .notice-swipe {
    height: 40px;
    line-height: 40px;
  }
</style>

API

Props

AttributeDescriptionTypeDefault
modeMode, can be set to closeable linkstring''
textNotice text contentstring''
colorText colorstring#ed6a0c
backgroundBackground colorstring#fffbe8
left-iconLeft Iconstring-
delayAnimation delay (s)number | string1
speedScroll speed (px/s)number | string60
scrollableWhether to scroll contentboolean-
wrapableWhether to enable text wrapbooleanfalse

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
reset v3.1.1Reset NoticeBar--

Types

The component exports the following type definitions:

import type { NoticeBarMode, NoticeBarProps, NoticeBarInstance } from 'vant';

NoticeBarInstance is the type of component instance:

import { ref } from 'vue';
import type { 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-background-colorvar(--van-orange-light)-
--van-notice-bar-icon-size16px-
--van-notice-bar-icon-min-width24px-
`,18),d=[l],h={__name:"README",setup(c,{expose:s}){return s({frontmatter:{}}),(p,r)=>(t(),a("div",e,d))}};export{h as default};