Skip to content

Dialog

A modal dialog with title, description and actions; a click opens it with a spring, a key press opens it instantly.

Base UI1.6 kB gzipSource Registry JSON

Dialog playground

Props

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/dialog.json

The CLI writes components/ikada/dialog.tsx and merges the ikada theme into your CSS. Or take it from the package: import { Dialog, DialogContent, DialogTitle, DialogDescription, DialogFooter } from "@sproutboat/ikada";

Usage

import { Dialog, DialogContent, DialogTitle, DialogDescription, DialogFooter } from "@/components/ikada/dialog";

<Dialog>
  <DialogTrigger render={<Button>Open dialog</Button>} />
  <DialogContent>
    <DialogTitle>Delete robin?</DialogTitle>
    <DialogDescription>This cannot be undone.</DialogDescription>
    <DialogFooter>
      <DialogClose render={<Button>Cancel</Button>} />
      <DialogClose render={<Button variant="primary">Confirm</Button>} />
    </DialogFooter>
  </DialogContent>
</Dialog>

Examples

Confirm

Opens with a click on a spring from the centre; opened with a key it appears at once. Escape or Cancel closes.

Without the corner close

When the footer already has Cancel, hideClose drops the X.

Props

DialogContentProps
PropTypeDescription
classNamestringClasses merged onto the root element, after ikada's own.
hideClosebooleanHide the corner close button when the footer already has Cancel. Default `false`.
styleCSSProperties | ((state: DialogPopupState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogPopupState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

Also takes every prop of Omit<ComponentProps<typeof BaseDialog.Popup>, "className">.

DialogTitleProps
PropTypeDescription
styleCSSProperties | ((state: DialogTitleState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTitleState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
classNamestringClasses merged onto the root element, after ikada's own.
DialogDescriptionProps
PropTypeDescription
styleCSSProperties | ((state: DialogDescriptionState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogDescriptionState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
classNamestringClasses merged onto the root element, after ikada's own.

Source: src/components/dialog.tsx