Contact Modal 3
Contact ModalsText Align Center1 ColumnFormModal

Code
relume-contact-modal3.tsx
"use client";
import { useState } from "react";
import { Button, type ButtonProps } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Sheet, SheetClose, SheetContent, SheetOverlay, SheetTrigger } from "@/components/ui/sheet";
import { Textarea } from "@/components/ui/textarea";
import { useMediaQuery } from "@/hooks/use-media-query";
type Props = {
heading: string;
description: string;
button: ButtonProps;
};
export type ContactModal3Props = React.ComponentPropsWithoutRef<"section"> & Partial<Props>;
export const ContactModal3 = (props: ContactModal3Props) => {
const { heading, description, button } = {
...ContactModal3Defaults,
...props,
};
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [message, setMessage] = useState("");
const [acceptTerms, setAcceptTerms] = useState<boolean | "indeterminate">(false);
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
console.log({ name, email, message, acceptTerms });
};
const isTablet = useMediaQuery("(max-width: 767px)");
return (
<section className="px-[5%] py-16 md:py-24 lg:py-28">
<div className="container max-w-lg text-center">
<Sheet>
<SheetTrigger asChild>
<Button>Open modal</Button>
</SheetTrigger>
<SheetOverlay />
<SheetContent
side="right"
className="h-full w-[90%] px-8 pt-16 pb-28 md:w-[80%] md:px-12 md:py-16 lg:w-full lg:max-w-[40rem] lg:px-16 lg:py-20"
>
<SheetClose />
<div className="mb-8 text-center md:mb-10 lg:mb-12">
<h2 className="mb-3 text-h2 font-bold md:mb-4">{heading}</h2>
<p className="text-medium">{description}</p>
</div>
<form className="grid grid-cols-1 gap-6" onSubmit={handleSubmit}>
<div className="grid w-full grid-cols-1 items-center">
<Label htmlFor="name" className="mb-2">
Name
</Label>
<Input
type="text"
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
/>
</div>
<div className="grid w-full grid-cols-1 items-center">
<Label htmlFor="email" className="mb-2">
Email
</Label>
<Input
type="email"
id="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
<div className="grid w-full grid-cols-1 items-center">
<Label htmlFor="message" className="mb-2">
Message
</Label>
<Textarea
id="message"
placeholder="Type your message..."
className="min-h-[11.25rem] overflow-auto"
value={message}
onChange={(e) => setMessage(e.target.value)}
/>
</div>
<div className="mb-3 flex items-center md:mb-4">
<Checkbox
id="terms"
checked={acceptTerms}
onCheckedChange={setAcceptTerms}
className="mr-2"
/>
<Label htmlFor="terms" className="cursor-pointer gap-1 text-small">
I accept the{" "}
<a className="text-scheme-text underline" href="#">
Terms
</a>
</Label>
</div>
<div className="text-center">
<Button {...button}>{button.title}</Button>
</div>
</form>
</SheetContent>
</Sheet>
</div>
</section>
);
};
export const ContactModal3Defaults: Props = {
heading: "Contact us",
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
button: { title: "Submit" },
};npm i @radix-ui/react-checkbox @radix-ui/react-dialog @radix-ui/react-label @radix-ui/react-radio-group @radix-ui/react-select @radix-ui/react-slot @radix-ui/react-switch class-variance-authority@0.7.1 clsx@^2.1.1 motion@^12.15.0 relume-icons@1.3.0 tailwind-merge@^2.2.2


