shadcn.io is not affiliated with official shadcn/ui
Expandable Banner Block for React
A fee-change notice for a rent-collection tool as a card in card: one header line that opens a sentence, three rows of facts (Now, From next renewal, Why) and a link.
Installation
Overview
An expandable banner for React with Base UI, for a change that deserves one line first and the details on request. A muted shell with + marks on its corners wraps a raised panel whose header line, a receipt icon, "Card payment fees change at your next renewal" and a chevron, is the trigger of a disclosure that starts closed. Opened, it shows one sentence, three rows of facts on hairlines (Now, From next renewal, Why) and an underlined link to the fee schedule. The panel is separated from the header by a hairline, and the height opens on one grid row with a CSS transition. It's built from Collapsible, Data List and Guides, and it follows the theme, light or dark.
FAQ
How do I change the facts?
Edit FACTS at the top of the file: each entry is a label and a value. They are a real description list (a term and its detail), so a screen reader says "From next renewal, 1.9% per card payment". Values with a sign or a unit sit in a bdi element so a right-to-left layout keeps them in order.
How is the disclosure named for screen readers?
The trigger is a button inside the block's heading (h2), named by the header line; it reports expanded or collapsed, opens with Enter or Space, and its aria-controls points at the panel. The whole line is the target, not only the chevron.
How do I start it open?
Give Collapsible the defaultOpen prop.
It starts closed because a banner should take one line until someone asks for more.
What moves, and what happens with reduced motion?
The card fades up once on load, the panel's height eases open and the chevron turns over, all with CSS. With reduced motion turned on the panel opens at once and nothing animates.
Related
- Pro
Collapsible Details Banner
Disclosures and tabsAn incident notice for a status-page product as a disclosure: one summary line with an Investigating badge, and open it explains the incident and lists the four affected services.
- Pro
Expandable Timeline Banner
Disclosures and tabsA parcel notice for a tracking product as a disclosure: a header that names the current stage and its step, and a vertical four-step timeline when opened.
- $Pro
Expandable Code Banner
Disclosures and tabsAn install notice for a CLI toolkit as a disclosure: a header with a version badge opens package-manager tabs and the command in a mono box with a Copy button.
- Pro
Info Alert Banner
AlertsAn in-page info callout for an invoicing app: a card in card with an info icon, a heading, two sentences about a change coming next month, a Shine Button link and a dismiss button that folds the block away.
- Pro
Maintenance Alert Banner
AlertsA maintenance callout for a managed database service: a warning heading and two sentences over a second band that draws the day as 24 hour cells, with the two hours inside the window filled.
- 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.