A simple, lightweight, and customizable multi-step form component for React Native with TypeScript support.
Screen.Recording.2026-01-14.at.05.47.42.mov
npm install rnstepformor
yarn add rnstepformimport { RenderStepForm } from "rnstepform";
import { View, TextInput, Text } from "react-native";
import { useState } from "react";
function MyForm() {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
return (
<RenderStepForm
totalSteps={2}
indicatorColor="#00bcd4"
headText="Sign Up"
continueButtonColor="#00bcd4"
>
{(currentStep) => {
switch (currentStep) {
case 1:
return (
<View>
<Text>What's your name?</Text>
<TextInput
value={name}
onChangeText={setName}
placeholder="Enter your name"
/>
</View>
);
case 2:
return (
<View>
<Text>What's your email?</Text>
<TextInput
value={email}
onChangeText={setEmail}
placeholder="Enter your email"
/>
</View>
);
default:
return null;
}
}}
</RenderStepForm>
);
}Here's a full example with validation and completion handling:
import { RenderStepForm } from "rnstepform";
import { View, TextInput, Text } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { useState } from "react";
function CareerDetailsForm() {
const [name, setName] = useState("");
const [age, setAge] = useState("");
const [gradYear, setGradYear] = useState("");
const [profession, setProfession] = useState("");
// Validate each step
function isStepValid(step: number) {
switch (step) {
case 1:
return name !== "";
case 2:
return age !== "";
case 3:
return gradYear !== "";
case 4:
return profession !== "";
default:
return false;
}
}
// Handle form completion
function handleComplete() {
console.log("Form completed!", {
name,
age,
gradYear,
profession,
});
// Save data, navigate, etc.
}
return (
<SafeAreaView style={{ flex: 1, padding: 16, backgroundColor: "white" }}>
<RenderStepForm
totalSteps={4}
indicatorColor="aqua"
headText="Career Details"
continueButtonColor="aqua"
isStepValid={isStepValid}
onComplete={handleComplete}
>
{(step) => {
switch (step) {
case 1:
return (
<View>
<Text style={{ fontSize: 16 }}>Name</Text>
<TextInput
value={name}
onChangeText={setName}
placeholder="John Doe"
style={{
borderWidth: 1,
borderRadius: 8,
padding: 12,
fontSize: 16,
marginTop: 8,
}}
/>
</View>
);
case 2:
return (
<View>
<Text style={{ fontSize: 16 }}>Age</Text>
<TextInput
value={age}
onChangeText={setAge}
placeholder="25"
keyboardType="number-pad"
maxLength={2}
style={{
borderWidth: 1,
borderRadius: 8,
padding: 12,
fontSize: 16,
marginTop: 8,
}}
/>
</View>
);
case 3:
return (
<View>
<Text style={{ fontSize: 16 }}>Year of Graduation</Text>
<TextInput
value={gradYear}
onChangeText={setGradYear}
placeholder="2020"
keyboardType="numeric"
maxLength={4}
style={{
borderWidth: 1,
borderRadius: 8,
padding: 12,
fontSize: 16,
marginTop: 8,
}}
/>
</View>
);
case 4:
return (
<View>
<Text style={{ fontSize: 16 }}>Current Profession</Text>
<TextInput
value={profession}
onChangeText={setProfession}
placeholder="Software Engineer"
style={{
borderWidth: 1,
borderRadius: 8,
padding: 12,
fontSize: 16,
marginTop: 8,
}}
/>
</View>
);
default:
return null;
}
}}
</RenderStepForm>
</SafeAreaView>
);
}| Prop | Type | Required | Description |
|---|---|---|---|
totalSteps |
number |
✅ | Total number of steps in your form |
indicatorColor |
string |
✅ | Color of the progress bar |
headText |
string |
✅ | Header text displayed at the top |
continueButtonColor |
string |
✅ | Background color of the continue/complete button |
children |
(currentStep: number) => ReactNode |
✅ | Function that renders content based on current step |
isStepValid |
(step: number) => boolean |
❌ | Optional validation function. Return true to enable the continue button |
onComplete |
() => void |
❌ | Optional callback when user completes the last step |
- Automatic Navigation: The component handles forward/backward navigation automatically
- Progress Tracking: Shows current step and progress bar
- Validation: Disable the continue button until the current step is valid
- Completion: Execute custom logic when the user reaches the final step
✅ Simple and intuitive API
✅ Built-in progress indicator
✅ Step validation support
✅ Back button navigation
✅ TypeScript support
✅ Fully customizable colors
✅ Lightweight with zero dependencies
Full TypeScript support included:
import { RenderStepForm, RenderStepFormProps } from "rnstepform";
const props: RenderStepFormProps = {
totalSteps: 3,
indicatorColor: "#007AFF",
headText: "Setup",
continueButtonColor: "#007AFF",
children: (step) => <View />,
};- Wrap the component in a
SafeAreaViewfor proper spacing on notched devices - Use
isStepValidto prevent users from proceeding with invalid data - The
childrenfunction receives the current step number (1-indexed) - The continue button automatically becomes "Complete ➡️" on the last step
- Your number of
totalSteps, and Form switch cases should be the same. If you have 4 step form, then you should have 4 switch cases.
MIT