---
title: "Login SSO · UI SDK — StyleX Blocks"
description: "Enterprise single sign-on flow with work-email domain lookup, SAML 2.0 and OIDC identity provider confirmation (Okta, Microsoft Entra ID, Google Workspace), password fallback with inline validation, and toast feedback."
url: "https://stylexblocks.com/block/ui-sdk/login-sso/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Login SSO block

Enterprise single sign-on flow with work-email domain lookup, SAML 2.0 and OIDC identity provider confirmation (Okta, Microsoft Entra ID, Google Workspace), password fallback with inline validation, and toast feedback.

- Behavior engine: UI SDK
- Category: [Auth](https://stylexblocks.com/blocks/auth.md)
- Built with: [Alert](https://stylexblocks.com/components/ui-sdk/alert.md), [Avatar](https://stylexblocks.com/components/ui-sdk/avatar.md), [Badge](https://stylexblocks.com/components/ui-sdk/badge.md), [Button](https://stylexblocks.com/components/ui-sdk/button.md), [Card](https://stylexblocks.com/components/ui-sdk/card.md), [Center](https://stylexblocks.com/components/ui-sdk/center.md), [Field](https://stylexblocks.com/components/ui-sdk/field.md), [Heading](https://stylexblocks.com/components/ui-sdk/heading.md), [Icon](https://stylexblocks.com/components/ui-sdk/icon.md), [Input](https://stylexblocks.com/components/ui-sdk/input.md), [Link](https://stylexblocks.com/components/ui-sdk/link.md), [Password Input](https://stylexblocks.com/components/ui-sdk/password-input.md), [Separator](https://stylexblocks.com/components/ui-sdk/separator.md), [Spinner](https://stylexblocks.com/components/ui-sdk/spinner.md), [Stack](https://stylexblocks.com/components/ui-sdk/stack.md), [Text](https://stylexblocks.com/components/ui-sdk/text.md), [Toast](https://stylexblocks.com/components/ui-sdk/toast.md)
- HTML page: https://stylexblocks.com/block/ui-sdk/login-sso/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add login-sso
```

Equivalent: `npx shadcn add @stylexblocks/login-sso`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/login-sso.json

## Usage

```tsx
import { LoginSso } from "#components/blocks/ui-sdk/login-sso.tsx";

export function Example() {
  return (
    <div style={{ minHeight: "100dvh" }}>
      <LoginSso />
    </div>
  );
}
```

## Source

`components/blocks/ui-sdk/login-sso.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Alert } from "#components/ui/ui-sdk/alert.tsx";
import { Avatar } from "#components/ui/ui-sdk/avatar.tsx";
import { Badge } from "#components/ui/ui-sdk/badge.tsx";
import { Button } from "#components/ui/ui-sdk/button.tsx";
import { Card } from "#components/ui/ui-sdk/card.tsx";
import { Center, Circle, Square } from "#components/ui/ui-sdk/center.tsx";
import { Field } from "#components/ui/ui-sdk/field.tsx";
import { Heading } from "#components/ui/ui-sdk/heading.tsx";
import { Icon } from "#components/ui/ui-sdk/icon.tsx";
import { Input } from "#components/ui/ui-sdk/input.tsx";
import { Link } from "#components/ui/ui-sdk/link.tsx";
import { PasswordInput } from "#components/ui/ui-sdk/password-input.tsx";
import { Separator } from "#components/ui/ui-sdk/separator.tsx";
import { Spinner } from "#components/ui/ui-sdk/spinner.tsx";
import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";
import { Text } from "#components/ui/ui-sdk/text.tsx";
import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";
import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";
import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";
import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";
import {
  accentPalette,
  bluePalette,
  emeraldPalette,
  indigoPalette,
} from "@stylexblocks/ui/themes/palettes.ts";
import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";
import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";
import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";
import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";
import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";

// ── Types & Demo Data ─────────────────────────────────────────────────────────

export type SsoProviderPalette = "indigo" | "blue" | "emerald";

export interface SsoProviderConfig {
  id: string;
  name: string;
  abbr: string;
  protocol: "SAML 2.0" | "OIDC";
  tenantHost: string;
  palette: SsoProviderPalette;
}

export interface LoginSsoProps extends StyleOverrideProps {
  /** Workspace name shown across the authentication flow. */
  workspaceName?: string;
  /** Primary heading on the initial sign-in step. */
  title?: string;
  /** Supporting subtitle beneath the initial heading. */
  description?: string;
  /** Domain-to-identity-provider lookup map keyed by lowercase email domain. */
  providers?: Record<string, SsoProviderConfig>;
  /** Initial email address pre-filled in the work email input. */
  defaultEmail?: string;
  /** Optional backdrop artwork URL or data URI rendered behind the card. */
  backdropSrc?: string;
  /** Called when an enterprise SSO redirect is confirmed. */
  onSsoRedirect?: (payload: { email: string; provider: SsoProviderConfig }) => void;
  /** Called when password sign-in succeeds. */
  onPasswordSignIn?: (payload: { email: string }) => void;
}

const DEFAULT_SSO_PROVIDERS: Record<string, SsoProviderConfig> = {
  "helioslabs.io": {
    id: "okta",
    name: "Okta",
    abbr: "OK",
    protocol: "SAML 2.0",
    tenantHost: "helios.okta.com",
    palette: "indigo",
  },
  "okta.com": {
    id: "okta",
    name: "Okta",
    abbr: "OK",
    protocol: "SAML 2.0",
    tenantHost: "id.okta.com",
    palette: "indigo",
  },
  "northstar.co": {
    id: "entra",
    name: "Microsoft Entra ID",
    abbr: "ME",
    protocol: "OIDC",
    tenantHost: "login.microsoftonline.com/northstar",
    palette: "blue",
  },
  "microsoft.com": {
    id: "entra",
    name: "Microsoft Entra ID",
    abbr: "ME",
    protocol: "OIDC",
    tenantHost: "login.microsoftonline.com",
    palette: "blue",
  },
  "veridian.design": {
    id: "google",
    name: "Google Workspace",
    abbr: "GW",
    protocol: "SAML 2.0",
    tenantHost: "accounts.google.com/o/saml2",
    palette: "emerald",
  },
  "google.com": {
    id: "google",
    name: "Google Workspace",
    abbr: "GW",
    protocol: "SAML 2.0",
    tenantHost: "accounts.google.com/o/saml2",
    palette: "emerald",
  },
};

const SAMPLE_ACCOUNTS: Array<{ email: string; label: string }> = [
  { email: "maya@helioslabs.io", label: "Okta" },
  { email: "devon@northstar.co", label: "Entra ID" },
  { email: "claire@veridian.design", label: "Google" },
  { email: "alex@studio.org", label: "Password" },
];

type AuthStep = "email" | "sso-confirm" | "password-fallback" | "signed-in";
type FallbackReason = "no-sso" | "manual";

function extractDomain(email: string): string | null {
  const parts = email.trim().toLowerCase().split("@");
  if (parts.length !== 2 || !parts[1]) return null;
  return parts[1];
}

function isValidEmail(email: string): boolean {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
}

function resolvePalette(key: SsoProviderPalette) {
  if (key === "blue") return bluePalette;
  if (key === "emerald") return emeraldPalette;
  return indigoPalette;
}

// ── Inline SVG Icons ──────────────────────────────────────────────────────────

function HeliosMark() {
  return (
    <Square render={<span />} size="md" style={styles.brandMark} aria-hidden="true">
      <Icon
        size="md"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        strokeWidth="1.75"
        strokeLinecap="round"
        strokeLinejoin="round"
      >
        <circle cx="12" cy="12" r="4" />
        <path d="M12 3v2.5" />
        <path d="M12 18.5V21" />
        <path d="M3 12h2.5" />
        <path d="M18.5 12H21" />
        <path d="m5.64 5.64 1.77 1.77" />
        <path d="m16.59 16.59 1.77 1.77" />
        <path d="m18.36 5.64-1.77 1.77" />
        <path d="m7.41 16.59-1.77 1.77" />
      </Icon>
    </Square>
  );
}

function ShieldCheckIcon() {
  return (
    <Icon
      size="md"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.6"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M10 2.5 16 5v4.5c0 3.7-2.55 6.85-6 8-3.45-1.15-6-4.3-6-8V5l6-2.5Z" />
      <path d="m7.5 10.2 1.7 1.7 3.5-3.7" />
    </Icon>
  );
}

function KeyIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.6"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="7.5" cy="10" r="3.5" />
      <path d="M11 10h6.5" />
      <path d="M15 10v2.5" />
      <path d="M17.5 10v2" />
    </Icon>
  );
}

function ArrowRightIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.75"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M4.5 10h11" />
      <path d="M11 5.5 15.5 10 11 14.5" />
    </Icon>
  );
}

function CheckCircleIcon() {
  return (
    <Icon
      size="md"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.75"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="10" cy="10" r="7.5" />
      <path d="m7 10.3 2 2 4-4.5" />
    </Icon>
  );
}

function InfoCircleIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.7"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="10" cy="10" r="7.5" />
      <path d="M10 9.2v4.2" />
      <path d="M10 6.5h.01" />
    </Icon>
  );
}

// ── Styles ────────────────────────────────────────────────────────────────────

const styles = stylex.create({
  root: {
    backgroundColor: semanticColors.bg,
    color: semanticColors.fg,
    fontFamily: fonts.body,
    minHeight: "100%",
    overflowX: "hidden",
    overflowY: "auto",
    paddingBlock: spacing._8,
    paddingInline: spacing._4,
    position: "relative",
    width: "100%",
  },
  backdropImage: {
    height: "100%",
    left: 0,
    objectFit: "cover",
    pointerEvents: "none",
    position: "absolute",
    top: 0,
    userSelect: "none",
    width: "100%",
    zIndex: 0,
  },
  backdropScrim: {
    backgroundColor: semanticColors.bg,
    height: "100%",
    left: 0,
    opacity: 0.36,
    pointerEvents: "none",
    position: "absolute",
    top: 0,
    width: "100%",
    zIndex: 1,
  },
  stage: {
    maxWidth: "26.5rem",
    position: "relative",
    width: "100%",
    zIndex: 2,
  },
  card: {
    boxShadow: semanticShadows.xl,
    width: "100%",
  },
  cardBody: {
    gap: spacing._5,
    paddingBlock: {
      default: spacing._8,
      "@media (max-width: 480px)": spacing._6,
    },
    paddingInline: {
      default: spacing._8,
      "@media (max-width: 480px)": spacing._5,
    },
  },
  header: {
    textAlign: "center",
  },
  brandMark: {
    backgroundColor: semanticColors.accentSubtle,
    borderColor: semanticColors.accentBorder,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    color: semanticColors.accentFg,
    marginBottom: spacing._1,
  },
  heading: {
    marginBlock: 0,
    textAlign: "center",
    textWrap: "balance",
  },
  subtitle: {
    maxWidth: "34ch",
  },
  fieldsStack: {
    gap: spacing._3_5,
    width: "100%",
  },
  helperLink: {
    fontSize: fontSizes.xs,
    lineHeight: lineHeights.xs,
  },
  dividerLine: {
    flexBasis: 0,
    flexGrow: 1,
    flexShrink: 1,
    minWidth: 0,
    width: "auto",
  },
  dividerLabel: {
    flexShrink: 0,
    whiteSpace: "nowrap",
  },
  fullWidth: {
    width: "100%",
  },
  providerCard: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.border,
    borderStyle: "solid",
    borderWidth: "1px",
    width: "100%",
  },
  providerCardBody: {
    alignItems: "center",
    flexDirection: "row",
    gap: spacing._3,
    paddingBlock: spacing._3_5,
    paddingInline: spacing._4,
  },
  providerIconWrap: {
    color: semanticColors.fgMuted,
    flexShrink: 0,
  },
  providerMeta: {
    flexBasis: 0,
    flexGrow: 1,
    flexShrink: 1,
  },
  accountPill: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.border,
    borderRadius: radii.full,
    borderStyle: "solid",
    borderWidth: "1px",
    display: "inline-flex",
    maxWidth: "100%",
    paddingBlock: spacing._1,
    paddingInlineEnd: spacing._2,
    paddingInlineStart: spacing._3,
  },
  successBadgeWrap: {
    backgroundColor: semanticColors.bgSuccess,
    borderColor: semanticColors.borderSuccess,
    borderStyle: "solid",
    borderWidth: "1px",
    color: semanticColors.fgSuccess,
    marginBottom: spacing._1,
  },
  sessionSummaryBody: {
    gap: spacing._2_5,
    paddingBlock: spacing._3_5,
    paddingInline: spacing._4,
  },
  demoStrip: {
    backgroundColor: semanticColors.bgOverlay,
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    boxShadow: semanticShadows.md,
    paddingBlock: spacing._3,
    paddingInline: spacing._4,
    width: "100%",
  },
});

// ── Component ─────────────────────────────────────────────────────────────────

/**
 * LoginSso — enterprise SSO sign-in block with work-email domain lookup,
 * SAML 2.0 / OIDC identity provider confirmation (Okta, Microsoft Entra ID,
 * Google Workspace), password fallback with inline validation, and toast
 * feedback over an atmospheric architectural backdrop.
 */
export function LoginSso({
  workspaceName = "Helios Workspace",
  title = "Sign in to Helios",
  description = "Enter your work email to connect with your organization's identity provider.",
  providers = DEFAULT_SSO_PROVIDERS,
  defaultEmail = "",
  backdropSrc = "/images/blocks/login-sso/dusk-towers.webp",
  onSsoRedirect,
  onPasswordSignIn,
  palette,
  style,
}: LoginSsoProps) {
  const queue = useMemo(() => Toast.createToaster(), []);
  const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);

  const [step, setStep] = useState<AuthStep>("email");
  const [fallbackReason, setFallbackReason] = useState<FallbackReason>("no-sso");
  const [email, setEmail] = useState(defaultEmail);
  const [password, setPassword] = useState("");
  const [emailError, setEmailError] = useState<string | null>(null);
  const [passwordError, setPasswordError] = useState<string | null>(null);
  const [isLoading, setIsLoading] = useState(false);
  const [authMethodLabel, setAuthMethodLabel] = useState("");

  const clearPendingTimer = useCallback(() => {
    if (timerRef.current !== null) {
      clearTimeout(timerRef.current);
      timerRef.current = null;
    }
  }, []);

  useEffect(() => clearPendingTimer, [clearPendingTimer]);

  const normalizedEmail = email.trim();
  const domain = extractDomain(normalizedEmail);
  const detectedProvider = domain ? (providers[domain] ?? null) : null;
  const emailValid = isValidEmail(normalizedEmail);

  const handleEmailChange = useCallback((next: string) => {
    setEmail(next);
    setEmailError(null);
  }, []);

  const handlePasswordChange = useCallback((next: string) => {
    setPassword(next);
    setPasswordError(null);
  }, []);

  const verifyPasswordSignIn = useCallback(
    (targetEmail: string, candidatePassword: string) => {
      if (!candidatePassword.trim()) {
        setPasswordError("Enter your password to continue.");
        return;
      }
      if (candidatePassword.length < 6) {
        setPasswordError("Password must be at least 6 characters.");
        return;
      }
      if (candidatePassword.trim().toLowerCase() === "wrong") {
        setPasswordError("Incorrect password. Check your credentials and try again.");
        return;
      }

      clearPendingTimer();
      setIsLoading(true);
      setPasswordError(null);

      timerRef.current = setTimeout(() => {
        timerRef.current = null;
        setIsLoading(false);
        setAuthMethodLabel("Workspace password");
        setStep("signed-in");
        onPasswordSignIn?.({ email: targetEmail });
        queue.success(`Signed in to ${workspaceName}`, {
          description: `Authenticated as ${targetEmail}.`,
        });
      }, 900);
    },
    [clearPendingTimer, onPasswordSignIn, queue, workspaceName],
  );

  const handleEmailStepSubmit = useCallback(
    (event: React.FormEvent<HTMLFormElement>) => {
      event.preventDefault();
      if (!emailValid) {
        setEmailError("Enter a valid work email address (for example, maya@helioslabs.io).");
        return;
      }

      setEmailError(null);

      if (detectedProvider) {
        setStep("sso-confirm");
        return;
      }

      if (password.trim().length > 0) {
        verifyPasswordSignIn(normalizedEmail, password);
        return;
      }

      setFallbackReason("no-sso");
      setPasswordError(null);
      setStep("password-fallback");
    },
    [detectedProvider, emailValid, normalizedEmail, password, verifyPasswordSignIn],
  );

  const handleSsoLookup = useCallback(() => {
    if (!emailValid) {
      setEmailError("Enter your work email first so we can look up your SSO provider.");
      queue.info("Work email required for SSO", {
        description: "Try a managed domain like maya@helioslabs.io or devon@northstar.co.",
      });
      return;
    }

    setEmailError(null);

    if (detectedProvider) {
      setStep("sso-confirm");
      return;
    }

    setFallbackReason("no-sso");
    setPasswordError(null);
    setStep("password-fallback");
    queue.info(`No SSO provider found for ${domain ?? "this domain"}`, {
      description: "Continue with your workspace password instead.",
    });
  }, [detectedProvider, domain, emailValid, queue]);

  const handleSsoConfirm = useCallback(() => {
    if (!detectedProvider || isLoading) return;

    clearPendingTimer();
    setIsLoading(true);
    onSsoRedirect?.({ email: normalizedEmail, provider: detectedProvider });
    queue.info(`Redirecting to ${detectedProvider.name}…`, {
      description: `Validating ${detectedProvider.protocol} assertion for ${normalizedEmail}.`,
    });

    timerRef.current = setTimeout(() => {
      timerRef.current = null;
      setIsLoading(false);
      setAuthMethodLabel(`${detectedProvider.name} · ${detectedProvider.protocol}`);
      setStep("signed-in");
      queue.success(`Authenticated via ${detectedProvider.name}`, {
        description: `Welcome back to ${workspaceName}, ${normalizedEmail}.`,
      });
    }, 1100);
  }, [
    clearPendingTimer,
    detectedProvider,
    isLoading,
    normalizedEmail,
    onSsoRedirect,
    queue,
    workspaceName,
  ]);

  const handlePasswordFallbackSubmit = useCallback(
    (event: React.FormEvent<HTMLFormElement>) => {
      event.preventDefault();
      verifyPasswordSignIn(normalizedEmail, password);
    },
    [normalizedEmail, password, verifyPasswordSignIn],
  );

  const handleBackToEmail = useCallback(() => {
    clearPendingTimer();
    setIsLoading(false);
    setPasswordError(null);
    setStep("email");
  }, [clearPendingTimer]);

  const handleResetFlow = useCallback(() => {
    clearPendingTimer();
    setIsLoading(false);
    setPassword("");
    setEmailError(null);
    setPasswordError(null);
    setStep("email");
  }, [clearPendingTimer]);

  const handleSelectSample = useCallback(
    (sampleEmail: string) => {
      clearPendingTimer();
      setIsLoading(false);
      setEmail(sampleEmail);
      setPassword("");
      setEmailError(null);
      setPasswordError(null);
      setStep("email");
    },
    [clearPendingTimer],
  );

  const handleSupportClick = useCallback(
    (event: React.MouseEvent<HTMLAnchorElement>) => {
      event.preventDefault();
      queue.info("IT helpdesk notified", {
        description: "Check your organization's identity portal or contact security@helioslabs.io.",
      });
    },
    [queue],
  );

  const handleForgotPasswordClick = useCallback(
    (event: React.MouseEvent<HTMLAnchorElement>) => {
      event.preventDefault();
      queue.success("Password reset email sent", {
        description: `If ${normalizedEmail || "that address"} has a local password, reset instructions are on the way.`,
      });
    },
    [normalizedEmail, queue],
  );

  const handleRequestAccessClick = useCallback(
    (event: React.MouseEvent<HTMLAnchorElement>) => {
      event.preventDefault();
      queue.info("Workspace access request", {
        description: `Ask your ${workspaceName} administrator to provision your seat via SCIM or invite.`,
      });
    },
    [queue, workspaceName],
  );

  const handleSwitchToPasswordFallback = useCallback(
    (event: React.MouseEvent<HTMLAnchorElement>) => {
      event.preventDefault();
      clearPendingTimer();
      setIsLoading(false);
      setFallbackReason("manual");
      setPasswordError(null);
      setStep("password-fallback");
    },
    [clearPendingTimer],
  );

  return (
    <VStack
      align="center"
      justify="center"
      gap="0"
      palette={palette}
      style={[styles.root, style]}
    >
      <img
        src={backdropSrc}
        alt=""
        aria-hidden="true"
        {...stylex.props(styles.backdropImage)}
      />
      <div aria-hidden="true" {...stylex.props(styles.backdropScrim)} />

      <VStack render={<main />} align="center" gap="4" style={styles.stage}>
        <Card.Root variant="elevated" size="lg" style={styles.card}>
          <Card.Body style={styles.cardBody}>
            {/* ── Step 1: Work email & SSO lookup ── */}
            {step === "email" ? (
              <>
                <VStack render={<header />} align="center" gap="2" style={styles.header}>
                  <HeliosMark />
                  <Heading render={<h1 />} size="2xl" style={styles.heading}>
                    {title}
                  </Heading>
                  <Text variant="muted" size="sm" align="center" style={styles.subtitle}>
                    {description}
                  </Text>
                </VStack>

                <VStack
                  render={<form noValidate onSubmit={handleEmailStepSubmit} />}
                  gap="4"
                  style={styles.fullWidth}
                >
                  <VStack style={styles.fieldsStack}>
                    <Field.Root invalid={Boolean(emailError)}>
                      <HStack gap="2" justify="between" style={styles.fullWidth}>
                        <Field.Label>Work email</Field.Label>
                        {detectedProvider ? (
                          <Badge
                            variant="subtle"
                            size="xs"
                            palette={resolvePalette(detectedProvider.palette)}
                          >
                            {detectedProvider.name} · {detectedProvider.protocol}
                          </Badge>
                        ) : null}
                      </HStack>
                      <Input
                        type="email"
                        size="lg"
                        autoComplete="email"
                        placeholder="maya@helioslabs.io"
                        value={email}
                        onValueChange={handleEmailChange}
                      />
                      {emailError ? <Field.Error match>{emailError}</Field.Error> : null}
                    </Field.Root>

                    <PasswordInput.Root
                      size="lg"
                      autoComplete="current-password"
                      value={password}
                      onValueChange={handlePasswordChange}
                      invalid={Boolean(passwordError)}
                    >
                      <HStack gap="2" justify="between" style={styles.fullWidth}>
                        <PasswordInput.Label>Password</PasswordInput.Label>
                        <Link
                          href="#help"
                          variant="plain"
                          style={styles.helperLink}
                          onClick={handleSupportClick}
                        >
                          Trouble signing in?
                        </Link>
                      </HStack>
                      <PasswordInput.Control>
                        <PasswordInput.Input
                          placeholder={
                            detectedProvider
                              ? "Not required for SSO domains"
                              : "Enter password"
                          }
                        />
                        <PasswordInput.VisibilityTrigger />
                      </PasswordInput.Control>
                      {passwordError ? (
                        <Field.Error match>{passwordError}</Field.Error>
                      ) : null}
                    </PasswordInput.Root>
                  </VStack>

                  <VStack gap="2.5" style={styles.fullWidth}>
                    <Button
                      type="submit"
                      variant="solid"
                      size="lg"
                      palette={accentPalette}
                      disabled={isLoading}
                      style={styles.fullWidth}
                    >
                      {isLoading ? (
                        <>
                          <Spinner size="sm" />
                          Signing in…
                        </>
                      ) : detectedProvider ? (
                        <>
                          Continue with {detectedProvider.name}
                          <ArrowRightIcon />
                        </>
                      ) : (
                        "Sign in"
                      )}
                    </Button>

                    <HStack gap="3" style={styles.fullWidth}>
                      <Separator decorative style={styles.dividerLine} />
                      <Text render={<span />} variant="caption" style={styles.dividerLabel}>
                        Or sign in with
                      </Text>
                      <Separator decorative style={styles.dividerLine} />
                    </HStack>

                    <Button
                      type="button"
                      variant="surface"
                      size="lg"
                      disabled={isLoading}
                      onClick={handleSsoLookup}
                      style={styles.fullWidth}
                    >
                      <KeyIcon />
                      Continue with SSO
                    </Button>
                  </VStack>
                </VStack>

                <Text variant="caption" align="center">
                  Don&apos;t have a workspace seat?{" "}
                  <Link
                    href="#request-access"
                    variant="underline"
                    palette={accentPalette}
                    onClick={handleRequestAccessClick}
                  >
                    Request access
                  </Link>
                </Text>
              </>
            ) : null}

            {/* ── Step 2a: SSO provider detected ── */}
            {step === "sso-confirm" && detectedProvider ? (
              <>
                <VStack render={<header />} align="center" gap="2" style={styles.header}>
                  <Avatar.Root
                    variant="subtle"
                    size="lg"
                    shape="rounded"
                    palette={resolvePalette(detectedProvider.palette)}
                  >
                    <Avatar.Fallback>{detectedProvider.abbr}</Avatar.Fallback>
                  </Avatar.Root>
                  <Heading render={<h1 />} size="2xl" style={styles.heading}>
                    Sign in with {detectedProvider.name}
                  </Heading>
                  <Text variant="muted" size="sm" align="center" style={styles.subtitle}>
                    Your organization uses enterprise single sign-on. You&apos;ll return to{" "}
                    {workspaceName} right after authenticating.
                  </Text>
                </VStack>

                <Card.Root variant="subtle" size="md" style={styles.providerCard}>
                  <Card.Body style={styles.providerCardBody}>
                    <Center render={<span />} display="inline" style={styles.providerIconWrap}>
                      <ShieldCheckIcon />
                    </Center>
                    <VStack gap="0.5" style={styles.providerMeta}>
                      <HStack gap="2" wrap="wrap">
                        <Text render={<span />} variant="label" size="sm">
                          {detectedProvider.name}
                        </Text>
                        <Badge
                          variant="subtle"
                          size="xs"
                          palette={resolvePalette(detectedProvider.palette)}
                        >
                          {detectedProvider.protocol}
                        </Badge>
                      </HStack>
                      <Text render={<span />} variant="caption" truncate="true">
                        {normalizedEmail}
                      </Text>
                      <Text
                        render={<span />}
                        variant="mono"
                        size="xs"
                        tone="subtle"
                        truncate="true"
                      >
                        {detectedProvider.tenantHost}
                      </Text>
                    </VStack>
                  </Card.Body>
                </Card.Root>

                <VStack gap="2.5" style={styles.fullWidth}>
                  <Button
                    type="button"
                    variant="solid"
                    size="lg"
                    palette={accentPalette}
                    disabled={isLoading}
                    onClick={handleSsoConfirm}
                    style={styles.fullWidth}
                  >
                    {isLoading ? (
                      <>
                        <Spinner size="sm" />
                        Redirecting to {detectedProvider.name}…
                      </>
                    ) : (
                      <>
                        Continue to {detectedProvider.name}
                        <ArrowRightIcon />
                      </>
                    )}
                  </Button>
                  <Button
                    type="button"
                    variant="ghost"
                    size="lg"
                    onClick={handleBackToEmail}
                    style={styles.fullWidth}
                  >
                    Use a different email
                  </Button>
                </VStack>

                <Text variant="caption" align="center">
                  Local workspace administrator?{" "}
                  <Link
                    href="#password-fallback"
                    variant="underline"
                    palette={accentPalette}
                    onClick={handleSwitchToPasswordFallback}
                  >
                    Use password instead
                  </Link>
                </Text>
              </>
            ) : null}

            {/* ── Step 2b: Password fallback ── */}
            {step === "password-fallback" ? (
              <>
                <VStack render={<header />} align="center" gap="2" style={styles.header}>
                  <HeliosMark />
                  <Heading render={<h1 />} size="2xl" style={styles.heading}>
                    Enter your password
                  </Heading>
                  <HStack gap="2" style={styles.accountPill}>
                    <Text render={<span />} size="xs" weight="medium" truncate="true">
                      {normalizedEmail}
                    </Text>
                    <Button
                      type="button"
                      variant="plain"
                      size="2xs"
                      palette={accentPalette}
                      onClick={handleBackToEmail}
                    >
                      Change
                    </Button>
                  </HStack>
                </VStack>

                {fallbackReason === "no-sso" ? (
                  <Alert.Root
                    status="info"
                    variant="subtle"
                    size="sm"
                    palette={bluePalette}
                  >
                    <Alert.Indicator>
                      <InfoCircleIcon />
                    </Alert.Indicator>
                    <Alert.Content>
                      <Alert.Description>
                        No SSO provider is linked to <strong>{domain}</strong>. Sign in with
                        your {workspaceName} password.
                      </Alert.Description>
                    </Alert.Content>
                  </Alert.Root>
                ) : null}

                <VStack
                  render={<form noValidate onSubmit={handlePasswordFallbackSubmit} />}
                  gap="4"
                  style={styles.fullWidth}
                >
                  <PasswordInput.Root
                    size="lg"
                    required
                    autoComplete="current-password"
                    value={password}
                    onValueChange={handlePasswordChange}
                    invalid={Boolean(passwordError)}
                  >
                    <HStack gap="2" justify="between" style={styles.fullWidth}>
                      <PasswordInput.Label>Password</PasswordInput.Label>
                      <Link
                        href="#forgot-password"
                        variant="plain"
                        style={styles.helperLink}
                        onClick={handleForgotPasswordClick}
                      >
                        Forgot password?
                      </Link>
                    </HStack>
                    <PasswordInput.Control>
                      <PasswordInput.Input
                        placeholder="Enter your workspace password"
                        autoFocus
                      />
                      <PasswordInput.VisibilityTrigger />
                    </PasswordInput.Control>
                    {passwordError ? (
                      <Field.Error match>{passwordError}</Field.Error>
                    ) : null}
                  </PasswordInput.Root>

                  <VStack gap="2.5" style={styles.fullWidth}>
                    <Button
                      type="submit"
                      variant="solid"
                      size="lg"
                      palette={accentPalette}
                      disabled={isLoading}
                      style={styles.fullWidth}
                    >
                      {isLoading ? (
                        <>
                          <Spinner size="sm" />
                          Verifying credentials…
                        </>
                      ) : (
                        "Sign in"
                      )}
                    </Button>
                    <Button
                      type="button"
                      variant="ghost"
                      size="lg"
                      onClick={handleBackToEmail}
                      style={styles.fullWidth}
                    >
                      Use a different email
                    </Button>
                  </VStack>
                </VStack>
              </>
            ) : null}

            {/* ── Step 3: Authenticated confirmation ── */}
            {step === "signed-in" ? (
              <>
                <VStack render={<header />} align="center" gap="2" style={styles.header}>
                  <Circle
                    render={<span />}
                    size="lg"
                    style={styles.successBadgeWrap}
                    aria-hidden="true"
                  >
                    <CheckCircleIcon />
                  </Circle>
                  <Heading render={<h1 />} size="2xl" style={styles.heading}>
                    You&apos;re signed in
                  </Heading>
                  <Text variant="muted" size="sm" align="center" style={styles.subtitle}>
                    Your session for {workspaceName} is verified and ready.
                  </Text>
                </VStack>

                <Card.Root variant="subtle" size="md" style={styles.providerCard}>
                  <Card.Body style={styles.sessionSummaryBody}>
                    <HStack gap="2" justify="between" style={styles.fullWidth}>
                      <Text render={<span />} variant="caption">
                        Account
                      </Text>
                      <Text render={<span />} size="xs" weight="medium">
                        {normalizedEmail}
                      </Text>
                    </HStack>
                    <HStack gap="2" justify="between" style={styles.fullWidth}>
                      <Text render={<span />} variant="caption">
                        Method
                      </Text>
                      <Text render={<span />} size="xs" weight="medium">
                        {authMethodLabel}
                      </Text>
                    </HStack>
                    <HStack gap="2" justify="between" style={styles.fullWidth}>
                      <Text render={<span />} variant="caption">
                        Status
                      </Text>
                      <Badge variant="subtle" size="xs" palette={emeraldPalette}>
                        Verified session
                      </Badge>
                    </HStack>
                  </Card.Body>
                </Card.Root>

                <VStack gap="2.5" style={styles.fullWidth}>
                  <Button
                    type="button"
                    variant="solid"
                    size="lg"
                    palette={accentPalette}
                    style={styles.fullWidth}
                    onClick={() =>
                      queue.info(`Opening ${workspaceName}…`, {
                        description: `Loading projects for ${normalizedEmail}.`,
                      })
                    }
                  >
                    Open {workspaceName}
                    <ArrowRightIcon />
                  </Button>
                  <Button
                    type="button"
                    variant="ghost"
                    size="lg"
                    onClick={handleResetFlow}
                    style={styles.fullWidth}
                  >
                    Sign in with another account
                  </Button>
                </VStack>
              </>
            ) : null}
          </Card.Body>
        </Card.Root>

        {/* Quick-fill demo strip so reviewers can exercise each IdP + fallback */}
        <VStack
          render={<aside aria-label="Sample enterprise domains" />}
          align="center"
          gap="2"
          style={styles.demoStrip}
        >
          <Text variant="caption">Try a sample work email:</Text>
          <HStack gap="1.5" justify="center" wrap="wrap">
            {SAMPLE_ACCOUNTS.map((sample) => (
              <Button
                key={sample.email}
                type="button"
                variant="subtle"
                size="2xs"
                onClick={() => handleSelectSample(sample.email)}
              >
                {sample.label}
              </Button>
            ))}
          </HStack>
        </VStack>
      </VStack>

      <Toaster toaster={queue} />
    </VStack>
  );
}
```

Credit: Inspired by [Login SSO](https://astryx.atmeta.com/playground?template=login-sso) from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.)
