create a beatuful and simple webpage for login using shadcn
- User
create a beatuful and simple webpage for login using shadcn
- Assistant
Below is a minimal-yet-elegant login page that relies on
shadcn/ui + TailwindCSS.
Copy-paste it into a fresh Next 13/14 project (the “App Router” way) and you’ll get a fully-functioning, nice-looking login form.- Quick setup (only once per project)
# 1. Create a Next app (skip if you already have one) npx create-next-app@latest my-login-demo cd my-login-demo # 2. Install Tailwind & init it npm install -D tailwindcss postcss autoprefixer npx tailwindcss init -p # 3. Install shadcn/ui and generate the base components npx shadcn-ui@latest init # choose “app router”, Typescript, Tailwind # 4. Pull the components we’ll use npx shadcn-ui@latest add button card input label # feel free to add more later- Tailwind globals (
tailwind.config.js)
/** @type {import('tailwindcss').Config} */ module.exports = { darkMode: ["class"], content: [ './app/**/*.{ts,tsx}', './components/**/*.{ts,tsx}', ], theme: { extend: {} }, plugins: [require('tailwindcss-animate')], }- Global CSS (
app/globals.css) – keep it lean
@tailwind base; @tailwind components; @tailwind utilities; /* Optional: subtle gradient background */ body { @apply min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 dark:from-slate-900 dark:via-slate-950 dark:to-black; }- The Login Page (
app/login/page.tsx)
'use client' import * as React from 'react' import Link from 'next/link' import { Card, CardContent, CardHeader, CardTitle, CardFooter, } from '@/components/ui/card' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Button } from '@/components/ui/button' export default function LoginPage() { // Demo handler (replace with real auth logic or next-auth action) function handleSubmit(e: React.FormEvent<HTMLFormElement>) { e.preventDefault() const data = Object.fromEntries(new FormData(e.currentTarget)) console.log('👋 Submitted:', data) // TODO: call an API route or server action } return ( <div className="flex items-center justify-center min-h-screen px-4"> <Card className="w-full max-w-md shadow-lg"> <CardHeader> <CardTitle className="text-2xl">Welcome back</CardTitle> </CardHeader> <CardContent> <form onSubmit={handleSubmit} className="grid gap-4"> <div className="grid gap-2"> <Label htmlFor="email">Email</Label> <Input id="email" name="email" type="email" placeholder="you@example.com" required /> </div> <div className="grid gap-2"> <Label htmlFor="password">Password</Label> <Input id="password" name="password" type="password" required /> </div> <Button type="submit" className="w-full"> Log in </Button> </form> </CardContent> <CardFooter className="flex flex-col gap-2"> <p className="text-xs text-muted-foreground"> By continuing, you agree to our <Link href="#" className="underline">Terms & Conditions</Link>. </p> <p className="text-sm"> New here?{' '} <Link href="/register" className="underline font-medium"> Create an account </Link> </p> </CardFooter> </Card> </div> ) }- Optional polish
• Dark mode works automatically (shadcn/ui +
dark:variants).
👉 Wrap your root layout with<ThemeProvider>(shadcn’scomponents/theme-provider.tsx) if you want a theme toggle.• Validation / errors: import
<Form,<FormField>components from shadcn-ui if you need Zod-powered validation.• Social logins: add extra
<Button variant="outline" className="gap-2">with an icon.That’s it—open
http://localhost:3000/loginand enjoy your crisp, accessible login page! 🪄
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.