components
shadcn
sign up
Sign-Up Page
This is well designed fully responsible kico ui sign-up component. Just copy code and paste in your app.
Preview
Loading...
Setup Guide
Install shadcn ui
npx shadcn-ui@latest init
Add shadcn ui components
npx shadcn-ui@latest add input
npx shadcn-ui@latest add button
npx shadcn-ui@latest add form
Install npm packages
npm i react-hook-form
npm i zod
npm i @hookform/resolvers
Add svg icons
Code
components/sign-up.tsx
"use client"
import Link from "next/link"
import { useState } from "react"
// npm packages
import { useForm } from "react-hook-form"
import { z } from "zod"
import { zodResolver } from "@hookform/resolvers/zod"
// just add icons whatever you wants for your site
import SignUpIcon from "@/components/icons/signup-icon"
import { Icons } from "@/components/icons/icons"
// shadcn ui components
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form"
// form validation using zod
const signUpFormSchema = z.object({
firstName: z
.string()
.min(2, {
message: "First name must be at least 2 characters.",
})
.max(30, {
message: "First name must not be longer than 30 characters.",
}),
lastName: z
.string()
.min(2, {
message: "Last name must be at least 2 characters.",
})
.max(30, {
message: "Last name must not be longer than 30 characters.",
}),
email: z
.string({
required_error: "Please enter valid email address.",
})
.email(),
password: z
.string()
.min(8)
.regex(/[A-Z]/, "Password must contain at least one uppercase letter")
.regex(/[a-z]/, "Password must contain at least one lowercase letter")
.regex(/[0-9]/, "Password must contain at least one number")
.regex(
/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,
"Password must contain at least one special character"
),
confirmPassword: z
.string()
.min(8)
.regex(/[A-Z]/, "Password must contain at least one uppercase letter")
.regex(/[a-z]/, "Password must contain at least one lowercase letter")
.regex(/[0-9]/, "Password must contain at least one number")
.regex(
/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,
"Password must contain at least one special character"
),
})
type SignUpFormValues = z.infer<typeof signUpFormSchema>
function AuthenticationStrategy() {
const isLoading = false
return (
<>
<div className="relative">
<div className="absolute inset-0 flex items-center">
<span className="w-full border-t" />
</div>
<div className="relative flex justify-center text-xs uppercase">
<span className="bg-background px-2 text-muted-foreground">
Or continue with
</span>
</div>
</div>
<Button variant="outline" type="button" disabled={isLoading}>
{isLoading ? (
<Icons.spinner className="mr-2 size-4 animate-spin" />
) : (
<Icons.google className="mr-2 size-4" />
)}{" "}
Google
</Button>
</>
)
}
function SignUpForm() {
const form = useForm<SignUpFormValues>({
resolver: zodResolver(signUpFormSchema),
mode: "onChange",
})
const [isLoading, setIsLoading] = useState<boolean>(false)
const onSubmit = (data: SignUpFormValues) => {
setIsLoading(true)
console.log(data) // get all form fields
setTimeout(() => setIsLoading(false), 3000)
}
return (
<Form {...form}>
<form
className="flex flex-col space-y-6 md:px-0"
onSubmit={form.handleSubmit(onSubmit)}
>
<div className="items-center space-y-6 md:flex md:space-x-8 md:space-y-0">
<FormField
control={form.control}
name="firstName"
render={({ field }) => (
<FormItem>
<FormLabel>First Name</FormLabel>
<FormControl>
<Input
placeholder="Enter first name"
className="focus-visible:ring-1"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="lastName"
render={({ field }) => (
<FormItem>
<FormLabel>Last Name</FormLabel>
<FormControl>
<Input
placeholder="Enter last name"
className="focus-visible:ring-1"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input
type="email"
placeholder="example@kicoui.com"
className="focus-visible:ring-1"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="password"
render={({ field }) => (
<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
<Input
type="password"
placeholder="Enter password"
className="focus-visible:ring-1"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="confirmPassword"
render={({ field }) => (
<FormItem>
<FormLabel>Confirm Password</FormLabel>
<FormControl>
<Input
type="password"
placeholder="Confirm password"
className="focus-visible:ring-1"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit" disabled={isLoading}>
Create An Account
{isLoading ? (
<Icons.spinner className="ml-2 size-4 animate-spin" />
) : (
<Icons.nextBtn className="ml-2 size-4" />
)}{" "}
</Button>
</form>
</Form>
)
}
function SignUpPage() {
return (
<div className="flex min-h-screen items-center justify-center">
<div className="container mx-auto pb-8">
<div className="container relative flex-col items-center justify-center p-0 md:grid lg:max-w-none lg:grid-cols-2">
<div className="relative hidden h-full flex-col rounded-l-2xl border-r lg:flex lg:p-5">
<SignUpIcon className="size-full" />
</div>
<div className="lg:p-5">
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[400px]">
<div className="flex flex-col space-y-2 text-center">
<h1 className="text-2xl font-semibold tracking-tight">
Create an account
</h1>
<p className="text-sm text-muted-foreground">
Enter your information below to create your account
</p>
</div>
<SignUpForm />
<div className="flex items-center justify-start">
<Link
href="/login"
className="text-xs text-foreground/60 transition-all hover:text-foreground md:text-sm"
>
Already have an acount?
</Link>
</div>
<AuthenticationStrategy />
<p className="px-4 text-center text-sm text-muted-foreground">
By clicking continue, you agree to our{" "}
<Link
href="/terms"
className="underline underline-offset-4 hover:text-primary"
>
Terms of Service
</Link>{" "}
and{" "}
<Link
href="/privacy"
className="underline underline-offset-4 hover:text-primary"
>
Privacy Policy
</Link>
.
</p>
</div>
</div>
</div>
</div>
</div>
)
}
export default SignUpPage