# Button: Error details

> Pass a function to `errorLabel` to show the rejection reason. While the pointer or keyboard focus stays on the button, the error stays on screen.

Example: https://hextaui.com/docs/button/examples/error-details
Component docs: https://hextaui.com/docs/button.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/button-error-details.json
```

This adds `components/examples/button/error-details.tsx` with the Button component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/button/error-details.tsx"
"use client"

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

export function ButtonErrorDetails() {
  return (
    <Button
      feedback
      variant="outline"
      errorLabel={(error) =>
        error instanceof Error ? error.message : "Failed"
      }
      onClick={async () => {
        await new Promise((resolve) => setTimeout(resolve, 700))
        throw new Error("Card declined")
      }}
    >
      Pay $24
    </Button>
  )
}
```

## Props in this example

### Button

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"default" \| "outline" \| "secondary" \| "ghost" \| "ghost-destructive" \| "destructive" \| "link"` | `"default"` |  |
| `feedback` | `boolean` | `false` | Track the promise returned from onClick and show its status. |
| `onClick` | `(event) => unknown` | – | Return a promise to drive feedback. |
| `errorLabel` | `ReactNode \| (error: unknown) => ReactNode` | `"Failed"` |  |

## More Button examples

- [Variants](https://hextaui.com/docs/button/examples/variants.md)
- [Sizes](https://hextaui.com/docs/button/examples/sizes.md)
- [Pill](https://hextaui.com/docs/button/examples/pill.md)
- [With icon](https://hextaui.com/docs/button/examples/with-icon.md)
- [Disabled](https://hextaui.com/docs/button/examples/disabled.md)
- [Custom labels](https://hextaui.com/docs/button/examples/custom-labels.md)
- [Smooth width](https://hextaui.com/docs/button/examples/smooth-width.md)
- [Forms](https://hextaui.com/docs/button/examples/form.md)
- [Icon buttons](https://hextaui.com/docs/button/examples/icon-feedback.md)
- [Feedback on every variant](https://hextaui.com/docs/button/examples/variants-feedback.md)
- [Controlled loading](https://hextaui.com/docs/button/examples/controlled-loading.md)
- [Controlled status](https://hextaui.com/docs/button/examples/controlled-status.md)
- [As a link](https://hextaui.com/docs/button/examples/link.md)
- [Right to left](https://hextaui.com/docs/button/examples/rtl.md)
