About
Onboarding Questionnaire component. It manages the layout, animation, and internal state of the sliders, reporting the final values via callbacks.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Onboarding to your project and fits it to your theme.
Code
How Onboarding is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
// demo.tsx
"use client";
import { useState } from "react";
import {
OnboardingQuestionnaire,
QuestionnaireQuestion,
} from "@/components/ui/onboarding-1"; // Adjust path as needed
import {
Wallet,
Sparkles,
Sunrise,
Moon,
User,
Users,
} from "lucide-react"; // Using lucide-react for icons
/**
* Demo component showcasing the OnboardingQuestionnaire.
*/
export default function OnboardingDemo() {
// In a real app, this state would be managed by a parent component (e.g., a step manager)
const [progress, setProgress] = useState(33);
const [currentImage, setCurrentImage] = useState(
"https://cdn.21st.dev/assets/mirror/5f/5f32c89359071f91ffd6ae6b48e20eba406caf739b3f2b7316a406b312d66afe.jpg",
);
const [showBackButton, setShowBackButton] = useState(false);
// Define the questions for this step
const questions: QuestionnaireQuestion[] = [
{
id: "spendingHabits",
label: "What best describes your travel spending habits?",
minLabel: "Budget conscious",
midLabel: "Reasonably priced",
maxLabel: "Luxurious",
minIcon: <Wallet className="w-3.5 h-3.5" />,
maxIcon: <Sparkles className="w-3.5 h-3.5" />,
defaultValue: 50,
},
{
id: "dailySchedule",
label:
"Would you rather get an early start on the day or do you prefer to stay out late?",
minLabel: "Early bird",
midLabel: "Evening person",
maxLabel: "Night owl",
minIcon: <Sunrise className="w-3.5 h-3.5" />,
maxIcon: <Moon className="w-3.5 h-3.5" />,
defaultValue: 70, // Defaulting towards Night owl
},
{
id: "socialPreference",
label:
"Do you have an independent streak when you travel, or do you seek out group camaraderie?",
minLabel: "Independent",
midLabel: "Solo explorer!",
maxLabel: "Social",
minIcon: <User className="w-3.5 h-3.5" />,
maxIcon: <Users className="w-3.5 h-3.5" />,
defaultValue: 20, // Defaulting towards Independent
},
];
// Handler for the "Next" button
const handleNext = (answers: Record<string, number>) => {
console.log("Answers:", answers);
// Simulate moving to the next step
setProgress(66);
setCurrentImage(
"https://cdn.21st.dev/assets/mirror/c7/c79619de8564ae4cbdf0ffffc5f1f1457d16cc9931a964578405821b6dc0fcff.jpg",
);
setShowBackButton(true);
alert("Check the console for the form data!");
};
// Handler for the "Back" button
const handleBack = () => {
console.log("Back clicked");
// Simulate moving to the previous step
setProgress(33);
setCurrentImage(
"https://cdn.21st.dev/assets/mirror/5f/5f32c89359071f91ffd6ae6b48e20eba406caf739b3f2b7316a406b312d66afe.jpg",
);
setShowBackButton(false);
};
return (
<OnboardingQuestionnaire
title="What do you like to do?"
questions={questions}
imageSrc={currentImage} // The image will animate when this src changes
progress={progress}
showBack={showBackButton}
onNext={handleNext}
onBack={handleBack}
onSaveAndExit={() => console.log("Save and exit clicked")}
/>
);
}














