shadcn.io is not affiliated with official shadcn/ui
Warning Alert Banner Block for React
An expiry callout for a certificate manager: a framed panel with a warning icon and a Shine Button that renews in place, turning the alert into a success, plus a ghost button that folds it away.
Installation
Overview
An expiry callout for React with Base UI, for a warning that can be fixed on the spot. A hairline frame with + marks on its corners holds a warning icon, a heading, one sentence and two actions. The Shine Button, "Renew certificate", fixes it in place: it reads "Renewing…" with a spinner, then the icon turns from the warning to the success token and the words to "Certificate renewed, valid for 90 days". The warning and the result share one grid cell, so nothing shifts. "Remind me tomorrow" folds the whole block away with a CSS height transition, down to its top rule. The status colour stays on the icon; the text follows your theme. The page's rails and top rule come from the Guides spine. It's built from Guides, Shine Button, Button and Spinner, with your theme's tokens for every colour. For expiring certificates, domains, trials, tokens and any warning where the fix is one action.
FAQ
How do I connect the real renewal?
Replace the timer: the block's renew handler sets the phase to "renewing" and a 2.2 second effect sets it to "done". Call your API there instead, and set "done" when it succeeds; on failure, go back to "idle" and put the reason in the polite status line. The effect clears its timer when the block unmounts, so leaving the page cancels it.
Where does the keyboard go when the button disables itself?
While renewing, the button is disabled and a polite status says "Renewing certificate". When the result arrives, focus moves to a short visually hidden line, "Certificate renewed, valid for 90 days.", so a keyboard or a screen reader lands where the news is and the next Tab carries on from the block. "Remind me tomorrow" does the same with "We'll remind you tomorrow."
How do the two states avoid shifting the page?
The warning and the result are stacked in one grid cell, as are the two sets of actions. The state that isn't showing is invisible and inert, so it takes no focus and screen readers skip it, and the cell is as tall as the taller one. The button's two labels share a cell too, so it keeps its width while it spins.
How do I keep the reminder after a reload?
The block forgets on purpose, so the preview always shows it. To remember, set a cookie when "Remind me tomorrow" is pressed with an expiry a day away, and skip rendering the block while your server sees it. Reading a stored value after the first paint would show the panel and then fold it, moving the page.
Related
- 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
Success Alert Banner
AlertsA success notice for a release pipeline on a faint tinted band: a check icon, a heading, one line, a link to the deployment and 18 slim segments, one per passed check, that fill in once.
- Pro
Error Alert Banner
AlertsA failed-deploy callout for a deploy platform: a band with a failure icon, a heading naming the commit, a Shine Button to retry, and a framed excerpt that quotes the failing lines with the bad one marked.
- 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
Usage Quota Metric Banner
MetricsAn API-quota banner for an API platform on a tinted band: a bar with 80% and 95% ticks, the warning colour past the alert, and a hatched stretch to 100% for where the pace leads.
- Pro
Stacked Alert Banner
AlertsFour notices from an invoicing back office in one framed list: an error, a warning, an info and a success, each with its own close button, a live count and a Dismiss all.