# Button

Displays a button or a component that looks like a button.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).





<ComponentPreview name="button-demo">
  <ButtonDemo />
</ComponentPreview>

## Installation [#installation]

<Tabs defaultValue="cli">
  <TabsList>
    <TabsTrigger value="cli">
      CLI
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add https://shadcn-cssinjs.com/r/button.json
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      pnpm add @base-ui/react @stylexjs/stylex
      ```

      <Step>
        Make sure [StyleX is configured](/docs/installation) and the design tokens are
        installed.
      </Step>

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

      <ComponentSource name="button" title="button.tsx" />

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

## Usage [#usage]

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

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

## Examples [#examples]

### Variants [#variants]

Use the `variant` prop to change the button style.

<ComponentPreview name="button-variants">
  <ButtonVariants />
</ComponentPreview>

### Size [#size]

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

<ComponentPreview name="button-sizes">
  <ButtonSizes />
</ComponentPreview>

### Link [#link]

<ComponentPreview name="button-link">
  <ButtonLink />
</ComponentPreview>

### Icon [#icon]

Use `size="icon"` for a square, icon-only button.

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

### With Icon [#with-icon]

Place an icon before or after the label.

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

### Disabled [#disabled]

<ComponentPreview name="button-disabled">
  <ButtonDisabled />
</ComponentPreview>



### Default [#default]

<ComponentPreview name="button-default">
  <ButtonDefault />
</ComponentPreview>

### Outline [#outline]

<ComponentPreview name="button-outline">
  <ButtonOutline />
</ComponentPreview>

### Secondary [#secondary]

<ComponentPreview name="button-secondary">
  <ButtonSecondary />
</ComponentPreview>

### Ghost [#ghost]

<ComponentPreview name="button-ghost">
  <ButtonGhost />
</ComponentPreview>

### Destructive [#destructive]

<ComponentPreview name="button-destructive">
  <ButtonDestructive />
</ComponentPreview>

### Rounded [#rounded]

<ComponentPreview name="button-rounded">
  <ButtonRounded />
</ComponentPreview>

### Spinner [#spinner]

<ComponentPreview name="button-spinner">
  <ButtonSpinner />
</ComponentPreview>

### Button Group [#button-group]

<ComponentPreview name="button-group-example">
  <ButtonGroupExample />
</ComponentPreview>

### As Link [#as-link]

Use the `render` prop to render the button as a link.

<ComponentPreview name="button-as-link">
  <ButtonAsLink />
</ComponentPreview>



## RTL [#rtl]

To enable right-to-left support, see the [RTL guide](/docs/rtl).

<ComponentPreview name="button-rtl" direction="rtl">
  <ButtonRtl />
</ComponentPreview>

## API Reference [#api-reference]

### Button [#button]

The `Button` component is a wrapper around the `button` element that adds a variety of styles and functionality.

| Prop      | Type                                                                          | Default     |
| --------- | ----------------------------------------------------------------------------- | ----------- |
| `variant` | `"default" \| "destructive" \| "outline" \| "secondary" \| "ghost" \| "link"` | `"default"` |
| `size`    | `"default" \| "sm" \| "lg" \| "icon" \| "icon-sm" \| "icon-lg"`               | `"default"` |
| `render`  | `React.ReactElement`                                                          | -           |

Use the `render` prop to render the button as a different element (the Base UI equivalent of `asChild`).
