@molecule/app-announcement-bar-solid

Feature · announcement-bar · App (browser) · v1.1.2 · Apache-2.0

Persistent banner for announcements, promos, feature callouts, with dismiss + CTA

npm install @molecule/app-announcement-bar-solid

npm · Source on GitHub

How it works

@molecule/app-announcement-bar-solid 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 { render } from 'solid-js/web'
import { MoleculeProvider } from '@molecule/app-solid'
import { AnnouncementBar } from '@molecule/app-announcement-bar-solid'

render(
  () => (
    <MoleculeProvider i18n={i18nProvider}>
      <AnnouncementBar
        kind="promo"
        icon={<span>🎉</span>}
        action={{ label: 'Learn more', href: '/pricing' }}
        onDismiss={() => console.log('dismissed')}
        dataMolId="promo-bar"
      >
        New Pro plan — 3 months free for early adopters.
      </AnnouncementBar>
    </MoleculeProvider>,
  ),
  document.getElementById('root')!,
)

Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid

Reference

Solid 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 Solid 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.ts JSDoc, not this file.

Quick Start

import { render } from 'solid-js/web'
import { MoleculeProvider } from '@molecule/app-solid'
import { AnnouncementBar } from '@molecule/app-announcement-bar-solid'

render(
  () => (
    <MoleculeProvider i18n={i18nProvider}>
      <AnnouncementBar
        kind="promo"
        icon={<span>🎉</span>}
        action={{ label: 'Learn more', href: '/pricing' }}
        onDismiss={() => console.log('dismissed')}
        dataMolId="promo-bar"
      >
        New Pro plan — 3 months free for early adopters.
      </AnnouncementBar>
    </MoleculeProvider>,
  ),
  document.getElementById('root')!,
)

Type

feature

Installation

npm install @molecule/app-announcement-bar-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js

API

Interfaces

AnnouncementBarProps

Props accepted by the AnnouncementBar component.

interface AnnouncementBarProps {
  /** Primary message. */
  children: JSX.Element
  /** Optional leading icon. */
  icon?: JSX.Element
  /** Optional call-to-action (link or button). */
  action?: {
    /** The action's label — a string, or a node. */
    label: JSX.Element
    /** 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'

Functions

AnnouncementBar(props)

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.

This is the Solid counterpart of @molecule/app-announcement-bar-react: the same props (React names), the same ClassMap tokens, the same i18n keys, and the same DOM for the same input.

function AnnouncementBar(props: AnnouncementBarProps): JSX.Element
  • props — Component props (see AnnouncementBarProps).

Returns: The rendered announcement bar, or nothing while hidden.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-solid ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-solid ^1.1.0
  • solid-js ^1.8.0

Runtime Dependencies

  • @molecule/app-solid
  • @molecule/app-ui
  • @molecule/app-ui-solid
  • solid-js

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. Translations come from the companion @molecule/app-locales-announcement-bar locale bond.

Translations

Translation strings are provided by @molecule/app-locales-announcement-bar.