An inline notice: an icon, a message, and an optional action, such as "The 24-hour reply window has closed". For a passing confirmation, use a toast (planned).
Installation
bun add @harmo-ui/css @harmo-ui/react
npm install @harmo-ui/css @harmo-ui/react
pnpm add @harmo-ui/css @harmo-ui/react
yarn add @harmo-ui/css @harmo-ui/react
bunx harmo-ui add banner
npx harmo-ui add banner
pnpm dlx harmo-ui add banner
yarn dlx harmo-ui add banner
Usage
import { Banner, Button } from "@harmo-ui/react";import { WarningIcon } from "./icons";<Banner status="warning" icon={<WarningIcon />} action={ <Button variant="secondary" size="small"> Send template </Button> }> The 24-hour reply window has closed. Send a template to reply.</Banner>
data-status colors the icon. info is the default, so the first banner leaves it out. Any SVG drawn in currentColor takes the color.
Translation settings apply to new conversations only.
Your WhatsApp number is connected and ready to send.
Your message quality is low. Fewer people will receive your campaigns.
We couldn't reach WhatsApp. Check the connection in your business settings.
<> <Banner icon={<InfoIcon />}> Translation settings apply to new conversations only. </Banner> <Banner status="success" icon={<SuccessIcon />}> Your WhatsApp number is connected and ready to send. </Banner> <Banner status="warning" icon={<WarningIcon />}> Your message quality is low. Fewer people will receive your campaigns. </Banner> <Banner status="error" icon={<ErrorIcon />}> We couldn't reach WhatsApp. Check the connection in your business settings. </Banner></>
The banners above are on the page from the start, so they have no role. One shown later must announce itself: role="alert" when it's urgent, as here, or role="status" when it can wait. Keep it in the page with hidden and remove that to show it. Press Send message.
The message wasn't sent. Check your connection and try again.
<Banner> renders the banner, with its children as the message. Other props are the <div>'s attributes, such as role="alert" for a banner shown after the page loads.
Prop
Effect
icon
The icon, as an element, such as <WarningIcon /> from your app; Banner adds .hbanner-icon to its className and hides it from screen readers
status
success, warning, info, or error; info when left out
action
Placed after the message, such as a small secondary <Button>
HTML
A <div class="hbanner"> holding an .hbanner-icon, with aria-hidden="true" and focusable="false", a .hbanner-message, and optionally a small secondary Button. Draw the icon with fill="currentColor" or stroke="currentColor"; the banner colors it. Load banner.css; button.css for an action. It needs no script.
Hook
Effect
data-status="info", or none
Icon in --harmo-status-color-info
data-status="success"
Icon in --harmo-status-color-success
data-status="warning"
Icon in --harmo-status-color-warning
data-status="error"
Icon in --harmo-status-color-error
A direct .hbutton with data-variant="secondary"
The action; on hover its background fills and its border stays put
A banner present when the page loads needs no role. One added later announces itself: role="status" when it can wait for the current speech, role="alert" when it's urgent, such as an error that blocks the task.