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:
<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><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):
<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><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):
<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><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
| Prop | Description | Type | Default |
|---|---|---|---|
| text | Announcement text (\n splits multiple lines which are played one by one) | string | — |
| mode | Play mode (roll marquee / none static) | 'roll' | 'none' | 'roll' |
| speed | Scroll speed (px/s) | number | 60 |
| delay | First-play delay (ms) | number | 1000 |
| closeable | Close button on the right | boolean | false |
| leftIcon | Left announcement icon name | string | — |
| label | Accessible name (defaults to "lh-notice-bar") | string | — |
| sx | sx quick-layout props | LhSxProps | — |
NoticeBar Events
| Event | Description | Callback |
|---|---|---|
| close | Close button click (the bar hides itself) | — |
| replay | Emitted after every completed loop; with multiple lines the next line is switched to | — |
Accessibility
- The root
aria-labeldefaults to a fixed label and can be overridden withlabel; the announcement text itself is what screen readers read - The close button is a real
<button>whosearia-labelis the locale word for "close" - No scrolling happens when the content does not overflow, avoiding pointless animation

