Skip to content
Organisms

Sign-in card

Email, password and social sign-in.

Primitive

Variants

6 more takes on the sign-in card, each a single file you install on its own by its id.

aui-015Magic link

Send a sign-in link and watch it land.

$ pnpm dlx asta-ui@latest add sign-in-aui-015

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/sign-in-aui-015.json

aui-016Painted split

Sign-in beside a painting.

$ pnpm dlx asta-ui@latest add sign-in-aui-016

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/sign-in-aui-016.json

aui-017Social first

Providers first, email behind a link.

$ pnpm dlx asta-ui@latest add sign-in-aui-017

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/sign-in-aui-017.json

aui-018Two-step

Email first, then password.

$ pnpm dlx asta-ui@latest add sign-in-aui-018

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/sign-in-aui-018.json

aui-019Passkey

Passkey with a password fallback.

$ pnpm dlx asta-ui@latest add sign-in-aui-019

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/sign-in-aui-019.json

aui-020Sign up

Sign up with a live avatar and a strength meter.

$ pnpm dlx asta-ui@latest add sign-in-aui-020

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/sign-in-aui-020.json

Installation

Primitive
  1. Run the CLI

    Run pnpm dlx asta-ui@latest init once, then this. The file lands in components/astabyte/, installs radix-ui@base-ui/react and the colour tokens go into your CSS. This is the Radix build. Drop --radix for Base UI.This is the Base UI build, the default. Want Radix? Add --radix.

    $ pnpm dlx asta-ui@latest add sign-in --radix

    Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/base/sign-in.json

  2. Or install the package

    Don’t want the file? Import from asta-uiasta-ui/base and update with pnpm update asta-ui. Add the stylesheet once. More.

    $ pnpm add asta-ui radix-ui @base-ui/react
    import { SignInCard } from "asta-ui";
    import { SignInCard } from "asta-ui/base";
  3. Or copy it by hand

    Install radix-ui@base-ui/react, then copy these files. Keep the paths, or fix the @/ imports. Then add the tokens from globals.css.

    "use client";
    
    import { useEffect, useId, useRef, useState, type FormEvent, type ReactNode } from "react";
    import { Button } from "@/components/kit/button";
    
    const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
    
    const RING = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_14%,transparent)]";
    const EASE = "ease-[cubic-bezier(.16,1,.3,1)]";
    
    const CSS = `
    @keyframes kit-signin-pop { from { opacity: 0; transform: scale(.92) translateY(6px) } to { opacity: 1; transform: none } }
    @keyframes kit-signin-draw { from { stroke-dashoffset: 24 } to { stroke-dashoffset: 0 } }
    @media (prefers-reduced-motion: reduce) { .kit-signin * { animation: none !important } }
    `;
    
    const GoogleGlyph = () => (
      <svg viewBox="0 0 16 16" aria-hidden>
        <path fill="currentColor" d="M8 6.6v2.9h4.1A4.3 4.3 0 0 1 8 12.4a4.4 4.4 0 0 1 0-8.8c1.1 0 2.1.4 2.9 1.1l2-2A7.3 7.3 0 0 0 8 .7a7.3 7.3 0 1 0 0 14.6c4.2 0 7-3 7-7.1 0-.5 0-1-.1-1.5H8Z" />
      </svg>
    );
    const GitHubGlyph = () => (
      <svg viewBox="0 0 16 16" aria-hidden>
        <path
          fill="currentColor"
          d="M8 .5a7.5 7.5 0 0 0-2.4 14.6c.4.1.5-.2.5-.4v-1.4c-2.1.5-2.5-.9-2.5-.9-.4-.9-.9-1.1-.9-1.1-.7-.5 0-.5 0-.5.8.1 1.2.8 1.2.8.7 1.2 1.8.8 2.2.6.1-.5.3-.8.5-1-1.7-.2-3.4-.8-3.4-3.7 0-.8.3-1.5.8-2-.1-.2-.3-1 .1-2 0 0 .6-.2 2.1.8a7 7 0 0 1 3.8 0c1.4-1 2.1-.8 2.1-.8.4 1 .2 1.8.1 2 .5.5.8 1.2.8 2 0 2.9-1.8 3.5-3.4 3.7.3.2.5.7.5 1.4v2.1c0 .2.1.5.5.4A7.5 7.5 0 0 0 8 .5Z"
        />
      </svg>
    );
    
    interface FieldProps {
      label: string;
      type: string;
      value: string;
      onChange: (v: string) => void;
      onBlur: () => void;
      error?: string;
      /** Bumped on every failed submit so the field shakes again. */
      shake: number;
      name: string;
      autoComplete: string;
      inputMode?: "email" | "text";
      placeholder?: string;
      end?: ReactNode;
    }
    
    function Field({ label, type, value, onChange, onBlur, error, shake, name, autoComplete, inputMode, placeholder, end }: FieldProps) {
      const id = useId();
      const box = useRef<HTMLDivElement>(null);
      const hasError = !!error;
      // Shake once when an error shows up, and again on every failed submit.
      useEffect(() => {
        if (!hasError || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
        box.current?.animate(
          [{ transform: "none" }, { transform: "translateX(-6px)" }, { transform: "translateX(5px)" }, { transform: "translateX(-3px)" }, { transform: "translateX(2px)" }, { transform: "none" }],
          { duration: 420, easing: "cubic-bezier(.16,1,.3,1)" },
        );
      }, [hasError, shake]);
      return (
        <div className="flex flex-col gap-1.5">
          <label htmlFor={id} className="text-[13px] font-medium text-ink">
            {label}
          </label>
          <div ref={box} className="relative">
            <input
              id={id}
              name={name}
              type={type}
              value={value}
              autoComplete={autoComplete}
              inputMode={inputMode}
              autoCapitalize="none"
              spellCheck={false}
              placeholder={placeholder}
              onChange={(e) => onChange(e.target.value)}
              onBlur={onBlur}
              aria-invalid={!!error || undefined}
              aria-describedby={error ? `${id}-err` : undefined}
              className={cx(
                "h-10 w-full rounded-lg bg-paper px-3 text-[16px] sm:text-[14px] text-ink outline-none transition-shadow duration-200 placeholder:text-mute",
                !!end && "pr-11",
                error
                  ? "shadow-[inset_0_0_0_1.5px_var(--color-ink)] focus-visible:ring-2 focus-visible:ring-ink/30"
                  : `${RING} focus-visible:ring-2 focus-visible:ring-brand/50`,
              )}
            />
            {end && <div className="absolute inset-y-0 right-1 flex items-center">{end}</div>}
          </div>
          <p
            id={`${id}-err`}
            role={error ? "alert" : undefined}
            className={cx("grid text-[12.5px] text-ink transition-[grid-template-rows,opacity] duration-300", EASE, error ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0")}
          >
            <span className="overflow-hidden">{error}</span>
          </p>
        </div>
      );
    }
    
    const validEmail = (v: string) => /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(v.trim());
    
    export interface SignInCardProps {
      title?: string;
      subtitle?: string;
      /** Called with the credentials; resolve to finish, reject (with a message) to show an error. */
      onSubmit?: (data: { email: string; password: string }) => Promise<void>;
      onSocial?: (provider: "google" | "github") => void;
      className?: string;
    }
    
    /**
     * An email + password card with social sign-in, inline validation (errors appear on blur or submit and the
     * field shakes once), a submit that shows progress and a success state that morphs in.
     */
    export function SignInCard({ title = "Welcome back", subtitle = "Sign in to continue to your workspace.", onSubmit, onSocial, className }: SignInCardProps) {
      const [email, setEmail] = useState("");
      const [password, setPassword] = useState("");
      const [touched, setTouched] = useState({ email: false, password: false });
      const [reveal, setReveal] = useState(false);
      const [state, setState] = useState<"idle" | "loading" | "done">("idle");
      const [formError, setFormError] = useState("");
      const [shake, setShake] = useState(0);
    
      const check = {
        email: (v: string) => (!v.trim() ? "Enter your email." : !validEmail(v) ? "Enter an email like [email protected]." : ""),
        password: (v: string) => (!v ? "Enter your password." : v.length < 8 ? "Use at least 8 characters." : ""),
      };
      const errors = { email: check.email(email), password: check.password(password) };
      const show = (k: "email" | "password") => (touched[k] ? errors[k] : "");
      // Errors show on blur or submit. A value that becomes valid while typing clears its error and stays quiet
      // until the next blur, so a new error never pops up mid-word.
      const edit = (k: "email" | "password", v: string) => {
        if (k === "email") setEmail(v);
        else setPassword(v);
        if (touched[k] && !check[k](v)) setTouched((t) => ({ ...t, [k]: false }));
      };
    
      const submit = async (e: FormEvent<HTMLFormElement>) => {
        e.preventDefault();
        setTouched({ email: true, password: true });
        setFormError("");
        if (errors.email || errors.password) {
          setShake((n) => n + 1);
          const first = e.currentTarget.elements.namedItem(errors.email ? "email" : "password");
          if (first instanceof HTMLInputElement) first.focus();
          return;
        }
        setState("loading");
        try {
          await (onSubmit?.({ email, password }) ?? new Promise((r) => setTimeout(r, 1200)));
          setState("done");
        } catch (err) {
          setState("idle");
          setFormError(err instanceof Error ? err.message : "Something went wrong. Try again.");
        }
      };
    
      const reset = () => {
        setEmail("");
        setPassword("");
        setTouched({ email: false, password: false });
        setState("idle");
      };
    
      return (
        <div className={cx("kit-signin relative w-full max-w-[380px] overflow-hidden rounded-xl bg-paper p-6 sm:p-7", "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_10%,transparent),0_1px_2px_rgb(0_0_0/0.04),0_18px_40px_-20px_rgb(0_0_0/0.25)]", className)}>
          <style href="asta-sign-in" precedence="asta">{CSS}</style>
          {state === "done" ? (
            <div className="flex min-h-[380px] flex-col items-center justify-center text-center" style={{ animation: "kit-signin-pop .5s cubic-bezier(.16,1,.3,1) both" }} role="status">
              <span className="flex h-14 w-14 items-center justify-center rounded-full bg-brand text-on-brand">
                <svg viewBox="0 0 24 24" className="h-7 w-7" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                  <path d="M5 12.5l4.5 4.5L19 7.5" strokeDasharray="24" style={{ animation: "kit-signin-draw .5s .15s cubic-bezier(.16,1,.3,1) both" }} />
                </svg>
              </span>
              <h3 className="mt-5 text-[20px] font-medium tracking-[-0.02em] text-ink">You&apos;re in</h3>
              <p className="mt-1.5 max-w-[26ch] text-[14px] leading-snug text-mute">
                Signed in as <span className="text-ink">{email}</span>.
              </p>
              <Button variant="soft" size="sm" className="mt-6" onClick={reset}>
                Sign out
              </Button>
            </div>
          ) : (
            <form noValidate onSubmit={submit} className="flex flex-col">
              <h3 className="text-[20px] font-medium tracking-[-0.02em] text-ink">{title}</h3>
              <p className="mt-1 text-[14px] leading-snug text-mute">{subtitle}</p>
    
              <div className="mt-6 grid grid-cols-2 gap-2">
                <Button variant="outline" iconLeft={<GoogleGlyph />} onClick={() => onSocial?.("google")}>
                  Google
                </Button>
                <Button variant="outline" iconLeft={<GitHubGlyph />} onClick={() => onSocial?.("github")}>
                  GitHub
                </Button>
              </div>
    
              <div className="my-5 flex items-center gap-3 text-[12px] text-mute" aria-hidden>
                <span className="h-px flex-1 bg-[color-mix(in_srgb,var(--color-ink)_10%,transparent)]" />
                or
                <span className="h-px flex-1 bg-[color-mix(in_srgb,var(--color-ink)_10%,transparent)]" />
              </div>
    
              <div className="flex flex-col gap-3">
                <Field
                  label="Email"
                  name="email"
                  type="email"
                  autoComplete="email"
                  inputMode="email"
                  placeholder="[email protected]"
                  value={email}
                  onChange={(v) => edit("email", v)}
                  onBlur={() => email && setTouched((t) => ({ ...t, email: true }))}
                  error={show("email")}
                  shake={shake}
                />
                <Field
                  label="Password"
                  name="password"
                  type={reveal ? "text" : "password"}
                  autoComplete="current-password"
                  placeholder="At least 8 characters…"
                  value={password}
                  onChange={(v) => edit("password", v)}
                  onBlur={() => password && setTouched((t) => ({ ...t, password: true }))}
                  error={show("password")}
                  shake={shake}
                  end={
                    <button
                      type="button"
                      onClick={() => setReveal((v) => !v)}
                      aria-label={reveal ? "Hide password" : "Show password"}
                      aria-pressed={reveal}
                      className="flex h-8 w-8 items-center justify-center rounded-lg text-mute outline-none transition-colors hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50"
                    >
                      <svg viewBox="0 0 24 24" className="h-4 w-4" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                        <path d="M2.5 12c3-5.5 16-5.5 19 0-3 5.5-16 5.5-19 0Z" />
                        <circle cx="12" cy="12" r="2.75" />
                        <path d="m4.5 4.5 15 15" className={cx("transition-[stroke-dashoffset] duration-300", EASE)} strokeDasharray="22" strokeDashoffset={reveal ? 22 : 0} />
                      </svg>
                    </button>
                  }
                />
              </div>
    
              <div className="mt-3 flex items-center justify-between text-[13px]">
                <label className="flex cursor-pointer items-center gap-2 text-ink-2">
                  <input type="checkbox" name="remember" defaultChecked className="h-3.5 w-3.5 accent-[var(--color-brand)]" />
                  Remember me
                </label>
                <a href="#" onClick={(e) => e.preventDefault()} className="text-brand outline-none hover:underline focus-visible:underline">
                  Forgot password?
                </a>
              </div>
    
              {formError && (
                <p role="alert" className="mt-4 rounded-lg bg-paper-2 px-3 py-2 text-[13px] text-ink">
                  {formError}
                </p>
              )}
    
              <Button type="submit" variant="solid" size="md" loading={state === "loading"} className="mt-5 w-full">
                Sign in
              </Button>
              <p className="mt-4 text-center text-[13px] text-mute">
                New here?{" "}
                <a href="#" onClick={(e) => e.preventDefault()} className="font-medium text-ink outline-none hover:underline focus-visible:underline">
                  Create an account
                </a>
              </p>
            </form>
          )}
        </div>
      );
    }
    
    export default SignInCard;
    
    "use client";
    
    import { useEffect, useId, useRef, useState, type FormEvent, type ReactNode } from "react";
    import { Button } from "@/components/kit/base/button";
    
    const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
    
    const RING = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_14%,transparent)]";
    const EASE = "ease-[cubic-bezier(.16,1,.3,1)]";
    
    const CSS = `
    @keyframes kit-signin-pop { from { opacity: 0; transform: scale(.92) translateY(6px) } to { opacity: 1; transform: none } }
    @keyframes kit-signin-draw { from { stroke-dashoffset: 24 } to { stroke-dashoffset: 0 } }
    @media (prefers-reduced-motion: reduce) { .kit-signin * { animation: none !important } }
    `;
    
    const GoogleGlyph = () => (
      <svg viewBox="0 0 16 16" aria-hidden>
        <path fill="currentColor" d="M8 6.6v2.9h4.1A4.3 4.3 0 0 1 8 12.4a4.4 4.4 0 0 1 0-8.8c1.1 0 2.1.4 2.9 1.1l2-2A7.3 7.3 0 0 0 8 .7a7.3 7.3 0 1 0 0 14.6c4.2 0 7-3 7-7.1 0-.5 0-1-.1-1.5H8Z" />
      </svg>
    );
    const GitHubGlyph = () => (
      <svg viewBox="0 0 16 16" aria-hidden>
        <path
          fill="currentColor"
          d="M8 .5a7.5 7.5 0 0 0-2.4 14.6c.4.1.5-.2.5-.4v-1.4c-2.1.5-2.5-.9-2.5-.9-.4-.9-.9-1.1-.9-1.1-.7-.5 0-.5 0-.5.8.1 1.2.8 1.2.8.7 1.2 1.8.8 2.2.6.1-.5.3-.8.5-1-1.7-.2-3.4-.8-3.4-3.7 0-.8.3-1.5.8-2-.1-.2-.3-1 .1-2 0 0 .6-.2 2.1.8a7 7 0 0 1 3.8 0c1.4-1 2.1-.8 2.1-.8.4 1 .2 1.8.1 2 .5.5.8 1.2.8 2 0 2.9-1.8 3.5-3.4 3.7.3.2.5.7.5 1.4v2.1c0 .2.1.5.5.4A7.5 7.5 0 0 0 8 .5Z"
        />
      </svg>
    );
    
    interface FieldProps {
      label: string;
      type: string;
      value: string;
      onChange: (v: string) => void;
      onBlur: () => void;
      error?: string;
      /** Bumped on every failed submit so the field shakes again. */
      shake: number;
      name: string;
      autoComplete: string;
      inputMode?: "email" | "text";
      placeholder?: string;
      end?: ReactNode;
    }
    
    function Field({ label, type, value, onChange, onBlur, error, shake, name, autoComplete, inputMode, placeholder, end }: FieldProps) {
      const id = useId();
      const box = useRef<HTMLDivElement>(null);
      const hasError = !!error;
      // Shake once when an error shows up, and again on every failed submit.
      useEffect(() => {
        if (!hasError || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
        box.current?.animate(
          [{ transform: "none" }, { transform: "translateX(-6px)" }, { transform: "translateX(5px)" }, { transform: "translateX(-3px)" }, { transform: "translateX(2px)" }, { transform: "none" }],
          { duration: 420, easing: "cubic-bezier(.16,1,.3,1)" },
        );
      }, [hasError, shake]);
      return (
        <div className="flex flex-col gap-1.5">
          <label htmlFor={id} className="text-[13px] font-medium text-ink">
            {label}
          </label>
          <div ref={box} className="relative">
            <input
              id={id}
              name={name}
              type={type}
              value={value}
              autoComplete={autoComplete}
              inputMode={inputMode}
              autoCapitalize="none"
              spellCheck={false}
              placeholder={placeholder}
              onChange={(e) => onChange(e.target.value)}
              onBlur={onBlur}
              aria-invalid={!!error || undefined}
              aria-describedby={error ? `${id}-err` : undefined}
              className={cx(
                "h-10 w-full rounded-lg bg-paper px-3 text-[16px] sm:text-[14px] text-ink outline-none transition-shadow duration-200 placeholder:text-mute",
                !!end && "pr-11",
                error
                  ? "shadow-[inset_0_0_0_1.5px_var(--color-ink)] focus-visible:ring-2 focus-visible:ring-ink/30"
                  : `${RING} focus-visible:ring-2 focus-visible:ring-brand/50`,
              )}
            />
            {end && <div className="absolute inset-y-0 right-1 flex items-center">{end}</div>}
          </div>
          <p
            id={`${id}-err`}
            role={error ? "alert" : undefined}
            className={cx("grid text-[12.5px] text-ink transition-[grid-template-rows,opacity] duration-300", EASE, error ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0")}
          >
            <span className="overflow-hidden">{error}</span>
          </p>
        </div>
      );
    }
    
    const validEmail = (v: string) => /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(v.trim());
    
    export interface SignInCardProps {
      title?: string;
      subtitle?: string;
      /** Called with the credentials; resolve to finish, reject (with a message) to show an error. */
      onSubmit?: (data: { email: string; password: string }) => Promise<void>;
      onSocial?: (provider: "google" | "github") => void;
      className?: string;
    }
    
    /**
     * An email + password card with social sign-in, inline validation (errors appear on blur or submit and the
     * field shakes once), a submit that shows progress and a success state that morphs in.
     */
    export function SignInCard({ title = "Welcome back", subtitle = "Sign in to continue to your workspace.", onSubmit, onSocial, className }: SignInCardProps) {
      const [email, setEmail] = useState("");
      const [password, setPassword] = useState("");
      const [touched, setTouched] = useState({ email: false, password: false });
      const [reveal, setReveal] = useState(false);
      const [state, setState] = useState<"idle" | "loading" | "done">("idle");
      const [formError, setFormError] = useState("");
      const [shake, setShake] = useState(0);
    
      const check = {
        email: (v: string) => (!v.trim() ? "Enter your email." : !validEmail(v) ? "Enter an email like [email protected]." : ""),
        password: (v: string) => (!v ? "Enter your password." : v.length < 8 ? "Use at least 8 characters." : ""),
      };
      const errors = { email: check.email(email), password: check.password(password) };
      const show = (k: "email" | "password") => (touched[k] ? errors[k] : "");
      // Errors show on blur or submit. A value that becomes valid while typing clears its error and stays quiet
      // until the next blur, so a new error never pops up mid-word.
      const edit = (k: "email" | "password", v: string) => {
        if (k === "email") setEmail(v);
        else setPassword(v);
        if (touched[k] && !check[k](v)) setTouched((t) => ({ ...t, [k]: false }));
      };
    
      const submit = async (e: FormEvent<HTMLFormElement>) => {
        e.preventDefault();
        setTouched({ email: true, password: true });
        setFormError("");
        if (errors.email || errors.password) {
          setShake((n) => n + 1);
          const first = e.currentTarget.elements.namedItem(errors.email ? "email" : "password");
          if (first instanceof HTMLInputElement) first.focus();
          return;
        }
        setState("loading");
        try {
          await (onSubmit?.({ email, password }) ?? new Promise((r) => setTimeout(r, 1200)));
          setState("done");
        } catch (err) {
          setState("idle");
          setFormError(err instanceof Error ? err.message : "Something went wrong. Try again.");
        }
      };
    
      const reset = () => {
        setEmail("");
        setPassword("");
        setTouched({ email: false, password: false });
        setState("idle");
      };
    
      return (
        <div className={cx("kit-signin relative w-full max-w-[380px] overflow-hidden rounded-xl bg-paper p-6 sm:p-7", "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_10%,transparent),0_1px_2px_rgb(0_0_0/0.04),0_18px_40px_-20px_rgb(0_0_0/0.25)]", className)}>
          <style href="asta-sign-in" precedence="asta">{CSS}</style>
          {state === "done" ? (
            <div className="flex min-h-[380px] flex-col items-center justify-center text-center" style={{ animation: "kit-signin-pop .5s cubic-bezier(.16,1,.3,1) both" }} role="status">
              <span className="flex h-14 w-14 items-center justify-center rounded-full bg-brand text-on-brand">
                <svg viewBox="0 0 24 24" className="h-7 w-7" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                  <path d="M5 12.5l4.5 4.5L19 7.5" strokeDasharray="24" style={{ animation: "kit-signin-draw .5s .15s cubic-bezier(.16,1,.3,1) both" }} />
                </svg>
              </span>
              <h3 className="mt-5 text-[20px] font-medium tracking-[-0.02em] text-ink">You&apos;re in</h3>
              <p className="mt-1.5 max-w-[26ch] text-[14px] leading-snug text-mute">
                Signed in as <span className="text-ink">{email}</span>.
              </p>
              <Button variant="soft" size="sm" className="mt-6" onClick={reset}>
                Sign out
              </Button>
            </div>
          ) : (
            <form noValidate onSubmit={submit} className="flex flex-col">
              <h3 className="text-[20px] font-medium tracking-[-0.02em] text-ink">{title}</h3>
              <p className="mt-1 text-[14px] leading-snug text-mute">{subtitle}</p>
    
              <div className="mt-6 grid grid-cols-2 gap-2">
                <Button variant="outline" iconLeft={<GoogleGlyph />} onClick={() => onSocial?.("google")}>
                  Google
                </Button>
                <Button variant="outline" iconLeft={<GitHubGlyph />} onClick={() => onSocial?.("github")}>
                  GitHub
                </Button>
              </div>
    
              <div className="my-5 flex items-center gap-3 text-[12px] text-mute" aria-hidden>
                <span className="h-px flex-1 bg-[color-mix(in_srgb,var(--color-ink)_10%,transparent)]" />
                or
                <span className="h-px flex-1 bg-[color-mix(in_srgb,var(--color-ink)_10%,transparent)]" />
              </div>
    
              <div className="flex flex-col gap-3">
                <Field
                  label="Email"
                  name="email"
                  type="email"
                  autoComplete="email"
                  inputMode="email"
                  placeholder="[email protected]"
                  value={email}
                  onChange={(v) => edit("email", v)}
                  onBlur={() => email && setTouched((t) => ({ ...t, email: true }))}
                  error={show("email")}
                  shake={shake}
                />
                <Field
                  label="Password"
                  name="password"
                  type={reveal ? "text" : "password"}
                  autoComplete="current-password"
                  placeholder="At least 8 characters…"
                  value={password}
                  onChange={(v) => edit("password", v)}
                  onBlur={() => password && setTouched((t) => ({ ...t, password: true }))}
                  error={show("password")}
                  shake={shake}
                  end={
                    <button
                      type="button"
                      onClick={() => setReveal((v) => !v)}
                      aria-label={reveal ? "Hide password" : "Show password"}
                      aria-pressed={reveal}
                      className="flex h-8 w-8 items-center justify-center rounded-lg text-mute outline-none transition-colors hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50"
                    >
                      <svg viewBox="0 0 24 24" className="h-4 w-4" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                        <path d="M2.5 12c3-5.5 16-5.5 19 0-3 5.5-16 5.5-19 0Z" />
                        <circle cx="12" cy="12" r="2.75" />
                        <path d="m4.5 4.5 15 15" className={cx("transition-[stroke-dashoffset] duration-300", EASE)} strokeDasharray="22" strokeDashoffset={reveal ? 22 : 0} />
                      </svg>
                    </button>
                  }
                />
              </div>
    
              <div className="mt-3 flex items-center justify-between text-[13px]">
                <label className="flex cursor-pointer items-center gap-2 text-ink-2">
                  <input type="checkbox" name="remember" defaultChecked className="h-3.5 w-3.5 accent-[var(--color-brand)]" />
                  Remember me
                </label>
                <a href="#" onClick={(e) => e.preventDefault()} className="text-brand outline-none hover:underline focus-visible:underline">
                  Forgot password?
                </a>
              </div>
    
              {formError && (
                <p role="alert" className="mt-4 rounded-lg bg-paper-2 px-3 py-2 text-[13px] text-ink">
                  {formError}
                </p>
              )}
    
              <Button type="submit" variant="solid" size="md" loading={state === "loading"} className="mt-5 w-full">
                Sign in
              </Button>
              <p className="mt-4 text-center text-[13px] text-mute">
                New here?{" "}
                <a href="#" onClick={(e) => e.preventDefault()} className="font-medium text-ink outline-none hover:underline focus-visible:underline">
                  Create an account
                </a>
              </p>
            </form>
          )}
        </div>
      );
    }
    
    export default SignInCard;
    
  4. Or ask your AI agent

    Paste this into Claude Code, Cursor, Codex, v0 or Lovable. Fill in the last line. More in Prompts.

    Add the Astabyte UI Sign-in card component to my project.
    
    Email, password and social sign-in.
    It includes: Field, Button, validation, states.
    
    Install it (Radix build):
    ```sh
    pnpm dlx asta-ui@latest add sign-in --radix
    ```
    Or with the shadcn CLI:
    ```sh
    pnpm dlx shadcn@latest add https://ui.astabyte.com/r/sign-in.json
    ```
    If the project isn't set up yet, run `pnpm dlx asta-ui@latest init --radix` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4).
    
    Import it like this:
    ```tsx
    import { SignInCard } from "@/components/astabyte/sign-in";
    ```
    
    Usage example and props: https://ui.astabyte.com/sign-in
    Full catalogue for context: https://ui.astabyte.com/llms.txt
    
    Rules:
    - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS.
    - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback.
    - Keep keyboard, focus and ARIA behaviour (interactive pieces are built on Radix primitives from the radix-ui package).
    - Stay on Radix: install other Astabyte UI components with `--radix` so the project uses one primitive library.
    - Use fake data and fake brand names in examples.
    
    Use it to: [describe where it goes and what it should do]
    Add the Astabyte UI Sign-in card component to my project.
    
    Email, password and social sign-in.
    It includes: Field, Button, validation, states.
    
    Install it (Base UI build):
    ```sh
    pnpm dlx asta-ui@latest add sign-in
    ```
    Or with the shadcn CLI:
    ```sh
    pnpm dlx shadcn@latest add https://ui.astabyte.com/r/base/sign-in.json
    ```
    If the project isn't set up yet, run `pnpm dlx asta-ui@latest init` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4).
    
    Import it like this:
    ```tsx
    import { SignInCard } from "@/components/astabyte/sign-in";
    ```
    
    Usage example and props: https://ui.astabyte.com/sign-in
    Full catalogue for context: https://ui.astabyte.com/llms.txt
    
    Rules:
    - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS.
    - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback.
    - Keep keyboard, focus and ARIA behaviour (interactive pieces are built on Base UI primitives from the @base-ui/react package).
    - Stay on Base UI: install other Astabyte UI components without `--radix` so the project uses one primitive library.
    - Use fake data and fake brand names in examples.
    
    Use it to: [describe where it goes and what it should do]
  5. Or use plain HTML + CSS

    Not on React? Use it from Django, Rails, Laravel, Go html/template, htmx or a static page. Load asta.css and asta.js once (the head.html tab), then paste the markup. The ui.astabyte.com/cdn link is temporary: pin a version from jsDelivr for production. More in HTML + CSS.

    <!-- Needs asta.js for the password reveal; the form posts to /sign-in, which returns the error or the signed-in state. -->
    <div style="max-width:420px">
    <div id="sign-in" data-asta-sign-in class="asta-sign-in"><form action="/sign-in" method="post" novalidate hx-post="/sign-in" hx-target="#sign-in" hx-swap="outerHTML" hx-indicator="find button[type=submit]" class="asta-sign-in-form">
    <h3 class="asta-sign-in-title">Welcome back</h3><p class="asta-sign-in-subtitle">Use any email and the password astabyte.</p>
    <div class="asta-sign-in-providers"><a class="asta-btn asta-btn-outline" href="#sign-in"><span class="asta-btn-label"><svg viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 6.6v2.9h4.1A4.3 4.3 0 0 1 8 12.4a4.4 4.4 0 0 1 0-8.8c1.1 0 2.1.4 2.9 1.1l2-2A7.3 7.3 0 0 0 8 .7a7.3 7.3 0 1 0 0 14.6c4.2 0 7-3 7-7.1 0-.5 0-1-.1-1.5H8Z"/></svg>Google</span><span class="asta-btn-spinner" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6" stroke="currentColor" stroke-opacity="0.25" stroke-width="2"/><path d="M14 8a6 6 0 0 0-6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></span></a><a class="asta-btn asta-btn-outline" href="#sign-in"><span class="asta-btn-label">GitHub</span><span class="asta-btn-spinner" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6" stroke="currentColor" stroke-opacity="0.25" stroke-width="2"/><path d="M14 8a6 6 0 0 0-6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></span></a></div>
    <div class="asta-sign-in-divider" aria-hidden="true">or</div>
    <div class="asta-sign-in-fields">
    <div class="asta-field"><div class="asta-field-head"><label class="asta-label" for="si-email">Email</label></div><label class="asta-input"><input class="asta-input-control" id="si-email" name="email" type="email" placeholder="[email protected]" autocomplete="email" inputmode="email" autocapitalize="none" spellcheck="false"></label></div>
    <div class="asta-field"><div class="asta-field-head"><label class="asta-label" for="si-pw">Password</label></div><div class="asta-sign-in-shake"><label class="asta-input" style="padding-right:4px"><input class="asta-input-control" id="si-pw" name="password" type="password" placeholder="At least 8 characters…" aria-invalid="true" aria-describedby="si-pw-error" autocomplete="current-password" autocapitalize="none" spellcheck="false"><svg class="asta-input-status" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><circle cx="8" cy="8" r="6.25"/><path d="M8 5v3.5M8 11h.01"/></svg><span class="asta-input-trailing"><button type="button" data-asta-reveal aria-label="Show password" aria-pressed="false" class="asta-sign-in-reveal"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/><path d="M2.5 13.5l11-11" class="asta-sign-in-reveal-slash"/></svg></button></span></label></div><p class="asta-error" id="si-pw-error" role="alert">Wrong password. Try astabyte.</p></div>
    </div>
    <div class="asta-sign-in-options"><label class="asta-checkbox"><span class="asta-checkbox-box"><input type="checkbox" class="asta-checkbox-input" name="remember"><svg class="asta-checkbox-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7"/></svg><span class="asta-checkbox-dash" aria-hidden="true"></span></span><span><span class="asta-checkbox-label" style="font-size:13px">Remember me</span></span></label><a href="#" class="asta-sign-in-link">Forgot password?</a></div>
    <button class="asta-btn asta-sign-in-submit" type="submit"><span class="asta-btn-label">Sign in</span><span class="asta-btn-spinner" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6" stroke="currentColor" stroke-opacity="0.25" stroke-width="2"/><path d="M14 8a6 6 0 0 0-6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></span></button>
    <p class="asta-sign-in-footer">New here? <a href="#">Create an account</a></p>
    </form></div>
    </div>

Usage

The demo above, as code.

"use client";

import { SignInCard } from "@/components/astabyte/sign-in";

export default function SignInDemo() {
  return (
    <div className="relative flex min-h-[420px] w-full items-center justify-center p-4 sm:p-8">
      <SignInCard
        title="Welcome back"
        subtitle="Sign in to continue to your workspace."
        // Pretend to call the API. Reject with an Error to show a message above the button.
        onSubmit={() => new Promise((resolve) => setTimeout(resolve, 1300))}
      />
    </div>
  );
}