A flexible and accessible dialog component for displaying content on top of the current page.
Basic Usage
A simple modal with a title, description, and action buttons.
Custom Styling
Customize the modal's appearance using `className` props.
Interactive Playground
Try different modal configurations live
import{useState}from'react'import{Button}from'./Button'import{Modal,ModalHeader,ModalTitle,ModalDescription,ModalBody,ModalFooter}from'./Modal'exportdefaultfunctionApp(){const[isOpen,setIsOpen] = useState(false)return(<divclassName="p-8 space-y-4"><h2className="text-2xl font-bold mb-4">Modal Example</h2><ButtononClick={()=>setIsOpen(true)}>Open Modal</Button><ModalisOpen={isOpen}onClose={()=>setIsOpen(false)}><ModalHeaderonClose={()=>setIsOpen(false)}><ModalTitle>Hello from Sandpack!</ModalTitle><ModalDescription>This modal is rendered inside the playground.</ModalDescription></ModalHeader><ModalBody><p>You can edit the code on the right to see changes live.</p><pclassName="mt-2">Try changing the modal's content or styling!</p></ModalBody><ModalFooter><Buttonvariant="outline"onClick={()=>setIsOpen(false)}>
Close
</Button></ModalFooter></Modal></div>)}