Library MCP Setup About Template Factory ↗
← Library / Auth & Login UI SDK Agentic

WynterHub SSO Sign-In Card

Centered high-trust sign-in card with your real brand mark, one prominent WynterHub single sign-on button, and a tucked-away email + password fallback with crisp readable inputs, show/hide password, inline validation, and a signed-in confirmation.

Install UI SDK & packages

npm install @ui-sdk/react @ui-sdk/core lucide-react

Give your agent the UI SDK skill

npx skills add vercel-labs/ui --skill ui-sdk

UI SDK entries: @ui-sdk/react/button @ui-sdk/react/collapsible @ui-sdk/react/field @ui-sdk/react/input @ui-sdk/react/password-input
"use client";

import * as React from "react";
import { ArrowRight, Check, ChevronDown, Eye, EyeOff, Lock, Mail, ShieldCheck } from "lucide-react";
import { Button } from "@ui-sdk/react/button";
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "@ui-sdk/react/collapsible";
import { Field, FieldError, FieldLabel } from "@ui-sdk/react/field";
import { Input } from "@ui-sdk/react/input";
import {
  PasswordInput,
  PasswordInputControl,
  PasswordInputToggle,
} from "@ui-sdk/react/password-input";

const card =
  "rounded-2xl border border-[#d8e0ea] bg-white shadow-[0_18px_44px_rgba(15,23,42,0.12)] dark:border-slate-400/20 dark:bg-[#111827] dark:shadow-[0_24px_60px_rgba(0,0,0,0.5)]";
const labelCls = "block text-[13px] font-semibold leading-snug text-slate-800 dark:text-slate-200";
const hintCls = "text-xs leading-relaxed text-slate-600 dark:text-slate-400";
const errorCls = "text-xs font-semibold text-red-800 dark:text-red-300";
const fieldBase =
  "w-full min-w-0 rounded-[10px] border-[1.5px] border-slate-300 bg-white text-sm font-medium text-slate-900 shadow-[0_1px_2px_rgba(15,23,42,0.06)] outline-none transition-[border-color,box-shadow] hover:border-slate-400 focus:border-sky-600 focus:ring-[3px] focus:ring-sky-600/25 dark:border-slate-400/35 dark:bg-[#182234] dark:text-slate-50 dark:shadow-[inset_0_1px_2px_rgba(0,0,0,0.35)] dark:hover:border-slate-400/55 dark:focus:border-sky-400 dark:focus:ring-sky-400/30";
const inputCls = `${fieldBase} h-11 px-3.5`;
const btnBase =
  "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-[10px] font-bold transition hover:-translate-y-px active:translate-y-px disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-500";
const btnMd = "h-11 px-4 text-sm";
const btnPrimary = `${btnBase} border border-sky-300/60 bg-linear-to-b from-sky-300 via-sky-400 to-sky-600 text-[#031521] shadow-[inset_0_1px_0_rgba(255,255,255,0.55),inset_0_-2px_0_rgba(3,55,86,0.35),0_8px_20px_rgba(2,132,199,0.25)] hover:brightness-105`;
const btnGhost = `${btnBase} border border-slate-300 bg-linear-to-b from-white to-slate-100 text-slate-900 shadow-[inset_0_1px_0_rgba(255,255,255,0.95),inset_0_-1.5px_0_rgba(15,23,42,0.08),0_1px_2px_rgba(15,23,42,0.06)] hover:border-slate-400 dark:border-slate-400/35 dark:from-[#243047] dark:to-[#182234] dark:text-slate-50 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.09),inset_0_-1.5px_0_rgba(0,0,0,0.35)] dark:hover:border-slate-400/55`;

export interface PasswordCredentials {
  email: string;
  password: string;
}

export interface WynterHubSsoLoginProps {
  /** Product name shown in the heading and trust line. */
  appName?: string;
  /** Square brand mark shown above the heading. */
  logoSrc?: string;
  /** Where the WynterHub button sends people when `onSsoClick` is not set. */
  ssoHref?: string;
  forgotHref?: string;
  onSsoClick?: () => void;
  /** Throw an Error to show its message above the form (wrong password, locked account…). */
  onPasswordSignIn?: (credentials: PasswordCredentials) => Promise<void> | void;
}

type Status = "idle" | "submitting" | "signedIn";
type Errors = { email?: string; password?: string; form?: string };

export function WynterHubSsoLogin({
  appName = "Snow",
  logoSrc = "/brand/snow-icon-transparent.webp",
  ssoHref = "/auth/wynter",
  forgotHref = "/forgot-password",
  onSsoClick,
  onPasswordSignIn,
}: WynterHubSsoLoginProps) {
  const [status, setStatus] = React.useState<Status>("idle");
  const [email, setEmail] = React.useState("");
  const [password, setPassword] = React.useState("");
  const [errors, setErrors] = React.useState<Errors>({});

  const handleSso = () => {
    if (onSsoClick) onSsoClick();
    else window.location.assign(ssoHref);
  };

  const handlePasswordSignIn = async (event: React.FormEvent<HTMLFormElement>) => {
    event.preventDefault();
    if (status === "submitting") return;
    const cleaned = email.trim();
    const next: Errors = {};
    if (!/^\S+@\S+\.\S+$/.test(cleaned)) next.email = "Enter the email you signed up with.";
    if (!password) next.password = "Enter your password.";
    if (next.email || next.password) {
      setErrors(next);
      return;
    }
    setErrors({});
    setStatus("submitting");
    try {
      await onPasswordSignIn?.({ email: cleaned, password });
      setStatus("signedIn");
    } catch (error) {
      setErrors({
        form:
          error instanceof Error && error.message
            ? error.message
            : "That email and password didn’t match. Try again.",
      });
      setStatus("idle");
    }
  };

  const brand = (
    <div className="flex items-center gap-2.5">
      <img
        src={logoSrc}
        alt=""
        width={44}
        height={44}
        className="h-11 w-11 object-contain drop-shadow-[0_6px_14px_rgba(56,189,248,0.32)]"
      />
      <span className="text-[15px] font-bold text-slate-900 dark:text-slate-50">{appName}</span>
    </div>
  );

  if (status === "signedIn") {
    return (
      <div role="status" className={`${card} mx-auto w-full max-w-md p-5 text-center sm:p-8`}>
        <div className="flex justify-center">{brand}</div>
        <div className="mx-auto mt-5 grid h-13 w-13 place-items-center rounded-2xl border border-emerald-600/40 bg-emerald-50 text-emerald-700 dark:border-emerald-400/40 dark:bg-emerald-400/15 dark:text-emerald-300">
          <Check className="h-6 w-6" strokeWidth={2.5} aria-hidden="true" />
        </div>
        <h1 className="mt-4 text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-50">You’re signed in</h1>
        <p className="mt-1.5 text-sm text-slate-600 dark:text-slate-400">
          Signed in as <strong className="font-semibold text-slate-900 dark:text-slate-50">{email.trim()}</strong>. Opening{" "}
          {appName} now.
        </p>
      </div>
    );
  }

  return (
    <div className={`${card} mx-auto w-full max-w-md p-5 sm:p-8`}>
      {brand}
      <h1 className="mt-5 text-2xl font-bold tracking-tight text-balance text-slate-900 dark:text-slate-50">
        Sign in to {appName}
      </h1>
      <p className="mt-1.5 text-sm text-slate-600 dark:text-slate-400">One WynterHub account opens every Wynter app.</p>

      <Button
        data-agent-confirm={`Redirects to WynterHub single sign-on for ${appName}`}
        onClick={handleSso}
        className={`${btnPrimary} mt-6 h-12 w-full px-5 text-[15px]`}
      >
        <ShieldCheck className="h-[18px] w-[18px]" aria-hidden="true" />
        <span>Continue with WynterHub</span>
        <ArrowRight className="h-4 w-4" aria-hidden="true" />
      </Button>

      <p className={`${hintCls} mt-3 text-center text-balance`}>
        <Lock className="mr-1.5 inline-block h-3.5 w-3.5 align-[-2px]" aria-hidden="true" />
        Secure single sign-on. {appName} never sees your WynterHub password.
      </p>

      <Collapsible className="mt-5 border-t border-[#d8e0ea] pt-5 dark:border-slate-400/20">
        <CollapsibleTrigger className={`${btnGhost} ${btnMd} group w-full`}>
          <Mail className="h-4 w-4" aria-hidden="true" />
          <span>Use email and password instead</span>
          <ChevronDown
            className="h-4 w-4 transition-transform duration-150 group-data-open:rotate-180"
            aria-hidden="true"
          />
        </CollapsibleTrigger>

        <CollapsiblePanel>
          <form onSubmit={handlePasswordSignIn} noValidate className="grid gap-4 pt-4">
            {errors.form && (
              <p
                role="alert"
                className="rounded-[10px] border border-red-300 bg-red-50 px-3.5 py-2.5 text-[13px] font-semibold text-red-800 dark:border-red-400/50 dark:bg-red-500/15 dark:text-red-200"
              >
                {errors.form}
              </p>
            )}

            <Field name="email" invalid={Boolean(errors.email)} className="grid gap-1.5">
              <FieldLabel className={labelCls}>Email address</FieldLabel>
              <Input
                type="email"
                autoComplete="email"
                required
                value={email}
                onValueChange={(value) => {
                  setEmail(value);
                  if (errors.email) setErrors((prev) => ({ ...prev, email: undefined }));
                }}
                className={inputCls}
              />
              {errors.email && (
                <FieldError match className={errorCls}>
                  {errors.email}
                </FieldError>
              )}
            </Field>

            <Field name="password" invalid={Boolean(errors.password)} className="grid gap-1.5">
              <div className="flex items-baseline justify-between gap-3">
                <FieldLabel className={labelCls}>Password</FieldLabel>
                <a
                  href={forgotHref}
                  className="rounded text-[13px] font-semibold text-sky-700 hover:underline dark:text-sky-300"
                >
                  Forgot password?
                </a>
              </div>
              <PasswordInput
                value={password}
                onValueChange={(value) => {
                  setPassword(value);
                  if (errors.password) setErrors((prev) => ({ ...prev, password: undefined }));
                }}
                required
                autoComplete="current-password"
                className="relative"
              >
                <PasswordInputControl className={`${inputCls} pr-12`} />
                <PasswordInputToggle
                  aria-label="Show password"
                  className="absolute top-1.5 right-1.5 grid h-8 w-8 cursor-pointer place-items-center rounded-lg text-slate-600 transition hover:bg-slate-900/5 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-400/15 dark:hover:text-slate-50"
                >
                  {(state) =>
                    state.visible ? (
                      <EyeOff className="h-4 w-4" aria-hidden="true" />
                    ) : (
                      <Eye className="h-4 w-4" aria-hidden="true" />
                    )
                  }
                </PasswordInputToggle>
              </PasswordInput>
              {errors.password && (
                <FieldError match className={errorCls}>
                  {errors.password}
                </FieldError>
              )}
            </Field>

            <Button type="submit" disabled={status === "submitting"} className={`${btnGhost} ${btnMd} w-full`}>
              {status === "submitting" ? "Signing in…" : "Sign in with email"}
            </Button>
          </form>
        </CollapsiblePanel>
      </Collapsible>
    </div>
  );
}

export default WynterHubSsoLogin;