shadcn.io is not affiliated with official shadcn/ui
Button examples · Standard
Button with Left Icon (Standard) for React
A filled button with an icon before the label, when the main action is faster to recognize with a symbol next to the word.
The default button, with a mail icon before the word. The icon is hidden from assistive tech, so the label has to say what happens.
Use it for Send or Download, where people scan a picture and a word together. If the word is already clear, drop the icon. A text Button is enough. In React, the button's styles line the icon up with the label.
Preview
Installation
FAQ
Why is the icon before the label?
The demo puts MailIcon before the text and sets data-icon="inline-start". That attribute is how the button's padding treats an icon, and it flips in a right-to-left layout. The gap comes from the button size.
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 Text (Standard)The one filled action
- Button with Right Icon (Standard)An arrow on the main action
- Button with Left Icon (Outline)An icon on an outline
- Button with Left Icon (Link)An icon before a quiet action
- Loading Button (Standard)The main action, while it runs
- Button with Left Icon (Secondary)An icon, kept quiet