shadcn.io is not affiliated with official shadcn/ui
Top Bar Banner Block for React
A slim announcement strip for a writing app's release: one centred line with the version, the news and an underlined link, and a ghost button that folds the strip away.
Installation
Overview
A top bar for React with Base UI, the strip that sits above your hero and says one thing. One centred line announces Quillmoor 3.0: the version in medium weight, what it brings in the muted tone, and an underlined link to the release notes with an arrow that turns around in right-to-left layouts. The strip is a faint tint of the theme's muted colour, 44 pixels tall on a desktop and two lines at most on a phone, and it sits on the page's drafting lines: two rails at the edges of the page column that run on into the blocks below, and a rule along its top edge with a plus mark on each crossing. The next block's own top rule is its bottom edge, so a stack never doubles a line. A ghost button at the end dismisses it: the strip folds its height away with a CSS transition, focus moves on to what follows it on the page, and a polite status line says it's gone. There's no primary colour anywhere: the tint, the weight and the underline carry it. It's built from Guides and Button with Lucide icons and your theme's tokens for every colour. For releases, changelog pointers, migrations and any site-wide news that should take one line and then get out of the way.
FAQ
How do I change what the bar says?
Edit RELEASE at the top of the file: the product and version in medium weight (name), the news after it (news), the link's words (link) and where it goes (href). Keep the whole line to about 50 characters (this one is 47): it then stays on one line on a desktop and wraps to two at most on a 320-pixel phone, where the centred text has about 190 pixels. The link never breaks inside itself, so its arrow stays with its words, and the link text says where it goes rather than "Learn more". The sentence sits in a bdi, so in a right-to-left page its full stop stays at its end.
How does the bar fold away, and what happens with reduced motion?
The strip sits in a one-row CSS grid. Dismissing it eases the row from 1fr to 0fr and the opacity to 0 over 300 ms, so the page below rises smoothly instead of jumping, and no height is measured in script. The strip's padding lives inside that row, so it folds to nothing; its top rule then lies on the next block's top rule and disappears into it. The bar stays in the page but becomes inert, out of the tab order and hidden from screen readers, and the section drops its "Announcement" label so no empty landmark is left behind. With reduced motion turned on, it closes at once.
Where does keyboard focus go after the bar is dismissed?
Where Tab would have taken it: to the first link, button or field after the bar on the page, such as your navbar's first link or the hero's first link, instead of being lost with the button. A polite status line says "Announcement dismissed." for screen readers. When nothing on the page comes after the bar, as in this preview, focus rests on the page and the status line still speaks.
How do I keep the bar closed after a visitor dismisses it?
Remember the dismissal under a key for this announcement, such as dismissed-quillmoor-3, so the next announcement shows again. A cookie is the right store for a top bar: the server reads it and leaves the bar out of the page, so it never flashes. Reading localStorage after the first render would show the bar and then fold it away on every visit, moving the whole page under it. The block keeps the choice for the current page only.
How does it line up with my navbar and hero?
The section is full width, with the tint on it, and the strip's content sits in the same max-w-6xl page column as every block. Its Guides layer draws that column's two rails and one rule along its top edge that runs to the page's edges, with a plus on each crossing. It draws no bottom rule: the block below draws that line, so the boundary under the strip has exactly one. Put it first on the page, or between your navbar and your hero; every rail stays at the same x from block to block.
How does it fit on a phone?
The line stays centred and wraps to two lines at most, the link on the second with its arrow. The dismiss button keeps its place at the end of the first line, the top end corner, and a matching empty column at the start keeps the text truly centred. In right-to-left layouts the button and the empty column swap sides and the arrow turns around; nothing scrolls sideways at 320 pixels.
Related
- Pro
Dismissible Announcement Bar Hero
Updates and timelinesA showcase hero for a release planning tool: a dismissible announcement band, a headline beside the pitch, a Shine Button, a trust line and a framed sketch of a release board that runs off the bottom.
- Pro
Version Banner CTA
Slim bandsA slim release band between solid rails: a version badge, the headline change, a Shine Button to the notes and a disclosure that opens a second band of three change cells.
- Pro
Dismissible Action Banner CTA
Slim bandsA slim survey banner between the page rails with a Shine Button and a close cell behind a solid divider: the close button opens a two-choice popover, then collapses the banner and leaves an Undo that takes focus.
- Pro
Trial Banner Billing
Upsell and retentionA trial-ending banner for an app's shell: days left in the heading, a progress bar, what changes when the trial ends, an Add payment method action and a dismiss that remembers.
- Pro
Reverse Split News List Hero
Updates and timelinesA reverse split hero on drafting lines for a team docs workspace: a greyscale product illustration beside an announcement pill, the headline, a ruled list of the latest updates as links, a Shine Button and a second action.
- Pro
A launch band for a design tool: a tinted strip with a centred line, a Launch week chip whose outline a light sweeps three times, and a link to the keynote.