shadcn.io is not affiliated with official shadcn/ui
Dismissible Action Banner CTA Block for React
A 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.
Installation
Overview
A slim survey banner that asks before it goes away, for React with Base UI. Between the page rails, a one-sentence headline with a "2 min" badge and a line of copy sit at the start, a Shine Button "Take the survey" follows, and at the end a close cell behind a solid divider that meets the top rule holds the close button. The close button opens a small popover that asks "Hide this banner?" with two choices, Not now and Don't show again. Either one eases the banner shut, announces what happened to screen readers, and leaves a slim Undo row that takes keyboard focus. On a phone the Shine Button and the close button share a row under the copy. It's built from Popover, Badge, Button, Shine Button and Guides with Lucide icons, and the collapse is a CSS grid-rows transition. For in-app surveys, announcements and any banner that should be easy to dismiss and easy to get back.
FAQ
How do I remember the choice?
The block only keeps it in state, so a reload shows the banner again. Save the choice where it suits you: a cookie lets the server render the page with the banner already closed, so it never flashes; localStorage has to be read after the first render. Store "Not now" with a date and show the banner again after a week, and store "Don't show again" with no date.
How does the banner collapse, and what about reduced motion?
The banner sits in a one-row CSS grid, and the Undo row in another. Hiding it eases the row from 1fr to 0fr while the Undo row eases open, over 300 ms, so the page height barely changes and nothing is measured in script. The hidden banner becomes inert and invisible, so it leaves the tab order and the accessibility tree. With reduced motion turned on it switches at once.
Where does keyboard focus go?
Choosing in the popover closes it, and focus moves to Undo, so a keyboard user is never left on a control that has gone. Undo restores the banner and moves focus back to the close button. A hidden live region announces "Banner hidden" with the choice made, and "Survey banner restored" after Undo.
How does the popover work?
The close button is named "Dismiss the survey banner" and opens a popover that closes on Escape and when you click away.
The popover is controlled with open and onOpenChange, and each choice sets it to closed.
Related
- 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
Icon Banner CTA
Slim bandsA slim band split into cells between solid rails: an icon tile, a solid divider, a title with one line of detail, and a Shine Button link on the end.
- Pro
Icon Action Banner CTA
Slim bandsA slim documentation band between solid rails: a framed icon tile, a title that is one big link over the whole row, and a Shine Button to the quickstart.
- Pro
Availability Strip CTA
Slim bandsA slim support band with a world clock between the page rails: a headline at the start, a framed figure of three hub clocks that show local time and whether each hub is staffed, and a Shine Button to book a call.
- 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
Dual Action CTA
Slim bandsA band call to action between solid rails with one split button: a Shine Button Get started link joined to a chevron that opens a menu of other routes, beside a headline and a sentence, in your theme.