Atoms
Dialog
A modal dialog that interrupts the user with important content.
shadcn/uiBased on shadcn/ui with Formance brand styling.
Installation#
npx shadcn@latest add @formance/dialogInstall the following dependencies:
npm install radix-ui lucide-reactCopy and paste the following code into your project.
Update the import paths to match your project setup.
Usage#
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger,} from '@/components/ui/dialog'<Dialog> <DialogTrigger>Open</DialogTrigger> <DialogContent> <DialogHeader> <DialogTitle>Dialog Title</DialogTitle> <DialogDescription> Dialog description goes here. </DialogDescription> </DialogHeader> <DialogFooter> <Button>Save</Button> </DialogFooter> </DialogContent></Dialog>Examples#
Sizes#
Use the size prop on DialogContent to set the maximum width. The default size is default.
Use full for a large view, for example a graph or a long table. The dialog fills the viewport, with a 1rem margin on each side. Its content is a flex column. Give the body min-h-0 flex-1 overflow-auto to fill the remaining height and scroll.
<DialogContent size="full"> <DialogHeader> <DialogTitle>Movement flow</DialogTitle> </DialogHeader> <div className="min-h-0 flex-1 overflow-auto">{/* graph */}</div></DialogContent>API Reference#
DialogContent#
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'default' | 'lg' | 'xl' | 'full' | 'default' | Sets the maximum width from the sm breakpoint: sm is 24rem, default is 32rem, lg is 42rem, xl is 56rem. full fills the viewport minus a 1rem margin, in width and height. The value is also set on data-size. |
showCloseButton | boolean | true | Shows the close button in the top-right corner. |