Onborda
An onboarding wizard flow for Next.js powered by framer motion
README
Onborda - Next.js onboarding flow
Onborda is a lightweight onboarding flow that utilises framer-motion for animations and tailwindcss for styling. Fully customisable pointers (tooltips) that can easily be used with shadcn/ui for modern web applications.
- Demo - onborda.vercel.app
Getting started
- ```bash
- # npm
- npm i onborda
- # pnpm
- pnpm add onborda
- # yarn
- yarn add onborda
- ```
Global layout.tsx
- ```tsx
- <OnbordaProvider>
- <Onborda steps={steps}>
- {children}
- </Onborda>
- </OnbordaProvider>
- ```
Components & page.tsx
Target anything in your app using the elements id attribute.
- ```tsx
- <div id="onborda-step1">Onboard Step</div>
- ```
Tailwind config
Tailwind CSS will need to scan the node module in order to include the classes used. See configuring source paths for more information about this topic.
Note _You only require this if you're not using a custom component.
- ```ts
- const config: Config = {
- content: [
- './node_modules/onborda/dist/**/*.{js,ts,jsx,tsx}' // Add this
- ]
- }
- ```
Custom Card
If you require greater control over the card design or simply wish to create a totally custom component then you can do so easily.
Prop | Type | Description |
---|---|---|
|---------------|------------------|----------------------------------------------------------------------| | ||
`step` | `Object` | The |
`currentStep` | `number` | The |
`totalSteps` | `number` | The |
`nextStep` | | | |
`prevStep` | | | |
`arrow` | | |
- ```tsx
- "use client"
- import type { CardComponentProps } from "onborda";
- export const CustomCard = ({
- step,
- currentStep,
- totalSteps,
- nextStep,
- prevStep,
- arrow,
- }: CardComponentProps) => {
- return (
- <div>
- <h1>{step.icon} {step.title}</h1>
- <h2>{currentStep} of {totalSteps}</h2>
- <p>{step.content}</p>
- <button onClick={prevStep}>Previous</button>
- <button onClick={nextStep}>Next</button>
- {arrow}
- </div>
- )
- }
- ```
Step object
Prop | Type | Description |
---|---|---|
|----------------|-------------------------------|---------------------------------------------------------------------------------------| | ||
`icon` | `React.ReactNode`, | An |
`title` | `string` | The |
`content` | `React.ReactNode` | The |
`selector` | `string` | A |
`side` | `"top"`, | Optional. |
`showControls` | `boolean` | Optional. |
`pointerPadding` | `number` | Optional. |
`pointerRadius` | `number` | Optional. |
`nextRoute` | `string` | Optional. |
`prevRoute` | `string` | Optional. |
Note _Both nextRoute and prevRoute have a 500ms delay before setting the next step, a function will be added soon to control the delay in case your application loads slower than this._
Example steps
- ```tsx
- [
- {
- icon: <>��</>,
- title: "Step 1",
- content: <>This is the first step</>,
- selector: "#onborda-step1",
- side: "top",
- showControls: true,
- pointerPadding: 10,
- pointerRadius: 10,
- nextRoute: "/foo",
- prevRoute: "/bar"
- }
- ]
- ```
Onborda Props
Property | Type | Description |
---|---|---|
|-----------------|----------------------------|---------------------------------------------------------------------------------------| | ||
`children` | `React.ReactNode` | Your |
`steps` | `Array[]` | An |
`showOnborda` | `boolean` | Optional. |
`shadowRgb` | `string` | Optional. |
`shadowOpacity` | `string` | Optional. |
`customCard` | `React.ReactNode` | Optional. |
- ```tsx
- <Onborda
- steps={steps}
- showOnborda={true}
- shadowRgb="55,48,163"
- shadowOpacity="0.8"
- cardComponent={CustomCard}
- >
- {children}
- </Onborda>
- ```