Skip to main content

MultinairePageView

Swipeable page view for onboarding flows, wizards, and carousels.

Basic Usage

import { MultinairePageView } from '@multinaire/multinaire-design';

<MultinairePageView
itemsMap={{
page1: <Page1 />,
page2: <Page2 />,
page3: <Page3 />,
}}
selectedItem="page1"
onChange={(item) => setSelectedItem(item)}
onFinish={() => completeOnboarding()}
/>

Props

PropTypeDefaultDescription
itemsMapRecord<T, ReactElement>Map of tab key to the React element rendered for that tab
selectedItemTCurrently selected tab key
scrollEnabledbooleantrueEnable scrolling when there are more tabs than fit the screen
isFinishLoadingbooleanfalseWhen true, the finish button becomes active after the last page
onChange(item: T) => voidCallback invoked when the user switches tabs
onFinish() => voidCallback invoked when the user completes the last page step
styleContainerStylePropsAdditional styles applied to the page content container (desktop only, overflow: hidden is always set)
paginationStyleContainerStylePropsAdditional styles applied to the pagination bar/sidebar

Examples

Onboarding Flow

const [currentPage, setCurrentPage] = useState('welcome');

<MultinairePageView
itemsMap={{
welcome: <WelcomeScreen />,
features: <FeaturesScreen />,
permissions: <PermissionsScreen />,
}}
selectedItem={currentPage}
onChange={setCurrentPage}
onFinish={() => {
completeOnboarding();
navigation.replace('Home');
}}
/>

With Loading State

<MultinairePageView
itemsMap={{
step1: <Step1 />,
step2: <Step2 />,
step3: <Step3 />,
}}
selectedItem={step}
onChange={setStep}
isFinishLoading={isSubmitting}
onFinish={handleSubmit}
/>

Disable Swipe

<MultinairePageView
scrollEnabled={false}
itemsMap={pages}
selectedItem={currentPage}
onChange={setCurrentPage}
onFinish={handleComplete}
/>
<MultinairePageView
itemsMap={images.reduce((acc, img, i) => ({
...acc,
[`image${i}`]: (
<MultinaireImage
source={{ uri: img.url }}
width="100%"
aspectRatio="16:9"
/>
),
}), {})}
selectedItem={`image${currentIndex}`}
onChange={(key) => setCurrentIndex(parseInt(key.replace('image', '')))}
onFinish={() => {}}
/>