SwipeUI

Checkout button

A full-width checkout action with an exact rolling total and centered payment feedback.

npx @swipeui/cli add checkout-button
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Submit an order with its total visible on the same action.
  • Explain why checkout is unavailable with disabledReason.

When not to use it

  • Replace a payment provider, validate a charge or guarantee server idempotency.
  • Show transfer progress; use Download button.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add checkout-button
  • Adds components/swipeui/ui/checkout-button.tsx, components/swipeui/ui/use-checkout-button.ts and 13 shared helpers.
  • Installs react-native-reanimated, uniwind, react-native-svg, react-native-worklets, clsx, tailwind-merge, expo-haptics, class-variance-authority. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/actions.tsx
import { CheckoutButton } from '@/components/swipeui/ui/checkout-button';

<CheckoutButton
  total={24}
  currency="USD"
  onPress={payForOrder}
  disabledReason={deliveryMissing ? 'Choose delivery' : undefined}
/>;

Examples

cart, states. The app and public preview use the same content and variant names. Demo settings sit outside the component and outcome feedback stays on the action.

Settings

SettingDefaultBehavior
total0Numeric total in major currency units, or a caller-formatted amount.
currency'USD'ISO 4217 currency for numeric totals.
localedevice localeIntl number locale.
labelsEnglish labelsIndependent idle/pending/success/error/retry words.
disabledReasonundefinedVisible explanation underneath; also disables checkout.
securetrueShow a neutral lock before the action.
amountMotiontrueRoll the exact formatted total independently.
onPressundefinedCheckout work; return the payment promise.
onSuccessundefinedReports the latest completed payment.
onErrorundefinedReports the latest failure.
minPending1200Pending visibility in milliseconds.
resetAfterundefinedFeedback lifetime in milliseconds; undefined retains the result.
shakeOnErrortrueShake once when payment fails.
disabledfalseDisables activation.
motionapp feelShared motion override.
hapticstrueIndependent press/success/error notifications or global switch.
variant'solid'How much the button stands out: solid, tinted (a soft wash of the tone), outline, ghost (no fill until pressed) or plain (text only). The 1.x names default, secondary and destructive still work as solid primary, neutral and destructive.
tone'primary' for solid, tinted and plain; 'neutral' for outline and ghostThe colour family: primary, neutral, destructive or success.
sizelgShared sm/md/lg sizes; checkout stretches to its container width.
shape'preset'preset follows your preset's control radius; pill is a capsule.
loadingfalseShows a spinner, reports busy and ignores taps.
loadingLabelabsentLabel shown while loading; defaults to the children.
loadingPlacementendReplace the total with a spinner; start and center remain available.
labelMorph'fade'How a changed text label arrives: fade (the new label rises in as the old one fades), characters (only the changed letters roll in) or none. The width springs to fit either way.
highlighttrueA faint rim of light along the top edge of solid buttons.
glowfalseA soft shadow in the tone's colour under solid buttons.
pressEffect'both'Feedback while pressed: both scales and washes the surface, scale, wash or none. Text-only buttons dim their label instead of washing.
disabledStyle'muted'How a disabled button looks: muted mutes its fill and label; dim halves its opacity.
paletteBUTTON_PALETTEColours that belong to the button's material rather than the theme (the top highlight).
classNameabsentClasses merged over the style.
textClassNameabsentClasses for the label text.
styleabsentStyle escape hatch for the container.
accessibilityLabelcurrent labelOptional spoken-name override.
testIDundefinedRoot identifier; parts append suffixes.
haptics.presstrueImpact for an accepted checkout.
haptics.successtrueSuccess notification after work settles.
haptics.errortrueError notification after failed work.

Composition and behavior

Return the actual checkout promise from onPress. The caller owns provider integration, idempotency and reconciliation. total accepts a preformatted string or a finite number with currency and locale. resetAfter is optional; success remains settled until reset or remount by default.

The action sits at the start and the caller-formatted or Intl-formatted total at the end. Numeric totals use major currency units.

Promise work locks repeated payment intent, keeps confirmation beside the end spinner and reports success or a destructive retry on the control.

disabledReason disables activation and exposes the visible reason as an accessibility hint; secure independently adds a neutral lock.

API reference

PropTypeDefaultDescription
layout?union—

Optional layout transition for composed controls; derive its values from useMotion.

motion?MotionOverrideapp feel

The app's press character, or a local override. The app's motion feel, or a local override for the press, label and width springs. Shared motion override.

variant?ButtonVariant'solid'

How much the button stands out: solid, tinted (a soft wash of the tone), outline, ghost (no fill until pressed) or plain (text only). The 1.x names default, secondary and destructive still work as solid primary, neutral and destructive.

tone?ButtonTone'primary' for solid, tinted and plain; 'neutral' for outline and ghost

The colour family: primary, neutral, destructive or success.

size?ButtonSize'md'

The height: sm 36pt (with a 44pt touch target), md 44pt, lg 52pt.

shape?ButtonShape'preset'

preset follows your preset's control radius; pill is a capsule.

block?booleanfalse

Stretches the button to the full width of its container.

leadingIcon?ButtonIcon—

Content before the label: a node, or a function that receives { color, size }.

trailingIcon?ButtonIcon—

Content after the label: a node, or a function that receives { color, size }.

trailingIconNudge?booleanfalse

Slides the trailing icon a little forward while pressed, mirrored in right-to-left layouts.

loadingLabel?string—

Label shown while loading; defaults to the children.

singleLine?booleanfalse

Keep string labels and loading words on one clipped line.

labelMorph?ButtonLabelMorph'fade'

How a changed text label arrives: fade (the new label rises in as the old one fades), characters (only the changed letters roll in) or none. The width springs to fit either way.

highlight?booleantrue

A faint rim of light along the top edge of solid buttons.

glow?booleanfalse

A soft shadow in the tone's colour under solid buttons.

pressEffect?ButtonPressEffect'both'

Feedback while pressed: both scales and washes the surface, scale, wash or none. Text-only buttons dim their label instead of washing.

disabledStyle?ButtonDisabledStyle'muted'

How a disabled button looks: muted mutes its fill and label; dim halves its opacity.

glassStatus?ThemeSurfaceTone—

Keeps a completed or failed action’s Glass status visible when the control is locked.

palette?Partial<ButtonPalette>BUTTON_PALETTE

Colours that belong to the button's material rather than the theme (the top highlight).

className?string—

Classes merged over the style.

textClassName?string—

Classes for the label text.

style?StyleProp<ViewStyle>—

Style escape hatch for the container.

onPress?(() => void | Promise<void>)undefined

Checkout work; return the payment promise.

onSuccess?(() => void)undefined

Reports the latest completed payment.

onError?((error: unknown) => void)undefined

Reports the latest failure.

minPending?number1200

Pending visibility in milliseconds.

resetAfter?numberundefined

Feedback lifetime in milliseconds; undefined retains the result.

shakeOnError?booleantrue

Shake once when payment fails.

haptics?uniontrue

Independent press/success/error notifications or global switch.

total?string | number0

Numeric total in major currency units, or caller-formatted text.

currency?string'USD'

ISO 4217 currency for numeric totals.

locale?stringdevice locale

Intl number locale.

labels?Partial<object>Pay / Confirming order / Paid / Payment failed / Try again

Independent lifecycle words.

disabledReason?stringundefined

Visible disabled explanation, also announced.

secure?booleantrue

Show a neutral lock before the action.

unlockOnPending?booleantrue

Morph the lock open while confirming, independent of other motion.

resultMotion?booleantrue

Move the icon and label into the center for the result.

amountMotion?booleantrue

Roll the exact total independently.

loadingPlacement?"center" | "end" | "start"'end'

Spinner replaces the price; start and center remain available.

Review gates

Founder app and existing pnpm-dev visual acceptance remains open. Native runtime, VoiceOver/TalkBack, haptics, motion, Dynamic Type, RTL and recordings remain pending founder-scheduled 7.9. Source, bundle and unit checks do not establish visual or native acceptance.

SettingDefaultBehavior
unlockOnPendingtrueOpen the secure lock while confirming; other motion remains independent.
resultMotiontrueMove the current message into the center for success/failure.

Checkout shows Pay and its total at opposite ends. During work the lock opens, the label becomes Confirming order, and the price becomes the loader. The centered outcome uses a tinted green surface with the tick and Paid in the same green. Both boards reuse the Quantity product row, followed by Checkout. Simulation/reset controls follow the compact-control standard.

Behavior and gestures

  • Pay and the exact total sit at logical start/end. On payment, the lock opens, Confirming order replaces Pay, and a spinner replaces the amount.
  • The current icon and words merge into the center for success or retry; success uses a green tinted surface with matching green tick and Paid.
  • The caller owns payment work; serial async intent, minimum pending, disabled explanations, unmount safety and retry remain in useCheckoutButton.

Accessibility

  • Named controls expose unavailable, busy and selected/progress state where applicable. Decorative layers are excluded from interaction.
  • Meaningful outcome/availability announcements are distinct from clocks and decorative effects. Native VoiceOver/TalkBack, Dynamic Type, RTL and touch evidence remain pending for 7.9.

Motion

  • Uses the press, morph, number and ambient motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Every decorative duration/spring comes from the shared role helpers. Content clocks remain independent of motion feel.
  • Reduce Motion retains readable outcome/progress feedback. Native motion/performance review remains pending.

Performance

  • No new package, network service, telemetry or proprietary source.
  • Async results and content timers clean up or invalidate after unmount; UI animation values stay on the UI thread.

Notes for AI

  • Return the actual checkout promise from onPress. The caller owns provider integration, idempotency and reconciliation. total accepts a preformatted string or a finite number with currency and locale. resetAfter is optional; success remains settled until reset or remount by default.
  • Founder app/web acceptance and all native runtime, accessibility, haptics, motion and recordings remain pending for 7.9.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items