---
title: Button
description: Displays a button or a component that looks like a button.
featured: true
component: true
---

<ComponentPreview name="button-demo" />

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx shadcn-ui@latest add button
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Install the following dependencies:</Step>

```bash
npm install @radix-ui/react-slot
```

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="button" />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx
import { Button } from "@/components/ui/button"
```

```tsx
<Button variant="outline">Button</Button>
```

## Link

You can use the `buttonVariants` helper to create a link that looks like a button.

```tsx
import { buttonVariants } from "@/components/ui/button"
```

```tsx
<Link className={buttonVariants({ variant: "outline" })}>Click here</Link>
```

Alternatively, you can set the `asChild` parameter and nest the link component.

```tsx
<Button asChild>
  <Link href="/login">Login</Link>
</Button>
```

## Examples

### Primary

<ComponentPreview name="button-demo" />

### Secondary

<ComponentPreview name="button-secondary" />

### Destructive

<ComponentPreview name="button-destructive" />

### Outline

<ComponentPreview name="button-outline" />

### Ghost

<ComponentPreview name="button-ghost" />

### Link

<ComponentPreview name="button-link" />

### Icon

<ComponentPreview name="button-icon" />

### With Icon

<ComponentPreview name="button-with-icon" />

### Loading

<ComponentPreview name="button-loading" />

### As Child

<ComponentPreview name="button-as-child" />
