# Subscribe button

A shadcn/ui newsletter signup for blogs and launch pages: the Subscribe pill stretches into an email field, then throws ribbons when you join.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available for the docs, pricing and about pages: append `.md` to the URL or send an `Accept: text/markdown` header (the home page answers the header too). An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

## At a glance

- **Good for:** Newsletter signups in blogs and site footers; Waitlists on product launch pages; Changelog and product update emails; Creator and indie maker mailing lists
- **Category:** Click & press, Loading & state · **Type:** Buttons, Text inputs · **Style:** Motion, Minimal, Dark mode
- **See it:** [Live preview](https://www.craftui.space/docs/interactions/subscribe-button)

## Install

```bash
pnpm dlx shadcn@latest add https://www.craftui.space/r/subscribe-button.json
```

Free to install.

## Usage

```tsx
import SubscribeButton from "@/components/interactions/subscribe-button/subscribe-button";

export default function Page() {
  return <SubscribeButton />;
}
```

With no props it renders with demo content; pass your own through the props below.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `onSubscribe` | `(email: string) => Promise<unknown> \| unknown` | — | Sends the address. Return a promise: the bar shows the spinner until it resolves, and shows the error's message if it rejects. Without it the bar waits 2 s and succeeds (a stand-in). Not called by `demo`. |
| `labels` | `Partial<SubscribeButtonLabels>` | — | Replaces any of the default words (English). |
| `demo` | `boolean` | `false` | Plays the whole round trip on a loop — open, type an address, join, done — while in view and untouched, with no Tab stops. For previews and gallery cards. |
| `className` | `string` | — | Classes for the row. Every size is in em of its font size, so a text size class (`text-lg`, `text-[26px]`) scales the whole bar. |

### `SubscribeButtonLabels`

| Field | Type | Description |
| --- | --- | --- |
| `cta` (required) | `string` | The word on the closed pill. |
| `ctaLabel` (required) | `string` | Accessible name of the closed pill. |
| `field` (required) | `string` | Accessible name of the email field. |
| `placeholder` (required) | `string` | Placeholder of the email field. |
| `submit` (required) | `string` | The submit button's word. It never remounts; the suffixes grow on its end. |
| `pendingSuffix` (required) | `string` | Letters added to `submit` while the request runs ("Join" + "ing"). |
| `joinedSuffix` (required) | `string` | Letters added to `submit` once it succeeded ("Join" + "ed"). |
| `subscribed` (required) | `string` | The sentence the pill pulls in around when it's done. |
| `subscribing` (required) | `string` | Read out to screen readers while the request runs. |
| `empty` (required) | `string` | Error when the field is empty. |
| `invalid` (required) | `string` | Error when the address can't be an email. |
| `failed` (required) | `string` | Error when `onSubscribe` fails without a message of its own. |

## Files

The install adds:

- `components/interactions/subscribe-button/subscribe-button.tsx`
- `components/interactions/subscribe-button/DESIGN.md`

npm dependencies (installed for you): `motion`.