---
title: "Button"
description: "Spring-pressed Button plus StatefulButton, MagneticButton, and MetallicButton variants."
category: "Components"
publishedAt: "2026-05-17"
updatedAt: "2026-11-25"
documentation: "https://beui.dev/components/motion/button"
markdown: "https://beui.dev/components/motion/button.md"
license: "MIT"
---

# Button

> Spring-pressed Button plus StatefulButton, MagneticButton, and MetallicButton variants.

## Install

### Metallic Button

A neutral button surface framed by a pronounced chrome rim with a straight traveling reflection.

```bash
npx shadcn@latest add @beui/button-metallic
```

Docs: https://beui.dev/components/motion/button/metallic.md

### Button

Subtle press scale, ripple, variants and sizes.

```bash
npx shadcn@latest add @beui/button-base
```

Docs: https://beui.dev/components/motion/button/base.md

### Stateful Button

Idle → loading → success / error with blur-swap slots and morphing width.

```bash
npx shadcn@latest add @beui/button-stateful
```

Docs: https://beui.dev/components/motion/button/stateful.md

### Magnetic Button

Button composed with the Magnetic wrapper for cursor-attracted pull.

```bash
npx shadcn@latest add @beui/button-magnetic
```

Docs: https://beui.dev/components/motion/button/magnetic.md

## Dependencies

- `clsx`
- `lucide-react`
- `motion`
- `react`
- `tailwind-merge`

## Usage

### Metallic Button usage

A neutral button surface framed by a pronounced chrome rim with a straight traveling reflection.

```tsx
"use client";

import { ArrowUpRight, Sparkles } from "lucide-react";
import { MetallicButton } from "@/components/motion/button";

export function ButtonMetallicPreview() {
  return (
    <div className="flex flex-wrap items-center justify-center gap-3 px-6 py-10">
      <MetallicButton>
        Continue
        <ArrowUpRight className="size-4" />
      </MetallicButton>
      <MetallicButton size="sm">
        <Sparkles className="size-3.5" />
        Generate
      </MetallicButton>
      <MetallicButton size="icon" aria-label="Magic tools">
        <Sparkles className="size-4" />
      </MetallicButton>
    </div>
  );
}
```

### Button usage

Subtle press scale, ripple, variants and sizes.

```tsx
"use client";

import { ArrowRight, Download, Trash2 } from "lucide-react";
import { Button } from "@/components/motion/button";

export function ButtonBasePreview() {
  return (
    <div className="flex flex-col items-center gap-6">
      <div className="flex flex-wrap items-center justify-center gap-3">
        <Button sound variant="primary" size="md">
          Continue
          <ArrowRight className="h-4 w-4" />
        </Button>
        <Button sound variant="secondary" size="md">
          <Download className="h-4 w-4" />
          Download
        </Button>
        <Button sound variant="outline" size="md">Outline</Button>
        <Button sound variant="ghost" size="md">Ghost</Button>
      </div>
      <div className="flex flex-wrap items-center justify-center gap-3">
        <Button sound variant="primary" size="sm">Small</Button>
        <Button sound variant="primary" size="md">Medium</Button>
        <Button sound variant="primary" size="lg">Large</Button>
        <Button sound variant="secondary" size="icon" aria-label="Delete">
          <Trash2 className="h-4 w-4" />
        </Button>
      </div>
      <div className="flex flex-wrap items-center justify-center gap-3">
        <Button sound variant="primary" size="md" ripple>Ripple</Button>
        <Button sound variant="outline" size="md" ripple>Tap me</Button>
      </div>
    </div>
  );
}
```

### Stateful Button usage

Idle → loading → success / error with blur-swap slots and morphing width.

```tsx
"use client";

import { ArrowRight } from "lucide-react";
import { useState } from "react";
import { type ButtonState, StatefulButton } from "@/components/motion/button";

export function ButtonStatefulPreview() {
  const [okState, setOkState] = useState<ButtonState>("idle");
  const [errState, setErrState] = useState<ButtonState>("idle");

  const run = (target: "ok" | "err") => {
    const setter = target === "ok" ? setOkState : setErrState;
    setter("loading");
    setTimeout(() => {
      setter(target === "ok" ? "success" : "error");
      setTimeout(() => setter("idle"), 1800);
    }, 1400);
  };

  return (
    <div className="flex flex-col items-center justify-center gap-3">
      <StatefulButton
        state={okState}
        variant="primary"
        size="md"
        onClick={() => run("ok")}
        loadingText="Saving"
        successText="Saved"
        icon={<ArrowRight className="h-4 w-4" />}
      >
        Save changes
      </StatefulButton>
      <StatefulButton
        state={errState}
        variant="secondary"
        size="md"
        onClick={() => run("err")}
        loadingText="Submitting"
        errorText="Failed"
      >
        Submit
      </StatefulButton>
    </div>
  );
}
```

### Magnetic Button usage

Button composed with the Magnetic wrapper for cursor-attracted pull.

```tsx
"use client";

import { ArrowRight } from "lucide-react";
import { MagneticButton } from "@/components/motion/button";

export function ButtonMagneticPreview() {
  return (
    <div className="flex flex-wrap items-center justify-center gap-4">
      <MagneticButton variant="primary" size="md" strength={0.35}>
        Hover me
        <ArrowRight className="h-4 w-4" />
      </MagneticButton>
      <MagneticButton variant="secondary" size="md" strength={0.25}>
        Subtle pull
      </MagneticButton>
      <MagneticButton variant="outline" size="md" strength={0.5}>
        Strong pull
      </MagneticButton>
    </div>
  );
}
```

## API Reference

### MetallicButton

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |
| `size` | `"sm" \| "md" \| "lg" \| "icon"` | `md` | No | Height and padding; "icon" is a square icon-only button. Default: "md" |
| `pressScale` | `number` |  | No | Scale while pressed. Default 0.97: subtle, so the press reads as feedback, not a squash. |
| `sound` | `boolean` |  | No | Play a soft press sound. Off by default; a `SoundProvider` can mute it app-wide. |
| `paused` | `boolean` | `false` | No | Stops the traveling reflection while preserving the chrome rim. |

### Button

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |
| `size` | `"sm" \| "md" \| "lg" \| "icon"` | `md` | No | Height and padding; "icon" is a square icon-only button. Default: "md" |
| `variant` | `"outline" \| "primary" \| "secondary" \| "ghost"` | `primary` | No | Visual style: filled, card, ghost or outline. Default: "primary" |
| `pressScale` | `number` | `0.97` | No | Scale while pressed. Default 0.97: subtle, so the press reads as feedback, not a squash. |
| `ripple` | `boolean` | `false` | No | Spawn a Material-style ripple from the press point. Off by default. |
| `sound` | `boolean` | `false` | No | Play a soft press sound. Off by default; a `SoundProvider` can mute it app-wide. |

### ButtonLink

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |
| `size` | `"sm" \| "md" \| "lg" \| "icon"` | `md` | No | Height and padding; "icon" is a square icon-only link. Default: "md" |
| `variant` | `"outline" \| "primary" \| "secondary" \| "ghost"` | `primary` | No | Visual style: filled, card, ghost or outline. Default: "primary" |
| `pressScale` | `number` | `0.97` | No | Scale while pressed. Default 0.97. |

### StatefulButton

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |
| `size` | `"sm" \| "md" \| "lg" \| "icon"` |  | No | Height and padding; "icon" is a square icon-only button. Default: "md" |
| `labels` | `Partial<{ loading: string; success: string; error: string; }>` |  | No | Override any built-in string. |
| `variant` | `"outline" \| "primary" \| "secondary" \| "ghost"` |  | No | Visual style: filled, card, ghost or outline. Default: "primary" |
| `pressScale` | `number` |  | No | Scale while pressed. Default 0.97: subtle, so the press reads as feedback, not a squash. |
| `ripple` | `boolean` |  | No | Spawn a Material-style ripple from the press point. Off by default. |
| `sound` | `boolean` |  | No | Play a soft press sound. Off by default; a `SoundProvider` can mute it app-wide. |
| `icon` | `ReactNode` |  | No | Trailing icon shown only while idle. |
| `state` | `"success" \| "loading" \| "idle" \| "error"` | `idle` | No | Which state to show. Loading also disables the button. Default: "idle" |
| `loadingText` | `ReactNode` |  | No | Text shown while loading. Default: "Loading" |
| `successText` | `ReactNode` |  | No | Text shown on success. Default: "Done" |
| `errorText` | `ReactNode` |  | No | Text shown on error. Default: "Try again" |

### MagneticButton

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` |  | No | Classes merged onto the root element. |
| `size` | `"sm" \| "md" \| "lg" \| "icon"` |  | No | Height and padding; "icon" is a square icon-only button. Default: "md" |
| `variant` | `"outline" \| "primary" \| "secondary" \| "ghost"` |  | No | Visual style: filled, card, ghost or outline. Default: "primary" |
| `pressScale` | `number` |  | No | Scale while pressed. Default 0.97: subtle, so the press reads as feedback, not a squash. |
| `ripple` | `boolean` |  | No | Spawn a Material-style ripple from the press point. Off by default. |
| `sound` | `boolean` |  | No | Play a soft press sound. Off by default; a `SoundProvider` can mute it app-wide. |
| `strength` | `number` | `0.25` | No | Magnetic pull strength. Default 0.25. |
| `magneticClassName` | `string` |  | No | Class applied to the magnetic wrapper. |

## About Button

Button is a set of animated React buttons built with Framer Motion and Tailwind CSS. The base Button scales down on press with a spring, lifts slightly on hover, and comes in primary, secondary, ghost and outline variants with an optional Material-style press ripple. StatefulButton swaps between idle, loading, success and error with a letter cascade and resizing width, MagneticButton is pulled toward the cursor, and MetallicButton frames a neutral surface with a chrome rim and a traveling reflection.

### When to use it

- A form submit or save action should show loading, success and error states without a separate spinner component.
- A landing page needs a primary call to action with a tactile press and an eye-catching magnetic or metallic style.
- An app needs one consistent button set with sizes, variants and an icon size for toolbars.

### Accessibility

Every variant renders a native button element (ButtonLink renders an anchor), so Enter, Space and focus work as usual. StatefulButton disables itself and sets aria-busy while loading, and its label sits in a polite live region so the new state text is announced. With reduced motion enabled, the press scale, ripple and letter cascade are removed, MetallicButton's reflection stops, and the magnetic pull is turned off; the magnetic pull is also skipped on devices that cannot hover.

### FAQ

**How do I make an animated button in React with Framer Motion?**

Install the variant you need and render Button with a variant and size. It accepts every motion button prop, and pressScale changes how far it shrinks on press. Set ripple to add the press ripple.

**How do I show a loading state on a button?**

Use StatefulButton and set state to idle, loading, success or error from your own logic. loadingText, successText and errorText change the label for each state, and icon adds a trailing icon in the idle state.

**Can I use the button as a link?**

Yes. ButtonLink takes the same variant, size and pressScale props as Button and renders an anchor, so it works with href or wrapped by a router link.

## React Native

A React Native version ships in beUI Native. The detail JSON has every file to copy.

```bash
npx expo install react-native-reanimated react-native-worklets
npm install uniwind tailwindcss
```

- Native detail: https://beui.dev/native/r/button
- GitHub: https://github.com/starc007/beui-native/tree/main/src/components/button

## Source

- Registry detail: https://beui.dev/r/button
- Raw source: https://beui.dev/r/button/raw
- GitHub: https://github.com/starc007/ui-components
