BNA

BNA UI
26

Onboarding

A customizable multi-step onboarding flow with smooth animations and gesture support.

Installation

pnpm dlx bna-ui add onboarding

Usage

import { Onboarding, OnboardingStep } from '@/components/ui/onboarding';
const steps: OnboardingStep[] = [
  {
    id: '1',
    title: 'Welcome',
    description: 'Get started with our amazing app',
    icon: <WelcomeIcon />,
  },
  {
    id: '2',
    title: 'Explore Features',
    description: 'Discover all the powerful features we offer',
    icon: <FeaturesIcon />,
  },
  {
    id: '3',
    title: 'Get Started',
    description: "You are all set! Let's begin your journey",
    icon: <StartIcon />,
  },
];
 
<Onboarding
  steps={steps}
  onComplete={() => console.log('Onboarding completed')}
  onSkip={() => console.log('Onboarding skipped')}
/>;

Examples

Default

With Images

Custom Styling

No Skip Button

Swipe Disabled

Custom Buttons

With Hook

API Reference

Onboarding

The main onboarding component that manages the multi-step flow.

PropTypeDefaultDescription
stepsOnboardingStep[]-Array of onboarding steps to display.
onComplete() => void-Callback when onboarding is completed.
onSkip() => void-Callback when onboarding is skipped.
showSkipbooleantrueWhether to show the skip button.
showProgressbooleantrueWhether to show progress dots.
swipeEnabledbooleantrueWhether to enable swipe gestures.
primaryButtonTextstring"Get Started"Text for the primary button on the last step.
skipButtonTextstring"Skip"Text for the skip button.
nextButtonTextstring"Next"Text for the next button.
backButtonTextstring"Back"Text for the back button.
styleViewStyle-Additional styles for the container.
childrenReactNode-Custom content to render in each step.

OnboardingStep

Configuration object for each step in the onboarding flow.

PropTypeDefaultDescription
idstring-Unique identifier for the step.
titlestring-Title text for the step.
descriptionstring-Description text for the step.
imageReactNode-Custom image component for the step.
iconReactNode-Icon component (used if no image provided).
backgroundColorstring-Custom background color for the step.

useOnboarding Hook

A hook for managing onboarding state in your application.

const {
  hasCompletedOnboarding,
  currentOnboardingStep,
  setCurrentOnboardingStep,
  completeOnboarding,
  resetOnboarding,
  skipOnboarding,
} = useOnboarding();

Returns

PropertyTypeDescription
hasCompletedOnboardingbooleanWhether the user has completed onboarding.
currentOnboardingStepnumberCurrent step index in the onboarding flow.
setCurrentOnboardingStep(step: number) => voidFunction to set the current step.
completeOnboarding() => Promise<void>Function to mark onboarding as completed.
resetOnboarding() => voidFunction to reset onboarding state.
skipOnboarding() => Promise<void>Function to skip and complete onboarding.

Features

  • Smooth Animations: Built with react-native-reanimated for fluid transitions
  • Gesture Support: Swipe left/right to navigate between steps
  • Customizable: Extensive customization options for styling and behavior
  • Progress Indicators: Visual progress dots to show current step
  • Flexible Content: Support for images, icons, and custom content
  • State Management: Built-in hook for managing onboarding state
  • Accessibility: Built with accessibility features in mind
  • TypeScript: Full TypeScript support with proper type definitions

Accessibility

The Onboarding component is built with accessibility in mind:

  • Proper semantic structure for screen readers
  • Keyboard navigation support
  • High contrast support for progress indicators
  • Descriptive labels for navigation buttons
  • Support for dynamic text sizing
  • Focus management between steps