Cosskit

Login

Split-layout sign-in screen with email and password fields, social sign-in, and a forgot-password link.

pnpm dlx shadcn@latest add @cosskit/auth-login

Requires the @cosskit namespace in your components.json.

Open full page

Code

import { GlobeIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";

// ---------------------------------------------------------------------------
// Testimonial shown in the brand panel
// ---------------------------------------------------------------------------

const testimonial = {
  quote:
    "Switching to this platform cut our onboarding time in half. The team actually looks forward to Monday standups now.",
  author: "Mia Hartwell",
  role: "Head of Product, Lumen Labs",
};

// ---------------------------------------------------------------------------
// Page — fully static, no client hooks, no form submission
// ---------------------------------------------------------------------------

export default function AuthLogin() {
  return (
    <div className="grid min-h-svh lg:grid-cols-2 [&_[data-slot=button]]:transition-[box-shadow,scale] [&_[data-slot=button]:not(.w-full)]:motion-safe:hover:scale-[1.05] [&_[data-slot=button].w-full]:motion-safe:hover:scale-[1.03]">
      {/* ------------------------------------------------------------------ */}
      {/* Form side                                                           */}
      {/* ------------------------------------------------------------------ */}
      <div className="flex flex-col items-center justify-center px-6 py-12 lg:px-12">
        <div className="w-full max-w-sm">
          {/* Brand mark */}
          <div className="mb-8 flex items-center gap-2">
            <div className="flex size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground font-bold text-sm">
              N
            </div>
            <span className="font-semibold text-sm">Northwind</span>
          </div>

          {/* Heading */}
          <div className="mb-6 flex flex-col gap-1">
            <h1 className="text-2xl font-semibold tracking-tight">
              Welcome back
            </h1>
            <p className="text-sm text-muted-foreground">
              Sign in to your Northwind account to continue.
            </p>
          </div>

          {/* Social sign-in */}
          <Button variant="outline" className="w-full" type="button">
            <GlobeIcon className="size-4" />
            Continue with Google
          </Button>

          {/* Divider */}
          <div className="my-5 flex items-center gap-3">
            <Separator className="flex-1" />
            <span className="text-xs text-muted-foreground">or</span>
            <Separator className="flex-1" />
          </div>

          {/* Email + password fields — form has no action/handler; button is type=button */}
          <form>
            <div className="flex flex-col gap-4">
              <Field>
                <FieldLabel htmlFor="email">Email address</FieldLabel>
                <Input
                  id="email"
                  type="email"
                  placeholder="you@example.com"
                  autoComplete="email"
                />
              </Field>

              <Field>
                {/* w-full is required: coss Field is `flex flex-col items-start`,
                    which shrinks children to content width and defeats
                    justify-between. */}
                <div className="flex w-full items-center justify-between">
                  <FieldLabel htmlFor="password">Password</FieldLabel>
                  <a
                    href="#"
                    className="text-xs text-muted-foreground underline-offset-4 hover:underline"
                  >
                    Forgot password?
                  </a>
                </div>
                <Input
                  id="password"
                  type="password"
                  placeholder="••••••••"
                  autoComplete="current-password"
                />
              </Field>

              <Button type="button" className="w-full mt-1">
                Sign in
              </Button>
            </div>
          </form>

          {/* Sign-up link */}
          <p className="mt-6 text-center text-sm text-muted-foreground">
            Don&apos;t have an account?{" "}
            <a
              href="#"
              className="font-medium text-foreground underline-offset-4 hover:underline"
            >
              Create one free
            </a>
          </p>
        </div>
      </div>

      {/* ------------------------------------------------------------------ */}
      {/* Brand / testimonial panel — hidden below lg                        */}
      {/* ------------------------------------------------------------------ */}
      <div className="hidden lg:flex flex-col items-center justify-center bg-muted px-12 py-16">
        <div className="max-w-md">
          <blockquote className="flex flex-col gap-6">
            <p className="text-xl font-medium leading-relaxed">
              &ldquo;{testimonial.quote}&rdquo;
            </p>
            <footer className="flex flex-col gap-0.5">
              <span className="font-semibold text-sm">{testimonial.author}</span>
              <span className="text-sm text-muted-foreground">
                {testimonial.role}
              </span>
            </footer>
          </blockquote>
        </div>
      </div>
    </div>
  );
}

Dependencies

  • @coss/ui