Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Alert Dialog examples · Custom Actions

Mixed Button Styles Alert Dialog for React

An alert dialog with Cancel on one side and two actions in different styles on the other.

Framework
UI library

When every button looks the same, people can't tell which one matters. This React alert dialog sets Cancel apart and pairs an outline Mark as On Hold with a solid Mark as Complete, so the recommended choice stands out. It's shadcn.io's Alert Dialog on Base UI with the Button variants doing the work.

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

Which button gets which style?

The recommended action gets the default solid style, the alternative gets variant="outline", and Cancel keeps its outline look. Use variant="destructive" only for actions that destroy something.

Can I use other colors than the variants?

Prefer the variants, since they follow the theme in light and dark mode. If you need a green success button, check the variants first rather than adding raw color classes, which won't adapt to the theme.

How are the buttons grouped?

AlertDialogFooter takes sm:justify-between; Cancel sits on one side and the two actions share a flex gap-2 group on the other, so the layout reads as cancel versus act, then which act.

What happens on small screens?

The footer stacks its children, and the action group uses flex-col-reverse below sm, so every button is full width and the primary action ends up on top.

Is it enough to tell the buttons apart by style?

No. Style helps sighted users, but the labels carry the meaning for everyone, including screen reader users and people who don't see color. Mark as On Hold and Mark as Complete say what each does.

Do all three buttons close the dialog?

Yes. Each action closes it after its click handler runs. On Base UI, AlertDialogAction is a plain button that leaves the dialog open: control open and set it to false in the action's handler.