mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-08 22:45:47 +00:00
130 lines
4.5 KiB
TypeScript
130 lines
4.5 KiB
TypeScript
import { Button } from "@/registry/new-york-v4/ui/button"
|
|
import {
|
|
Dialog,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from "@/registry/new-york-v4/ui/dialog"
|
|
import { Input } from "@/registry/new-york-v4/ui/input"
|
|
import { Label } from "@/registry/new-york-v4/ui/label"
|
|
|
|
export function DialogDemo() {
|
|
return (
|
|
<div className="flex flex-col items-start gap-4 md:flex-row">
|
|
<DialogWithForm />
|
|
<DialogScrollableContent />
|
|
<DialogWithStickyFooter />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function DialogWithForm() {
|
|
return (
|
|
<Dialog>
|
|
<form>
|
|
<DialogTrigger asChild>
|
|
<Button variant="outline">Edit Profile</Button>
|
|
</DialogTrigger>
|
|
<DialogContent className="sm:max-w-[425px]">
|
|
<DialogHeader>
|
|
<DialogTitle>Edit profile</DialogTitle>
|
|
<DialogDescription>
|
|
Make changes to your profile here. Click save when you're
|
|
done.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<div className="grid gap-4">
|
|
<div className="grid gap-3">
|
|
<Label htmlFor="name-1">Name</Label>
|
|
<Input id="name-1" name="name" defaultValue="Pedro Duarte" />
|
|
</div>
|
|
<div className="grid gap-3">
|
|
<Label htmlFor="username-1">Username</Label>
|
|
<Input id="username-1" name="username" defaultValue="@peduarte" />
|
|
</div>
|
|
</div>
|
|
<DialogFooter>
|
|
<DialogClose asChild>
|
|
<Button variant="outline">Cancel</Button>
|
|
</DialogClose>
|
|
<Button type="submit">Save changes</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</form>
|
|
</Dialog>
|
|
)
|
|
}
|
|
|
|
function DialogScrollableContent() {
|
|
return (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<Button variant="outline">Scrollable Content</Button>
|
|
</DialogTrigger>
|
|
<DialogContent className="sm:max-w-[425px]">
|
|
<DialogHeader>
|
|
<DialogTitle>Scrollable Content</DialogTitle>
|
|
<DialogDescription>
|
|
This is a dialog with scrollable content.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<div className="-mx-6 max-h-[500px] overflow-y-auto px-6 text-sm">
|
|
<h4 className="mb-4 text-lg leading-none font-medium">Lorem Ipsum</h4>
|
|
{Array.from({ length: 10 }).map((_, index) => (
|
|
<p key={index} className="mb-4 leading-normal">
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
|
|
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
|
|
enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
|
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
|
|
sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
</p>
|
|
))}
|
|
</div>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|
|
|
|
function DialogWithStickyFooter() {
|
|
return (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<Button variant="outline">Sticky Footer</Button>
|
|
</DialogTrigger>
|
|
<DialogContent className="sm:max-w-lg">
|
|
<DialogHeader>
|
|
<DialogTitle>Scrollable Content</DialogTitle>
|
|
<DialogDescription>
|
|
This is a dialog with scrollable content.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<div className="-mx-6 max-h-[500px] overflow-y-auto px-6 text-sm">
|
|
<h4 className="mb-4 text-lg leading-none font-medium">Lorem Ipsum</h4>
|
|
{Array.from({ length: 10 }).map((_, index) => (
|
|
<p key={index} className="mb-4 leading-normal">
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
|
|
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
|
|
enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
|
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
|
|
sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
</p>
|
|
))}
|
|
</div>
|
|
<DialogFooter>
|
|
<DialogClose asChild>
|
|
<Button variant="outline">Close</Button>
|
|
</DialogClose>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|