Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Actions with Icons Alert Dialog for Solid

A leave-site confirmation whose Continue button shows an external-link icon after the label. Nothing navigates.

UI library: Ark UI

The title is Leave Site. The buttons are Stay Here and Continue. Continue has an external-link icon after the words, hidden from assistive tech. The demo does not open another site.

Put the icon after the label when it shows where the action goes, and keep the words. If leaving is not a hard choice, a Dialog is enough. In Solid, Ark UI does not open the other site.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Alert Dialog anatomy: content, title, description, cancel, action

Usage

<AlertDialog>
    <AlertDialogTrigger asChild={props => <Button {...props()} variant="outline">Open External Link</Button>} />
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogTitle>Leave Site?</AlertDialogTitle>
        <AlertDialogDescription>
          You are about to visit an external website. We are not responsible for
          the content on external sites.
        </AlertDialogDescription>
      </AlertDialogHeader>
      <AlertDialogFooter>
        <AlertDialogCancel>Stay Here</AlertDialogCancel>
        <AlertDialogClose asChild={props => <AlertDialogAction {...props()}>
            Continue
            <ExternalLinkIcon aria-hidden="true" data-icon="inline-end" />
          </AlertDialogAction>} />
      </AlertDialogFooter>
    </AlertDialogContent>
  </AlertDialog>

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.

Do icons cause problems on small screens?

Only with long labels. Keep labels short when you add an icon so the button doesn't wrap; the footer stacks buttons full width on mobile.

Does Continue close the dialog?

Yes; put your navigation in its click handler.

API Reference

Alert Dialog

Sets asChild and props. The rest is on the Alert Dialog page.

Button

Sets props and variant="outline". The rest is on the Button page.