Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Pay Button

ProNew

A pay, donate or subscribe button with amount presets, optional shipping/tax breakdown, custom amounts and accepted-method marks. It calls onPay; your code talks to the provider.

Installation

pnpm dlx shadcn@latest add @viewport/pay-button

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
mode"pay" | "donate" | "subscribe"

What the button does: a one-off purchase, a donation, or a recurring plan.

"pay"
labelstring

Text before the brand name. Defaults to "Buy now with", "Donate with" or "Subscribe with".

—
brandBrand | null

The brand shown on the button, from Brand Icon. Pass `null` for a plain button with only the label.

"paypal"
amountnumber

A fixed amount. Use it instead of `amounts` when the buyer has nothing to choose.

—
amountsnumber[]

Preset amounts the buyer picks from.

—
defaultAmountnumber

The preset that starts selected. Defaults to the first one.

—
allowCustomboolean

Adds a field for typing any amount.

false
minnumber

Smallest amount accepted in the custom field.

1
maxnumber

Largest amount accepted in the custom field.

10000
currencystring

ISO 4217 currency code.

"USD"
shippingnumber

Flat delivery charge, in major currency units.

0
tax{ type: "fixed" | "percentage"; value: number }

Flat currency amount or percent of the selected price.

—
localestring

BCP 47 locale used to format amounts.

"en-US"
interval"week" | "month" | "year"

How often a subscription renews.

"month"
methodsPayMethod[]

Marks under the button for the methods you accept. An empty list hides the row.

["visa", "mastercard", "amex", "discover"]
color"gold" | "blue" | "black" | "white"

Button color.

"gold"
shape"pill" | "rect"

Button outline.

"pill"
titleReact.ReactNode

A heading above the amounts.

—
descriptionReact.ReactNode

Supporting text under the heading.

—
onPay(payment: Payment) => void | Promise<unknown>

Called with the payment to start. Hand it to your own checkout. Return a promise to show the busy state; resolve it for success, reject it for the error state.

—
successTextstring

Shown on the button after `onPay` resolves.

"Thank you!"
errorTextstring

Shown under the button after `onPay` rejects.

"The payment did not go through. Please try again."
disabledbooleanfalse
classNamestring—

Accessibility

  • Amount presets are a native radio group inside a fieldset, so arrow keys move between them.
  • The custom amount is a labelled field; a bad amount is announced with role=alert and marked aria-invalid.
  • While the payment is pending the button is aria-busy and the result is announced in a live region.
  • Each method mark has a text name, and the row is a labelled list.
  • The spinner and the error shake are stilled under reduced motion.