Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert examples · Info

Info with Title and Action Alert for React

An info alert with a title and Learn More and Dismiss buttons.

Framework
UI library

Information with a next step beats a passive notice. This React alert puts Learn More and Dismiss buttons in AlertAction, at the end of an Alert with variant="info" and a single AlertTitle. Use it for feature announcements or changelog highlights, where the reader can read more or acknowledge it and move on.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

What sits next to the title?

Learn More and Dismiss, in one AlertAction. The alert is variant="info" with a single AlertTitle and no description.

Why is Learn More a default button rather than blue?

Button has no info variant, so Learn More uses the default variant and Dismiss uses outline: the filled button is the one to press. The alert's blue tint already marks the message as information. In the info variant, ghost buttons in AlertAction take the blue hover color if you want a lighter pair.

Where are the buttons positioned?

AlertAction is absolutely positioned at the top right. The alert adds right padding so the title keeps its room. className="flex gap-2" puts the two xs buttons in a row.

How do I make Dismiss hide the alert?

Alert has no built-in dismiss. Keep whether it is shown in your own state and have Dismiss stop rendering it. The buttons in this file are static.

Can I add a third button beside these two?

Put it in the same AlertAction. That part is one absolutely positioned slot, so a second AlertAction would stack on the first. The title is only the word Info, which leaves room for the row.