A strip across the page for news that concerns everyone: a launch, a sale, planned downtime.
$ pnpm dlx shadcn@latest add @dashral/bannerInstallation
$ pnpm dlx shadcn@latest add @dashral/bannerAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/banner.json
Usage
import { Banner } from "@/components/dashral/banner"
<Banner
title="Version 2.0 is here."
description="Shared workspaces and a faster editor."
action={<a href="/changelog">Read the notes →</a>}
onClose={() => dismiss("v2-banner")}
/>Using the npm package? Import from @dashral/ui/components/banner instead, here and in the examples; the rest is the same.
Examples
API reference
Banner
Also takes every prop of <div>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
title | ReactNodeThe message, in bold. | — |
description | ReactNodeAfter the title, softer. Anything in children follows it. | — |
icon | ReactNodeBefore the text, e.g. an icon. | — |
action | ReactNodeAfter the text, e.g. a link or small buttons. | — |
variant | "solid" | "soft" | "outline"How much it stands out. | "solid" |
color | "primary" | "neutral" | "info" | "success" | "warning" | "destructive" | "highlight"What it means; neutral is the ink bar. | "neutral" |
align | "center" | "start"Its text in the middle, or at the start. | "center" |
floating | booleanA rounded card with a shadow instead of a full-width bar; place it with className (absolute, fixed). | false |
onClose | () => voidShows a close button and is called when it's pressed: hide it and remember the choice yourself. | — |
classNames | { title, description, action }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
Accessibility
- A plain region of the page, not announced: it's there when the page loads. For news that arrives while someone works, use a toast.
- The close button is named "Dismiss" (translated).
- On a phone the text wraps; nothing is cut off.