Modus UI

Resend Button

React Native (Expo)

A React Native resend code link that waits out a countdown, pulses when ready and starts over after each press.

The "Resend code" link under a verification form. It starts out waiting, showing the seconds left, and becomes pressable when the wait is over, pulsing once to say so. Pressing it calls onResend and starts the wait again. The time is not announced each second, only "You can resend now". Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.

Installation

CLI

npx @modus-ui/cli add resend-button

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/resend-button.tsx.
  3. Paste the code.

It needs no packages beyond react-native, which your Expo or React Native app already has.

Usage

tsx
import { ResendButton } from "@/components/ui/resend-button";

export default function Example() {
  return <ResendButton onResend={() => console.log("sent again")} />;
}

Props

PropTypeDefaultDescription
onResend() => void-Called when pressed after the wait; the wait then restarts.
secondsnumber30How long to wait before it can be pressed, in seconds.
labelstring"Resend code"The button's text.
colorsPartial<ResendButtonColors>-Overrides accent and disabled.
styleStyleProp<ViewStyle>-Style for the button.

Comments

  • No comments yet.