Make me a beautful Shadcn form component
- User
Make me a beautful Shadcn form component
- Assistant
Below is an example of a beautiful form component using Shadcn UI, a utility-first CSS framework similar to Tailwind CSS. This example will create a simple yet visually appealing form with input fields for name, email, and a message, along with a submit button.
First, ensure you have Shadcn UI installed in your project. If not, you can include it by adding the following line in the
<head>section of your HTML file:<link href="https://unpkg.com/@shadcn/ui/dist/index.css" rel="stylesheet" />Or, if you're using a package manager like npm or yarn, you can install it via:
npm install @shadcn/ui # or yarn add @shadcn/uiThen, import it in your CSS or JavaScript file accordingly.
Now, let's create the form component:
<div class="max-w-md mx-auto mt-10 p-4 rounded-lg shadow-lg bg-white"> <h2 class="text-2xl font-bold mb-4 text-center">Get in Touch</h2> <form> <div class="mb-4"> <label for="name" class="block text-sm font-medium text-gray-700">Name</label> <input type="text" id="name" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="Your name"> </div> <div class="mb-4"> <label for="email" class="block text-sm font-medium text-gray-700">Email</label> <input type="email" id="email" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="your@email.com"> </div> <div class="mb-4"> <label for="message" class="block text-sm font-medium text-gray-700">Message</label> <textarea id="message" rows="4" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="Your message..."></textarea> </div> <button type="submit" class="py-2 px-4 bg-indigo-500 text-white rounded hover:bg-indigo-700 transition duration-200">Send Message</button> </form> </div>This form component is designed to be responsive and visually appealing, with a clean and modern look. The
max-w-mdclass ensures the form doesn't get too wide on larger screens, whilemx-autocenters it horizontally. Therounded-lgandshadow-lgclasses add a rounded corner and a shadow effect, respectively, to give the form a more premium feel. The input fields and textarea are styled withrounded-mdand have a focus effect that changes the border color to indigo, providing a nice visual cue when interacting with the form.Feel free to customize the colors, spacing, and other styles to fit your project's design requirements by utilizing Shadcn UI's utility classes.