Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Button for React

Triggers an action or navigates when used as a link.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/aria/button.json

Usage

import { ArrowUpIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
<div className="flex flex-wrap items-center gap-2 md:flex-row">
  <Button variant="outline">Button</Button>
  <Button aria-label="Submit" size="icon-md" variant="outline">
    <ArrowUpIcon aria-hidden="true" />
  </Button>
</div>

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.

Demos

Size

Use the size prop to change the size of the button.

Variant Default

Outline

Secondary

Ghost

Destructive

Icon

With Icon

Remember to add data-icon="inline-start" or data-icon="inline-end" on the icon for the correct spacing.

Rounded

Use the rounded-full class to make the button rounded.

Spinner

Render a <Spinner /> inside the button to show a loading state. Add data-icon="inline-start" or data-icon="inline-end" on the spinner for the correct spacing.

As Child

Use asChild to render the button styles on a link (or other host element).

Rtl

Right-to-left button. See the RTL configuration guide for document direction.

API Reference

Button

PropType
className?string
AttributeType