Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Integrate and customize shadcn/ui components—discovery, installation, theming, and Radix/Base UI best practices
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
examples/auth-layout.tsx
1// Example: Authentication Layout with shadcn/ui2// Demonstrates: Layout composition, card usage, form integration34"use client"56import { Button } from "@/components/ui/button"7import {8Card,9CardContent,10CardDescription,11CardFooter,12CardHeader,13CardTitle,14} from "@/components/ui/card"15import { Input } from "@/components/ui/input"16import { Label } from "@/components/ui/label"17import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"18import { useState } from "react"1920export function AuthLayout() {21const [isLoading, setIsLoading] = useState<boolean>(false)2223async function onSubmit(event: React.FormEvent<HTMLFormElement>) {24event.preventDefault()25setIsLoading(true)2627// Simulate API call28setTimeout(() => {29setIsLoading(false)30}, 2000)31}3233return (34<div className="flex min-h-screen items-center justify-center bg-muted/40">35<Tabs defaultValue="login" className="w-[400px]">36<TabsList className="grid w-full grid-cols-2">37<TabsTrigger value="login">Login</TabsTrigger>38<TabsTrigger value="register">Register</TabsTrigger>39</TabsList>4041<TabsContent value="login">42<Card>43<CardHeader>44<CardTitle>Login</CardTitle>45<CardDescription>46Enter your credentials to access your account.47</CardDescription>48</CardHeader>49<form onSubmit={onSubmit}>50<CardContent className="space-y-4">51<div className="space-y-2">52<Label htmlFor="email">Email</Label>53<Input54id="email"55type="email"56placeholder="[email protected]"57required58/>59</div>60<div className="space-y-2">61<Label htmlFor="password">Password</Label>62<Input63id="password"64type="password"65required66/>67</div>68</CardContent>69<CardFooter className="flex flex-col space-y-4">70<Button71type="submit"72className="w-full"73disabled={isLoading}74>75{isLoading ? "Signing in..." : "Sign in"}76</Button>77<Button78type="button"79variant="link"80className="w-full text-sm text-muted-foreground"81>82Forgot password?83</Button>84</CardFooter>85</form>86</Card>87</TabsContent>8889<TabsContent value="register">90<Card>91<CardHeader>92<CardTitle>Create an account</CardTitle>93<CardDescription>94Enter your information to create an account.95</CardDescription>96</CardHeader>97<form onSubmit={onSubmit}>98<CardContent className="space-y-4">99<div className="space-y-2">100<Label htmlFor="name">Name</Label>101<Input102id="name"103placeholder="John Doe"104required105/>106</div>107<div className="space-y-2">108<Label htmlFor="register-email">Email</Label>109<Input110id="register-email"111type="email"112placeholder="[email protected]"113required114/>115</div>116<div className="space-y-2">117<Label htmlFor="register-password">Password</Label>118<Input119id="register-password"120type="password"121required122/>123</div>124<div className="space-y-2">125<Label htmlFor="confirm-password">Confirm Password</Label>126<Input127id="confirm-password"128type="password"129required130/>131</div>132</CardContent>133<CardFooter>134<Button135type="submit"136className="w-full"137disabled={isLoading}138>139{isLoading ? "Creating account..." : "Create account"}140</Button>141</CardFooter>142</form>143</Card>144</TabsContent>145</Tabs>146</div>147)148}149150/**151* Key Patterns Demonstrated:152*153* 1. Layout Composition: Centered authentication card with full-height viewport154* 2. Card Usage: Structured content with header, body, and footer155* 3. Tabs: Switch between login and register forms156* 4. Form Structure: Proper labeling and input grouping157* 5. Loading States: Button disabled state during form submission158* 6. Responsive Design: Mobile-friendly with max-width constraint159* 7. Tailwind Utilities: Using spacing, flexbox, and grid utilities160*161* Design Choices:162* - Minimal, clean interface focusing on the task at hand163* - Proper semantic HTML with form elements164* - Accessible labels and inputs165* - Clear visual hierarchy with card components166* - Loading feedback for better UX167*168* Required Dependencies:169* None beyond React and shadcn/ui components170*171* Installation:172* npx shadcn@latest add card173* npx shadcn@latest add input174* npx shadcn@latest add label175* npx shadcn@latest add button176* npx shadcn@latest add tabs177*/178