Composable stacked dialogs for shadcn/ui

Stacked dialog component inspired by Radix UI Dialog. Accessible. Customizable. Open Source. Pre-styled for shadcn/ui.

GitHub
GitHub
87

Installation

npx shadcn@latest add https://dialog-stack.haydenbleasel.com/registry.json

Description

The DialogStack component is a container for a series of dialogs, useful for creating a wizard, nested form or multi-step process. It provides a consistent layout and styling for each dialog, and includes navigation components to move between them.

Usage

<DialogStack>
  
  {/* Trigger */}
  <DialogStackTrigger>Open</DialogStackTrigger>
 
  {/* Overlay */}
  <DialogStackOverlay />
 
  {/* Body */}
  <DialogStackBody>
 
    {/* Dialog #1 */}
    <DialogStackContent>
      <DialogHeader>
        <DialogStackTitle>Title</DialogStackTitle>
        <DialogStackDescription>Description</DialogStackDescription>
      </DialogHeader>
      <p>Content</p>
      <DialogStackFooter>
        <DialogStackNext>Next</DialogStackNext>
      </DialogStackFooter>
    </DialogStackContent>
 
    {/* Dialog #2 */}
    <DialogStackContent>
      <DialogHeader>
        <DialogStackTitle>Title</DialogStackTitle>
        <DialogStackDescription>Description</DialogStackDescription>
      </DialogHeader>
      <p>Content</p>
      <DialogStackFooter>
        <DialogStackPrevious>Previous</DialogStackPrevious>
        <DialogStackNext>Next</DialogStackNext>
      </DialogStackFooter>
    </DialogStackContent>
 
    {/* Dialog #3 */}
    <DialogStackContent>
      <DialogHeader>
        <DialogStackTitle>Title</DialogStackTitle>
        <DialogStackDescription>Description</DialogStackDescription>
      </DialogHeader>
      <p>Content</p>
      <DialogStackFooter>
        <DialogStackPrevious>Previous</DialogStackPrevious>
        <DialogStackNext>Next</DialogStackNext>
      </DialogStackFooter>
    </DialogStackContent>
 
    {/* Dialog #4 */}
    <DialogStackContent>
      <DialogHeader>
        <DialogStackTitle>Title</DialogStackTitle>
        <DialogStackDescription>Description</DialogStackDescription>
      </DialogHeader>
      <p>Content</p>
      <DialogStackFooter>
        <DialogStackPrevious>Previous</DialogStackPrevious>
        <DialogStackNext>Next</DialogStackNext>
      </DialogStackFooter>
    </DialogStackContent>
 
    {/* Dialog #5 */}
    <DialogStackContent>
      <DialogHeader>
        <DialogStackTitle>Title</DialogStackTitle>
        <DialogStackDescription>Description</DialogStackDescription>
      </DialogHeader>
      <p>Content</p>
      <DialogStackFooter>
        <DialogStackPrevious>Previous</DialogStackPrevious>
        <DialogStackNext>Next</DialogStackNext>
      </DialogStackFooter>
    </DialogStackContent>
 
    {/* Dialog #6 */}
    <DialogStackContent>
      <DialogHeader>
        <DialogStackTitle>Title</DialogStackTitle>
        <DialogStackDescription>Description</DialogStackDescription>
      </DialogHeader>
      <p>Content</p>
      <DialogStackFooter>
        <DialogStackPrevious>Previous</DialogStackPrevious>
      </DialogStackFooter>
    </DialogStackContent>
  </DialogStackBody>
</DialogStack>

Props

All components accept the standard attributes relevant to their element and the className prop for custom styling. Below are the custom props for each component.

DialogStack

PropTypeDefaultDescription
clickablebooleanfalseWhether the user can click previous dialogs to navigate
openbooleanfalseWhether the dialog is open
onOpenChange(open: boolean) => voidundefinedCallback function to be called when the dialog is opened or closed

DialogStackTrigger

PropTypeDefaultDescription
asChildbooleanfalseWhether the component should render the child as a React element

DialogStackContent

PropTypeDefaultDescription
offsetnumber10The offset of the dialog

DialogStackNext

PropTypeDefaultDescription
asChildbooleanfalseWhether the component should render the child as a React element

DialogStackPrevious

PropTypeDefaultDescription
asChildbooleanfalseWhether the component should render the child as a React element