---
title: Button
description: Displays a button or a component that looks like a button.
featured: true
component: true
---
import { InfoIcon } from "lucide-react"
}>
**Updated:** We have updated the button component to add new sizes: `icon-sm` and `icon-lg`. See the
[changelog](/docs/components/button#changelog) for more details. Follow the
instructions to update your project.
```tsx showLineNumbers
```
## Installation
CLIManual
```bash
npx shadcn@latest add button
```
Install the following dependencies:
```bash
npm install @radix-ui/react-slot
```
Copy and paste the following code into your project.Update the import paths to match your project setup.
## Usage
```tsx
import { Button } from "@/components/ui/button"
```
```tsx
```
## Cursor
Tailwind v4 [switched](https://tailwindcss.com/docs/upgrade-guide#buttons-use-the-default-cursor) from `cursor: pointer` to `cursor: default` for the button component.
If you want to keep the `cursor: pointer` behavior, add the following code to your CSS file:
```css showLineNumbers title="globals.css"
@layer base {
button:not(:disabled),
[role="button"]:not(:disabled) {
cursor: pointer;
}
}
```
## Examples
### Size
```tsx
// Small
// Medium
// Large
```
### Default
```tsx
```
### Outline
```tsx
```
### Secondary
```tsx
```
### Ghost
```tsx
```
### Destructive
```tsx
```
### Link
```tsx
```
### Icon
```tsx showLineNumbers
```
### With Icon
The spacing between the icon and the text is automatically adjusted
based on the size of the button. You do not need any margin on the icon.
```tsx
```
### Rounded
Use the `rounded-full` class to make the button rounded.
```tsx
```
### Spinner
```tsx showLineNumbers
```
### Button Group
To create a button group, use the `ButtonGroup` component. See the [Button Group](/docs/components/button-group) documentation for more details.
```tsx showLineNumbers
```
### Link
You can use the `asChild` prop to make another component look like a button. Here's an example of a link that looks like a button.
```tsx showLineNumbers
import Link from "next/link"
import { Button } from "@/components/ui/button"
export function LinkAsButton() {
return (
)
}
```
## API Reference
### Button
The `Button` component is a wrapper around the `button` element that adds a variety of styles and functionality.
| Prop | Type | Default |
| --------- | ----------------------------------------------------------------------------- | ----------- |
| `variant` | `"default" \| "outline" \| "ghost" \| "destructive" \| "secondary" \| "link"` | `"default"` |
| `size` | `"default" \| "sm" \| "lg" \| "icon" \| "icon-sm" \| "icon-lg"` | `"default"` |
| `asChild` | `boolean` | `false` |
## Changelog
### 2025-09-24 New sizes
We have added two new sizes to the button component: `icon-sm` and `icon-lg`. These sizes are used to create icon buttons. To add them, edit `button.tsx` and add the following code under `size` in `buttonVariants`:
```tsx showLineNumbers title="components/ui/button.tsx"
const buttonVariants = cva("...", {
variants: {
size: {
// ...
"icon-sm": "size-8",
"icon-lg": "size-10",
// ...
},
},
})
```