Open a focused panel over the page for forms, details, or confirmations. Dismiss it with Escape or the close control.
tsx
1import{Button}from"@/components/ui/button"2import{3Dialog,4DialogClose,5DialogContent,6DialogDescription,7DialogFooter,8DialogHeader,9DialogTitle,10DialogTrigger,11}from"@/components/ui/dialog"12import{Field,FieldGroup}from"@/components/ui/field"13import{Input}from"@/components/ui/input"14import{Label}from"@/components/ui/label"1516exportfunctionExample(){17return(18<Dialog>19<form>20<DialogTriggerrender={<Buttonvariant="outline"/>}>21 Open Dialog22</DialogTrigger>23<DialogContentclassName="sm:max-w-sm">24<DialogHeader>25<DialogTitle>Edit profile</DialogTitle>26<DialogDescription>27 Make changes to your profile here. Click save when you're28 done.29</DialogDescription>30</DialogHeader>31<FieldGroup>32<Field>33<LabelhtmlFor="name-1">Name</Label>34<Inputid="name-1"name="name"defaultValue="Pedro Duarte"/>35</Field>36<Field>37<LabelhtmlFor="username-1">Username</Label>38<Input39id="username-1"40name="username"41defaultValue="@peduarte"42/>43</Field>44</FieldGroup>45<DialogFooter>46<DialogCloserender={<Buttonvariant="outline"/>}>47 Cancel48</DialogClose>49<Buttontype="submit">Save changes</Button>50</DialogFooter>51</DialogContent>52</form>53</Dialog>54)55}
1<Dialog>2<DialogTriggerrender={<Buttonvariant="outline"/>}>3 Edit profile4</DialogTrigger>5<DialogContent>6<DialogHeader>7<DialogTitle>Edit profile</DialogTitle>8<DialogDescription>9 Update your name and email for this workspace.10</DialogDescription>11</DialogHeader>12</DialogContent>13</Dialog>
Replace the default close control with a button in the footer.
tsx
1import{Button}from"@/components/ui/button"2import{3Dialog,4DialogClose,5DialogContent,6DialogDescription,7DialogFooter,8DialogHeader,9DialogTitle,10DialogTrigger,11}from"@/components/ui/dialog"12import{Input}from"@/components/ui/input"13import{Label}from"@/components/ui/label"1415exportfunctionExample(){16return(17<Dialog>18<DialogTriggerrender={<Buttonvariant="outline"/>}>19 Share20</DialogTrigger>21<DialogContentclassName="sm:max-w-md">22<DialogHeader>23<DialogTitle>Share link</DialogTitle>24<DialogDescription>25 Anyone who has this link will be able to view this.26</DialogDescription>27</DialogHeader>28<divclassName="flex items-center gap-2">29<divclassName="grid flex-1 gap-2">30<LabelhtmlFor="link"className="sr-only">31 Link32</Label>33<Input34id="link"35defaultValue="https://example.com/share/a1b2c3d4"36readOnly37/>38</div>39</div>40<DialogFooterclassName="sm:justify-start">41<DialogCloserender={<Button/>}>Close</DialogClose>42</DialogFooter>43</DialogContent>44</Dialog>45)46}
No close button
Set showCloseButton={false} on DialogContent to hide the default close button.
tsx
1import{Button}from"@/components/ui/button"2import{3Dialog,4DialogContent,5DialogDescription,6DialogHeader,7DialogTitle,8DialogTrigger,9}from"@/components/ui/dialog"1011exportfunctionExample(){12return(13<Dialog>14<DialogTriggerrender={<Buttonvariant="outline"/>}>15 No Close Button16</DialogTrigger>17<DialogContentshowCloseButton={false}>18<DialogHeader>19<DialogTitle>No Close Button</DialogTitle>20<DialogDescription>21 This dialog doesn't have a close button in the top-right22 corner.23</DialogDescription>24</DialogHeader>25</DialogContent>26</Dialog>27)28}
Sticky footer
Keep actions in view while longer content scrolls.
tsx
1import{Button}from"@/components/ui/button"2import{3Dialog,4DialogClose,5DialogContent,6DialogDescription,7DialogFooter,8DialogHeader,9DialogTitle,10DialogTrigger,11}from"@/components/ui/dialog"1213exportfunctionExample(){14return(15<Dialog>16<DialogTriggerrender={<Buttonvariant="outline"/>}>17 Sticky Footer18</DialogTrigger>19<DialogContent>20<DialogHeader>21<DialogTitle>Sticky Footer</DialogTitle>22<DialogDescription>23 This dialog has a sticky footer that stays visible while the content24 scrolls.25</DialogDescription>26</DialogHeader>27<divclassName="-mx-4 max-h-[50vh] overflow-y-auto px-4">28{Array.from({length:10}).map((_, index) => (29<pkey={index}className="mb-4 leading-normal tracking-wide">30 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do31 eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut32 enim ad minim veniam, quis nostrud exercitation ullamco laboris33 nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in34 reprehenderit in voluptate velit esse cillum dolore eu fugiat35 nulla pariatur. Excepteur sint occaecat cupidatat non proident,36 sunt in culpa qui officia deserunt mollit anim id est laborum.37</p>38))}39</div>40<DialogFooter>41<DialogCloserender={<Buttonvariant="outline"/>}>42 Close43</DialogClose>44</DialogFooter>45</DialogContent>46</Dialog>47)48}
Scrollable content
Let longer content scroll while the header stays in view.
tsx
1import{Button}from"@/components/ui/button"2import{3Dialog,4DialogContent,5DialogDescription,6DialogHeader,7DialogTitle,8DialogTrigger,9}from"@/components/ui/dialog"1011exportfunctionExample(){12return(13<Dialog>14<DialogTriggerrender={<Buttonvariant="outline"/>}>15 Scrollable Content16</DialogTrigger>17<DialogContent>18<DialogHeader>19<DialogTitle>Scrollable Content</DialogTitle>20<DialogDescription>21 This is a dialog with scrollable content.22</DialogDescription>23</DialogHeader>24<divclassName="-mx-4 max-h-[50vh] overflow-y-auto px-4">25{Array.from({length:10}).map((_, index) => (26<pkey={index}className="mb-4 leading-normal tracking-wide">27 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do28 eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut29 enim ad minim veniam, quis nostrud exercitation ullamco laboris30 nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in31 reprehenderit in voluptate velit esse cillum dolore eu fugiat32 nulla pariatur. Excepteur sint occaecat cupidatat non proident,33 sunt in culpa qui officia deserunt mollit anim id est laborum.34</p>35))}36</div>37</DialogContent>38</Dialog>39)40}