shadcn.io is not affiliated with official shadcn/ui
Alert Dialog examples · Custom Actions
Actions with Icons Alert Dialog for React
An alert dialog whose action carries an icon after its label to show where it leads.
An icon can say where a button goes faster than its label. This React alert dialog warns before leaving for an external site and puts an external-link icon after Continue. It's shadcn.io's Alert Dialog on Base UI, with a Lucide icon inside AlertDialogAction.
Preview
Installation
FAQ
Should icons go before or after the label?
After it for direction, like an external link or an arrow: they show where the action leads. Before it for icons that describe the action, like download or delete. Mark them with data-icon="inline-end" or data-icon="inline-start" so the button spaces them.
What size should the icon be?
Leave it to the button: it sizes icons to match its text, so there's no size-* class to add.
Should Cancel get an icon too?
Rarely. Stay Here is self-explanatory. Add icons where they add meaning, which is usually only the action.
Do screen readers announce the icon?
No. It's aria-hidden, so the button is read as Continue. Never make a dialog button icon-only; the text is what everyone relies on.
Related
- Confirmation with Custom Button Labels Alert DialogA confirmation dialog whose buttons name
- Mixed Button Styles Alert DialogAn alert dialog with Cancel on one side
- Vertical Button Stack Alert DialogAn alert dialog with its actions stacked
- Confirmation with Icon Alert DialogA confirmation dialog with a warning icon
- Standard DialogA share dialog with a read-only link, a
- Actions with Loading State Alert DialogAn alert dialog with file details whose