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.
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
Installation
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.
Related
- Button with Count (Secondary)A count, kept quiet
- Button with Kbd (Secondary)A shortcut, kept quiet
- Button with Right Icon (Secondary)An arrow, kept quiet
- Button with Text (Secondary)Quieter than the main action
- Loading Button (Secondary)A side action, while it runs
- Rounded Button (Secondary)A pill, kept quiet