Dialog
A modal window that overlays either the primary window or another dialog window.
Examples
import { Dialog, DialogHeader, DialogTitle, DialogDescription, DialogIcon, DialogFooter, Button } from 'kalki-design'
import { ShareNetwork } from '@phosphor-icons/react'
import * as React from 'react'
const ACTION_BUTTON_CLASS = 'min-w-[96px]'
export function Example() {
const [open, setOpen] = React.useState(false)
return (
<>
<Button onClick={() => setOpen(true)}>Open Media Dialog</Button>
<Dialog open={open} onClose={() => setOpen(false)} size="md" showCloseButton={false}>
<DialogHeader className="px-8 py-7">
<div className="flex items-start gap-5">
<DialogIcon tone="secondary" className="text-foreground [&>svg]:size-8">
<ShareNetwork weight="duotone" />
</DialogIcon>
<div className="space-y-2">
<DialogTitle>Share this project?</DialogTitle>
<DialogDescription>Anyone with the link will be able to view and edit this project.</DialogDescription>
</div>
</div>
</DialogHeader>
<DialogFooter className="px-8">
<Button size="md" variant="outline" className={ACTION_BUTTON_CLASS} onClick={() => setOpen(false)}>
Cancel
</Button>
<Button size="md" className={ACTION_BUTTON_CLASS} onClick={() => setOpen(false)}>
Share
</Button>
</DialogFooter>
</Dialog>
</>
)
}Installation
npx kalki-design add dialogUsage
import { Dialog } from 'kalki-design'
export default function Example() {
return <Dialog />
}API Reference
| Name | Type | Default | Description |
|---|---|---|---|
Nameopen | Typeboolean | Default— | DescriptionControlled open state. |
NameonClose | Typefunction | Default— | DescriptionCallback fired when the dialog should close. |
Namesize | Type'sm' | 'md' | 'lg' | 'full' | Default'md' | DescriptionMaximum width of the dialog. |
NamecloseOnOverlay | Typeboolean | Defaulttrue | DescriptionCloses dialog when clicking overlay. |
NamecloseOnEscape | Typeboolean | Defaulttrue | DescriptionCloses dialog when pressing Escape. |
NameshowCloseButton | Typeboolean | Defaulttrue | DescriptionShows an optional close button in the top-right corner. |