dialog-stack
kibo-ui-registry/dialog-stackFreeComponent
Composable stacked 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 component.
Live preview
live · rendered by the registry
Rendered by Kibo UI Registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.kibo-ui.com/r/dialog-stack.jsonSource
1"use client";23import { useControllableState } from "@radix-ui/react-use-controllable-state";4import { Portal } from "radix-ui";5import type {6 ButtonHTMLAttributes,7 Dispatch,8 HTMLAttributes,9 MouseEvent,10 MouseEventHandler,11 ReactElement,12 SetStateAction,13} from "react";14import {15 Children,16 cloneElement,17 createContext,18 useCallback,19 useContext,20 useEffect,21 useState,22} from "react";23import { cn } from "@/lib/utils";2425type DialogStackContextType = {26 activeIndex: number;27 setActiveIndex: Dispatch<SetStateAction<number>>;28 totalDialogs: number;29 setTotalDialogs: Dispatch<SetStateAction<number>>;30 isOpen: boolean;31 setIsOpen: Dispatch<SetStateAction<boolean>>;32 clickable: boolean;33};3435const DialogStackContext = createContext<DialogStackContextType>({36 activeIndex: 0,37 setActiveIndex: () => {},38 totalDialogs: 0,39 setTotalDialogs: () => {},40 isOpen: false,41 setIsOpen: () => {},42 clickable: false,43});4445type DialogStackChildProps = {46 index?: number;47};4849export type DialogStackProps = HTMLAttributes<HTMLDivElement> & {50 open?: boolean;51 clickable?: boolean;52 onOpenChange?: (open: boolean) => void;53 defaultOpen?: boolean;54};5556export const DialogStack = ({57 children,58 className,59 open,60 defaultOpen = false,61 onOpenChange,62 clickable = false,63 ...props64}: DialogStackProps) => {65 const [activeIndex, setActiveIndex] = useState(0);66 const [isOpen, setIsOpen] = useControllableState({67 defaultProp: defaultOpen,68 prop: open,69 onChange: onOpenChange,70 });7172 useEffect(() => {73 if (onOpenChange && isOpen !== undefined) {74 onOpenChange(isOpen);75 }76 }, [isOpen, onOpenChange]);7778 return (79 <DialogStackContext.Provider80 value={{81 activeIndex,82 setActiveIndex,83 totalDialogs: 0,84 setTotalDialogs: () => {},85 isOpen: isOpen ?? false,86 setIsOpen: (value) => setIsOpen(Boolean(value)),87 clickable,88 }}89 >90 <div className={className} {...props}>91 {children}92 </div>93 </DialogStackContext.Provider>94 );95};9697export type DialogStackTriggerProps =98 ButtonHTMLAttributes<HTMLButtonElement> & {99 asChild?: boolean;100 };101102export const DialogStackTrigger = ({103 children,104 className,105 onClick,106 asChild,107 ...props108}: DialogStackTriggerProps) => {109 const context = useContext(DialogStackContext);110111 if (!context) {112 throw new Error("DialogStackTrigger must be used within a DialogStack");113 }114115// … truncated
What it pulls in
npm packages
Files it writes
More from Kibo UI Registry
All 41 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| announcementannouncement | Kibo UI Registry | Components | Free | no deps | |
| avatar-stackavatar-stack | Kibo UI Registry | Components | Free | no deps | |
| bannerbanner | Kibo UI Registry | Components | Free | 2 deps | |
| calendarcalendar | Kibo UI Registry | Components | Free | 3 deps | |
| choiceboxchoicebox | Kibo UI Registry | Components | Free | 2 deps | |
| code-blockcode-block | Kibo UI Registry | Components | Free | 5 deps · 2 files | |
| color-pickercolor-picker | Kibo UI Registry | Components | Free | 3 deps | |
| comboboxcombobox | Kibo UI Registry | Components | Free | 2 deps |
