# Button: Custom labels

> `loadingLabel`, `successLabel` and `errorLabel` replace the text for each state. Each label flips in while the old one flips out.

Example: https://hextaui.com/docs/button/examples/custom-labels
Component docs: https://hextaui.com/docs/button.md

## Add this example

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

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

## Source

```tsx title="components/examples/button/custom-labels.tsx"
"use client"

import { IconDeviceFloppy } from "@tabler/icons-react"

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

function wait(ms: number) {
  return new Promise<void>((resolve) => setTimeout(resolve, ms))
}

async function fail(ms: number) {
  await wait(ms)
  throw new Error("Request failed")
}

export function ButtonCustomLabels() {
  return (
    <div className="flex flex-wrap items-center justify-center gap-2">
      <Button
        feedback
        loadingLabel="Saving…"
        successLabel="Saved"
        errorLabel="Couldn’t save"
        onClick={() => wait(1200)}
      >
        <IconDeviceFloppy data-icon="inline-start" />
        Save
      </Button>
      <Button
        feedback
        variant="outline"
        loadingLabel="Saving…"
        successLabel="Saved"
        errorLabel="Couldn’t save"
        onClick={() => fail(1200)}
      >
        <IconDeviceFloppy data-icon="inline-start" />
        Save
      </Button>
    </div>
  )
}
```

## 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. |
| `loadingLabel` | `ReactNode` | – | Shown next to the spinner. Hidden on icon sizes. |
| `successLabel` | `ReactNode` | `"Done"` |  |
| `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)
- [Smooth width](https://hextaui.com/docs/button/examples/smooth-width.md)
- [Error details](https://hextaui.com/docs/button/examples/error-details.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)
