@molecule/app-announcement-bar-vue
Feature · announcement-bar · App (browser) · v1.1.1 · Apache-2.0
Persistent banner for announcements, promos, feature callouts, with dismiss + CTA
npm install @molecule/app-announcement-bar-vueHow it works
@molecule/app-announcement-bar-vue is a ready-made announcement-bar feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { createApp, defineComponent, h } from 'vue'
import { moleculePlugin } from '@molecule/app-vue'
import { AnnouncementBar } from '@molecule/app-announcement-bar-vue'
const App = defineComponent({
setup() {
return () =>
h(
AnnouncementBar,
{
kind: 'promo',
icon: h('span', {}, '🎉'),
action: { label: 'Learn more', href: '/pricing' },
onDismiss: () => console.log('dismissed'),
dataMolId: 'promo-bar',
},
{ default: () => ['New Pro plan — 3 months free for early adopters.'] },
)
},
})
const app = createApp(App)
app.use(moleculePlugin, { i18n: i18nProvider })
app.mount('#app')Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue announcement / promo bar.
Exports <AnnouncementBar> — persistent top-of-page banner with icon,
message, optional action (link or button), and optional dismiss (×).
Long-lived and prominent, unlike a Toast; carries an action slot +
dismiss, unlike an Alert. It is the Vue counterpart of
@molecule/app-announcement-bar-react: same props (React names), same DOM
for the same input, same ClassMap tokens and i18n keys.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { moleculePlugin } from '@molecule/app-vue'
import { AnnouncementBar } from '@molecule/app-announcement-bar-vue'
const App = defineComponent({
setup() {
return () =>
h(
AnnouncementBar,
{
kind: 'promo',
icon: h('span', {}, '🎉'),
action: { label: 'Learn more', href: '/pricing' },
onDismiss: () => console.log('dismissed'),
dataMolId: 'promo-bar',
},
{ default: () => ['New Pro plan — 3 months free for early adopters.'] },
)
},
})
const app = createApp(App)
app.use(moleculePlugin, { i18n: i18nProvider })
app.mount('#app')
Type
feature
Installation
npm install @molecule/app-announcement-bar-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
AnnouncementBarProps
Props accepted by the AnnouncementBar component.
interface AnnouncementBarProps {
/** Primary message — the DEFAULT slot (also accepted as a `children` prop). */
children?: VNodeChild
/** Optional leading icon. Passed as a prop or as the same-named slot — both work. */
icon?: VNodeChild
/** Optional call-to-action (link or button). */
action?: {
/** The action's label — a string, or a node. */
label: VNodeChild
/** Rendering as a link: the action is an `<a href>` instead of a `<button>`. */
href?: string
/**
* Called when the action button is clicked (ignored when `href` is set).
* React's DOM click handler receives the click event, so the callback may
* take it.
*/
onClick?: (event?: MouseEvent) => void
}
/** Semantic kind — emitted as `data-kind` on the root (style via CSS/`className`). Defaults to `'info'`. */
kind?: AnnouncementKind
/** Show a dismiss (×) button. Defaults to true. */
dismissible?: boolean
/** Called when the bar is dismissed. */
onDismiss?: () => void
/** Controlled visibility — when provided, overrides internal state. */
visible?: boolean
/** Extra classes. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
}
Types
AnnouncementKind
Semantic kind, exposed as a data-kind attribute for per-kind styling (no built-in style change).
type AnnouncementKind = 'info' | 'success' | 'warning' | 'error' | 'promo'
Constants
AnnouncementBar
Persistent announcement banner — product updates, promos, outage
notices, feature callouts. Different from <Toast> in being
long-lived and prominent (top-of-page), and from <Alert> in
including an action slot + dismiss.
Dismissal is uncontrolled by default (internal state) — pass visible to
control it. kind is exposed as data-kind only; it does not change the
bar's colors by itself.
const AnnouncementBar: DefineComponent<
ExtractPropTypes<{
children: null
icon: null
action: {
type: PropType<NonNullable<AnnouncementBarProps['action']> | null>
default: undefined
}
kind: { type: PropType<AnnouncementKind>; default: string }
dismissible: { type: PropType<boolean>; default: boolean }
onDismiss: { type: PropType<() => void>; default: undefined }
visible: { type: PropType<boolean | undefined>; default: undefined }
className: StringConstructor
dataMolId: StringConstructor
}>,
() => VNodeChild,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
children: null
icon: null
action: {
type: PropType<NonNullable<AnnouncementBarProps['action']> | null>
default: undefined
}
kind: { type: PropType<AnnouncementKind>; default: string }
dismissible: { type: PropType<boolean>; default: boolean }
onDismiss: { type: PropType<() => void>; default: undefined }
visible: { type: PropType<boolean | undefined>; default: undefined }
className: StringConstructor
dataMolId: StringConstructor
}>
> &
Readonly<{}>,
{
action: { label: VNodeChild; href?: string; onClick?: (event?: MouseEvent) => void } | null
kind: AnnouncementKind
dismissible: boolean
onDismiss: () => void
visible: boolean | undefined
},
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeAnnouncementBarProps).
Returns: The announcement bar component, or nothing while hidden.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.5.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
kind is exposed as a data-kind attribute on the root — it does NOT
change the bar's colors by itself; style per-kind via className or a
[data-kind="…"] selector. Dismissal is uncontrolled by default
(internal state; the bar stays hidden until remount) — pass visible
to control it, e.g. to persist dismissal per user. dismissible
defaults to true. There is no default data-mol-id; pass dataMolId
so agents/E2E can target the bar. Node-valued props arrive as a prop AND
a same-named slot; components accept either. Translations come from the
companion @molecule/app-locales-announcement-bar locale bond.
Translations
Translation strings are provided by @molecule/app-locales-announcement-bar.