import { Link } from "@senvenli/react/action";
import { Banner } from "@senvenli/react/feedback";
export default function Example() {
return (
<Banner
title="Your trial ends in 3 days"
actions={
<>
<Link href="#plans">Choose a plan</Link>
<Link href="#compare">Compare plans</Link>
</>
}
>
Add a payment method to keep your projects and invoices after March 21.
</Banner>
);
}import { Banner } from "@senvenli/react/feedback";Examples
Tones
The icon and the title say the status; a danger banner is announced as an alert.import { Link } from "@senvenli/react/action";
import { Banner } from "@senvenli/react/feedback";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack space="space-150">
<Banner tone="success" title="Bank account verified">
Payouts start with your next invoice.
</Banner>
<Banner tone="warning" title="Storage is almost full">
You have used 46 of 50 GB. Remove files or upgrade to keep uploading.
</Banner>
<Banner tone="danger" title="Payment failed" actions={<Link href="#billing">Update payment method</Link>}>
We could not charge the card ending in 4242. Update it to keep your plan.
</Banner>
</Stack>
);
}Dismissible
`onDismiss` adds the close button. Leave it out for errors that must be resolved.import { Button } from "@senvenli/react/action";
import { Banner } from "@senvenli/react/feedback";
import { useState } from "react";
export default function Example() {
const [isOpen, setOpen] = useState(true);
if (!isOpen) return <Button onPress={() => setOpen(true)}>Show the banner again</Button>;
return (
<Banner title="Invoices have a new layout" onDismiss={() => setOpen(false)} dismissLabel="Close the layout notice">
Totals and tax now sit at the top of every invoice.
</Banner>
);
}Floating
Pinned to the bottom of the viewport until the visitor acts on it, like a cookie notice.import { Button } from "@senvenli/react/action";
import { Banner } from "@senvenli/react/feedback";
import { useState } from "react";
export default function Example() {
const [isOpen, setOpen] = useState(false);
return (
<>
<Button onPress={() => setOpen(true)} isDisabled={isOpen}>Show the cookie notice</Button>
{isOpen && (
<Banner
placement="floating"
aria-label="Cookie notice"
icon="cookie"
title="We use cookies"
actions={<Button onPress={() => setOpen(false)}>Accept</Button>}
onDismiss={() => setOpen(false)}
dismissLabel="Close cookie notice"
>
They keep you signed in and show us which pages are used.
</Banner>
)}
</>
);
}Guidelines
When to use it
- Telling people something about this page that they need to read or act on.
Use something else when
- Only an item's status needs showing. Badge
Do and avoid
- Say why and what to do; omit the close button for errors that must be resolved.
Accessibility
Built in
- Announced with the right urgency for its tone.
- The close button is named "Close" or your
dismissLabel.
You provide
- A specific
dismissLabelwhen "Close" alone is vague.
API reference
Banner
| Prop | Type | Default | Description |
|---|---|---|---|
tone | BannerTone | – | |
children | React.ReactNode | – | Why, and what to do. |
actions | React.ReactNode | – | Inline: up to two link actions. Floating: a default (neutral) Button, never the gold primary. |
onDismiss | () => void | – | Shows a close button; omit for errors that must be resolved. |
dismissLabel | string | – | The close button's name when "Close" alone is too vague ("Close cookie notice"). |
placement | "inline" | "floating" | – | |
title | React.ReactNode | – | What happened, one line. |
aria-label | string | – | Names the region ("Cookie notice"). |
avoid | string | RefObject<HTMLElement | null> | – | A sticky bottom bar to sit above: its element (measured from its top edge) or a CSS length with a unit ("72px"). |
icon | IconName | null | – | Replaces the tone icon ("cookie"); |
toneBannerTonechildrenReact.ReactNodeWhy, and what to do.
actionsReact.ReactNodeInline: up to two link actions. Floating: a default (neutral) Button, never the gold primary.
onDismiss() => voidShows a close button; omit for errors that must be resolved.
dismissLabelstringThe close button's name when "Close" alone is too vague ("Close cookie notice").
placement"inline" | "floating"titleReact.ReactNodeWhat happened, one line.
aria-labelstringNames the region ("Cookie notice").
avoidstring | RefObject<HTMLElement | null>A sticky bottom bar to sit above: its element (measured from its top edge) or a CSS length with a unit ("72px").
iconIconName | nullReplaces the tone icon ("cookie");
nullshows none (narrow phone layouts).