Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Button examples · Secondary

Button with Left Icon (Secondary) for React

A muted button with an icon before the label, when a supporting action needs a symbol and should stay visually quiet.

Framework
UI library

Secondary fill, a mail icon, then the label. The icon does not replace the words.

Use it beside a primary button, for something like Invite or Share. If it is the action you want pressed, use the default Button. In React, aria-hidden makes the icon decoration.

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

Why is the icon before the label?

On this secondary button the mail icon leads, with data-icon="inline-start". That padding flips in a right-to-left layout. The secondary fill is the quiet weight, and the icon inherits its text color.

How do I use a different icon?

Swap the component. MailIcon is a placeholder from lucide-react. Keep data-icon="inline-start" and aria-hidden="true" when the label already says what the button does.

Will a screen reader announce the icon?

No. aria-hidden="true" takes it out, and the label is the accessible name. Drop the label only if you add an aria-label on the button. An icon with no name is an unlabeled control.

How big is the icon?

You don't pass a numeric size. The button styles an svg that has no size-* class, and these demos leave that alone. Add className="size-4" on the icon only when you need to override it.

How quiet is this one?

variant="secondary" uses the secondary fill, and the mail icon inherits that foreground. Pair it with a primary button when both actions are real and only one of them should dominate.

Does the icon change what the click does?

No. It's decorative. The button's type is still button, so it won't submit a form unless you pass type="submit". Disabled works the same here: pass disabled and the whole control fades, icon included.