Examples
Onboarding
Three pages that swipe like a native pager, with a progress bar that follows them, Skip to jump to the end, and one button that reads Next until the last page, where it becomes Get started. Swipe, tap the button, or use the arrow keys on the web.
Loading…
import { useState } from 'react'; import { StyleSheet, View } from 'react-native'; import { Button, Heading, Pager, Steps, Text, useTheme } from 'patine-ui'; import { Icon } from '@patine-ui/icons'; import type { IconName } from '@patine-ui/icons'; const PAGES: { icon: IconName; step: string; title: string; body: string }[] = [ { icon: 'calendar', step: 'Plan', title: 'Plan the week in a minute', body: 'Drop in dinners, school runs and bin days. Fieldnote lines them up so the week reads at a glance.', }, { icon: 'bell', step: 'Remind', title: 'A nudge, not a nag', body: 'One reminder at the time you choose. Snooze it from the lock screen when the day runs late.', }, { icon: 'users', step: 'Share', title: 'Share it with your home', body: 'Invite the people you live with. Everyone sees the same plan, and anyone can tick things off.', }, ]; const STEPS = PAGES.map((page) => ({ title: page.step })); export default function Onboarding() { const { colors } = useTheme(); const [page, setPage] = useState(0); const last = page === PAGES.length - 1; return ( <View style={[styles.screen, { backgroundColor: colors.background }]}> <View style={styles.top}> <Steps steps={STEPS} value={page} variant="progress" style={styles.progress} /> <Button variant="ghost" size="sm" disabled={last} onPress={() => setPage(PAGES.length - 1)}> Skip </Button> </View> <Pager value={page} onValueChange={setPage} showIndicator={false} accessibilityLabel="Welcome" style={styles.pager}> {PAGES.map((item) => ( <View key={item.title} style={styles.page}> <View style={[styles.art, { backgroundColor: colors.primaryMuted }]}> <Icon name={item.icon} size={56} color="primary" strokeWidth={1.25} /> </View> <Heading level={2} style={styles.center}> {item.title} </Heading> <Text color="textSecondary" style={styles.center}> {item.body} </Text> </View> ))} </Pager> <View style={styles.bottom}> <Button size="lg" onPress={() => setPage(last ? 0 : page + 1)}> {last ? 'Get started' : 'Next'} </Button> <Text size="sm" color="textSecondary" style={styles.center}> Already have an account? Sign in </Text> </View> </View> ); } const styles = StyleSheet.create({ screen: { flex: 1 }, top: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 24, paddingTop: 12 }, progress: { flex: 1 }, pager: { flex: 1 }, page: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16, paddingHorizontal: 32 }, art: { width: 160, height: 160, borderRadius: 80, alignItems: 'center', justifyContent: 'center', marginBottom: 16 }, center: { textAlign: 'center' }, bottom: { gap: 16, padding: 24 }, });
Components used
- Pager: one full-width page at a time, swiped or driven by
value - Steps:
variant="progress"as a bar that fills as the pages go by - Button: Next / Get started, and a
ghostSkip - Heading, Text, Patine Icons
How it works
- One
pagestate drives everything. The pager, the progress bar and the button all read it, so a swipe, a tap on Next and Skip stay in step. - The pages are plain children. Swap the icons for your own illustrations or a Lottie view; the pager sizes each page to itself.