Applies to every preview on the site.
Installation
One command copies the source into your app — you own the code and can change anything.
After you add the file, import it like any local component:
import { StatefulButton } from "@/components/ui/stateful-button";Or add it with the CLI (installs any missing peers):
Usage
useKit(). Wrap your app in <KitProvider accent="#6366f1" radius={14}> to re-skin every component at once.Like this? There's a lot more in Pro Pro
12 full screens built from the same kit — install them the same way.
Props
| Prop | Type | Default |
|---|---|---|
| children Label while idle. | string | — |
| state Controlled state. Omit it to let a Promise from onPress drive the button. | "idle" | "loading" | "success" | "error" | — |
| onPress Resolve → success, reject → error, then back to idle (when state is not set). | () => void | Promise<unknown> | — |
| loadingText Label while loading. | string | children |
| successText Label after success. | string | labels.done |
| errorText Label after an error. | string | labels.failed |
| variant Idle look; success and error tint it green / red. | "primary" | "secondary" | "outline" | "ghost" | "primary" |
| size 36 / 46 / 54pt tall. | "sm" | "md" | "lg" | "md" |
| color Tint for the idle look. | string | theme primary |
| resetAfter ms the result shows before returning to idle (self-driving only). | number | 1600 |
| minLoading Minimum ms of spinner (self-driving only). | number | 500 |
| onStateChange Called on every state change. | (state) => void | — |
| pill Fully rounded ends. | boolean | false |
| block Stretch to the parent's width (no width animation). | boolean | false |
| disabled Blocks presses and dims the button. | boolean | false |
| haptics Taps on press, success and error. | boolean | true |
| accessibilityLabel Override what screen readers hear. | string | current label |
| textStyle Style for the label letters. | StyleProp<TextStyle> | — |
| style Style for the outer wrapper (margins, alignment). | StyleProp<ViewStyle> | — |
| className Tailwind classes on the root when using NativeWind or Uniwind. Prefer style for StyleSheet overrides. | string | — |
Customization
You own the source file — tune appearance with props (no fork required for most tweaks). For brand-wide colours and radius, wrap your app in KitProvider; for one-off looks, use the style props below.
Design theme
Open Design theme on the live preview — accent, corner radius and font update every variant instantly (same as KitProvider in your app).
Variants
Pick the Variants chip above the preview, or set variant=… — "primary" | "secondary" | "outline" | "ghost".
Style props
React Native style and typed slots like fieldStyle, plus optional root className when you use NativeWind or Uniwind (cnProps from kit).
- variant
- "primary" | "secondary" | "outline" | "ghost" · default "primary"Idle look; success and error tint it green / red.
- size
- "sm" | "md" | "lg" · default "md"36 / 46 / 54pt tall.
- color
- string · default theme primaryTint for the idle look.
- textStyle
- StyleProp<TextStyle>Style for the label letters.
- style
- StyleProp<ViewStyle>Style for the outer wrapper (margins, alignment).
- className
- stringTailwind classes on the root when using NativeWind or Uniwind. Prefer style for StyleSheet overrides.
Map tokens from your design system on Bring your design system or read Theming for KitProvider and NativeWind / Uniwind setup.
Behaviour & accessibility
- Touch
- Springs to 96% on press; at least 44pt tall to touch (hitSlop on the small size). Presses are ignored while loading and, when self-driving, until it returns to idle.
- Motion
- Label letters roll on the native driver; width, colour and the check / cross stroke spring or ease on the JS driver on separate views.
- Reduced motion
- Labels crossfade instead of rolling and the width changes instantly.
- Haptics
- Light tap on press, success / error notification on the result (expo-haptics; turn off with haptics={false}).
- Screen readers
- Button role with busy and disabled state; every new label (Saving…, Saved, Failed) is announced.
- Platforms
- iOS, Android and web.
Source
FAQ
How do I make a loading button in React Native?
npx @expokit/cli@latest add stateful-button in your Expo or React Native project and it copies a ready-made loading button into your app as plain TypeScript you can edit. It works on iOS, Android and web, and in Expo Go.Does Stateful Button work in Expo Go?
react-native-svg, expo-haptics) are all included in Expo Go.How do I add Stateful Button to my Expo app?
npx @expokit/cli@latest add stateful-button in your project. The CLI copies the component's source into your app and installs react-native-svg, expo-haptics, so the code is yours to change.Is Stateful Button free?
Can I change how Stateful Button looks?
useKit(), so wrapping your app in <KitProvider accent radius> re-skins it with every other ExpoKit component. The code lives in your project, so you can also edit anything directly.