logo

Aki UI

アキ ウイ

Dialog Stack

ダイアログスタック

A multi step dialog where each step stays behind the next one, so the stack builds up as you move forward. Portal and open state from Radix Dialog, animation from Framer Motion and Tailwind CSS.

Installation

Install the following dependencies:1

npm install @radix-ui/react-dialognpm install framer-motion

Copy and paste the following code into a new component file:2

"use client"

import * as Dialog from "@radix-ui/react-dialog"
import { AnimatePresence, motion } from "framer-motion"
import type {
ButtonHTMLAttributes,
Dispatch,
HTMLAttributes,
MouseEvent,
MouseEventHandler,

How to use it3

"use client"

import {
DialogStack,
DialogStackBody,
DialogStackClose,
DialogStackContent,
DialogStackDescription,
DialogStackFooter,
DialogStackHeader,

Props

DialogStack

NameDefaultDescription
children

ReactNode

Trigger, overlay and body of the stack

open

boolean

Controlled open state

defaultOpenfalse

boolean

Open state when the stack is uncontrolled

onOpenChange

(open: boolean) => void

Called when the stack opens or closes

clickablefalse

boolean

Clicking a dialog behind the active one jumps back to it

darkfalse

boolean

Applies the dark class inside the portal, since the portal escapes the preview wrapper

className

string

Additional classes on the wrapper

DialogStackTrigger

NameDefaultDescription
children

ReactNode

Content of the trigger button

asChildfalse

boolean

Merges the click handler into the child instead of rendering a button

onClick

(event) => void

Called after the stack is opened

className

string

Additional classes on the trigger

DialogStackOverlay

NameDefaultDescription
className

string

Additional classes on the backdrop

DialogStackBody

NameDefaultDescription
children

ReactElement | ReactElement[]

The DialogStackContent steps, each one receives its index

className

string

Additional classes on the centering container

DialogStackContent

NameDefaultDescription
children

ReactNode

Content of a single step

index0

number

Position in the stack, injected by DialogStackBody

offset10

number

Vertical gap in pixels between two stacked dialogs

className

string

Additional classes on the dialog surface

DialogStackHeader

NameDefaultDescription
children

ReactNode

Usually a title and a description

className

string

Additional classes on the header

DialogStackTitle

NameDefaultDescription
children

ReactNode

Title of the step

className

string

Additional classes on the title

DialogStackDescription

NameDefaultDescription
children

ReactNode

Supporting copy under the title

className

string

Additional classes on the description

DialogStackFooter

NameDefaultDescription
children

ReactNode

Navigation buttons, aligned to the right

className

string

Additional classes on the footer

DialogStackNext

NameDefaultDescription
children"Next"

ReactNode

Label of the button

asChildfalse

boolean

Merges the click handler into the child instead of rendering a button

className

string

Additional classes on the button

DialogStackPrevious

NameDefaultDescription
children"Previous"

ReactNode

Label of the button

asChildfalse

boolean

Merges the click handler into the child instead of rendering a button

className

string

Additional classes on the button

DialogStackClose

NameDefaultDescription
children"Close"

ReactNode

Label of the button

asChildfalse

boolean

Merges the click handler into the child instead of rendering a button

className

string

Additional classes on the button