Skip to content
API 风格:

NoticeBar ​

Marquee announcement bar. All scrolling geometry (line splitting, overflow detection, duration from speed, seamless-loop duplication) comes from the pure functions in @lh-ui/share/core/notice-bar; the web rendering layer prefers a CSS animation (@keyframes translating -50% for a seamless loop) and automatically falls back to a rAF-driven loop when CSS animation is unavailable.

Basic Usage ​

text is the announcement (the bar scrolls only when the content overflows; otherwise it sits statically on the left). mode="none" forces a static bar:

Basic Usage
During the Spring Festival holiday (Jan 28 - Feb 4), customer service is available 9:00-18:00 and shipments resume on the first working day after the holiday.
vue
<script setup lang="ts">
import { LhNoticeBar } from '@lh-ui/vue3'
</script>

<template>
  <!-- Basic usage -->
  <LhNoticeBar text="During the Spring Festival holiday, customer service is available 9:00-18:00 and shipments resume after the holiday." />
</template>
vue
<script>
import { LhNoticeBar } from '@lh-ui/vue3'

export default {
  components: { LhNoticeBar },
}
</script>

<template>
  <!-- Basic usage -->
  <LhNoticeBar text="During the Spring Festival holiday, customer service is available 9:00-18:00 and shipments resume after the holiday." />
</template>

Multiple Lines and Speed ​

When the text uses \n as a separator the lines are played one by one: each completed loop emits replay and switches to the next line (empty lines are filtered out). speed is the scroll speed in px/s (default 60) and delay is the first-play delay in ms (default 1000):

Multiple Lines and Speed
First: 20% off everything on Member Day\nSecond: 30 off your first order\nThird: extra loyalty points in the app
vue
<script setup lang="ts">
import { LhNoticeBar } from '@lh-ui/vue3'
</script>

<template>
  <!-- Multiple lines and speed -->
  <LhNoticeBar
    text="First: 20% off everything on Member Day\nSecond: 30 off your first order\nThird: extra loyalty points in the app"
    :speed="80"
  />
</template>
vue
<script>
import { LhNoticeBar } from '@lh-ui/vue3'

export default {
  components: { LhNoticeBar },
}
</script>

<template>
  <!-- Multiple lines and speed -->
  <LhNoticeBar
    text="First: 20% off everything on Member Day\nSecond: 30 off your first order\nThird: extra loyalty points in the app"
    :speed="80"
  />
</template>

Icon and Close ​

leftIcon takes an lh-icon name (the announcement icon); closeable renders a close button on the right which emits close and unmounts the bar (it reappears when the text changes):

Icon and Close
This site has completed ICP filing; see the footer for details.
vue
<script setup lang="ts">
import { LhNoticeBar } from '@lh-ui/vue3'
</script>

<template>
  <!-- Icon and close -->
  <LhNoticeBar text="This site has completed ICP filing; see the footer for details." left-icon="notification" closeable />
</template>
vue
<script>
import { LhNoticeBar } from '@lh-ui/vue3'

export default {
  components: { LhNoticeBar },
}
</script>

<template>
  <!-- Icon and close -->
  <LhNoticeBar text="This site has completed ICP filing; see the footer for details." left-icon="notification" closeable />
</template>

API ​

NoticeBar Props ​

PropDescriptionTypeDefault
textAnnouncement text (\n splits multiple lines which are played one by one)string—
modePlay mode (roll marquee / none static)'roll' | 'none''roll'
speedScroll speed (px/s)number60
delayFirst-play delay (ms)number1000
closeableClose button on the rightbooleanfalse
leftIconLeft announcement icon namestring—
labelAccessible name (defaults to "lh-notice-bar")string—
sxsx quick-layout propsLhSxProps—

NoticeBar Events ​

EventDescriptionCallback
closeClose button click (the bar hides itself)—
replayEmitted after every completed loop; with multiple lines the next line is switched to—

Accessibility ​

  • The root aria-label defaults to a fixed label and can be overridden with label; the announcement text itself is what screen readers read
  • The close button is a real <button> whose aria-label is the locale word for "close"
  • No scrolling happens when the content does not overflow, avoiding pointless animation

Beauty of tradition, foundation of code