Skip to content
Blocks

Workspace Login

A focused enterprise sign-in screen with email-based SAML and social providers.

Open ↗

Make it yours.

Install the editable source and its dependencies into your React + Tailwind project.

Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/workspace-login.json

Use it

Scroll horizontally for long lines
"use client";
import {WorkspaceLogin} from '@/components/jez-ui/blocks/workspace-login';

export default function Example(){

return <><WorkspaceLogin/></>;
}

Props & types

Scroll horizontally for long lines
export type LoginPresentation = {
  className?: string;
  title?: React.ReactNode;
  description?: React.ReactNode;
  brand?: string;
};

export type LoginHandlers = {
  onSubmit?: (credentials: {
    email: string;
    password: string;
  }) => Promise<void> | void;
  onSSO?: (
    provider: "google" | "github" | "saml",
    email?: string,
  ) => Promise<void> | void;
};

LoginHandlers & LoginPresentation

Source

View 6 source files

registry/blocks/workspace-login.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "../ui/utils";
import {
  LoginFields,
  type LoginPresentation,
  type LoginHandlers,
} from "./login-fields";
export function WorkspaceLogin({
  title,
  description,
  brand,
  className,
  ...handlers
}: LoginHandlers & LoginPresentation) {
  return (
    <section
      className={cn(
        "relative grid min-h-[740px] place-items-center overflow-hidden rounded-xl bg-muted p-6",
        className,
      )}
    >
      <div
        aria-hidden
        className="absolute inset-0 opacity-30"
        style={{
          backgroundImage:
            "radial-gradient(var(--color-muted-foreground) 1px,transparent 1px)",
          backgroundSize: "24px 24px",
        }}
      />
      <div className="relative w-full max-w-md rounded-2xl border border-border bg-background p-7 shadow-[0_16px_64px_#0000000a] md:p-10">
        <div className="mb-8">
          <p className="mb-7 text-xs font-semibold tracking-[.25em]">
            {brand ?? "COMMON / WORKSPACE"}
          </p>
          <h1 className="font-display text-2xl tracking-tight">
            {title ?? <>Your team is in here.</>}
          </h1>
          <p className="mt-2 text-sm leading-relaxed text-muted-foreground">
            {description ?? (
              <>
                Use your company email to continue with your organisation’s
                identity provider.
              </>
            )}
          </p>
        </div>
        <LoginFields enterprise {...handlers} />
      </div>
      <p className="relative mt-5 text-center text-xs text-muted-foreground">
        Single sign-on for your whole organisation.
      </p>
    </section>
  );
}

registry/ui/utils.ts

Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
  return twMerge(clsx(values));
}

registry/blocks/login-fields.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Github, ArrowRight, KeyRound, Building2 } from "lucide-react";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { PasswordInput } from "../ui/password-input";
export type LoginPresentation = {
  className?: string;
  title?: React.ReactNode;
  description?: React.ReactNode;
  brand?: string;
};
export type LoginHandlers = {
  onSubmit?: (credentials: {
    email: string;
    password: string;
  }) => Promise<void> | void;
  onSSO?: (
    provider: "google" | "github" | "saml",
    email?: string,
  ) => Promise<void> | void;
};
export function LoginFields({
  onSubmit,
  onSSO,
  enterprise = false,
}: LoginHandlers & { enterprise?: boolean }) {
  const [pending, setPending] = React.useState<string | null>(null),
    [message, setMessage] = React.useState(""),
    [error, setError] = React.useState(false);
  async function run(key: string, action?: () => Promise<void> | void) {
    setPending(key);
    setMessage("");
    setError(false);
    try {
      if (action) {
        await action();
        setMessage("Sign-in request completed.");
      } else
        setMessage(
          "Demo only. Connect your authentication provider to sign in.",
        );
    } catch (e) {
      setError(true);
      setMessage(
        e instanceof Error ? e.message : "Sign-in failed. Please try again.",
      );
    } finally {
      setPending(null);
    }
  }
  return (
    <div className="grid gap-5">
      <div className="grid gap-2">
        <Button
          disabled={!!pending}
          loading={pending === "google"}
          variant="outline"
          className="w-full"
          onClick={() =>
            run("google", onSSO ? () => onSSO("google") : undefined)
          }
        >
          <svg aria-hidden="true" viewBox="0 0 24 24" className="size-4">
            <path
              fill="currentColor"
              d="M21.6 12.23c0-.71-.06-1.39-.18-2.05H12v3.88h5.38a4.6 4.6 0 0 1-2 3.02v2.51h3.24c1.9-1.75 2.98-4.33 2.98-7.36ZM12 22c2.7 0 4.96-.9 6.61-2.41l-3.23-2.51c-.9.6-2.05.96-3.38.96-2.6 0-4.8-1.76-5.58-4.12H3.08v2.59A10 10 0 0 0 12 22ZM6.42 13.92A6 6 0 0 1 6.1 12c0-.67.11-1.32.32-1.92V7.49H3.08A10 10 0 0 0 2 12c0 1.61.39 3.14 1.08 4.51l3.34-2.59ZM12 5.96c1.47 0 2.79.5 3.83 1.5l2.87-2.88A9.62 9.62 0 0 0 12 2a10 10 0 0 0-8.92 5.49l3.34 2.59A5.99 5.99 0 0 1 12 5.96Z"
            />
          </svg>
          Continue with Google
        </Button>
        <Button
          disabled={!!pending}
          loading={pending === "github"}
          variant="outline"
          className="w-full"
          onClick={() =>
            run("github", onSSO ? () => onSSO("github") : undefined)
          }
        >
          <Github size={16} />
          Continue with GitHub
        </Button>
      </div>
      <div className="flex items-center gap-4 text-[11px] text-muted-foreground">
        <span className="h-px flex-1 bg-border" />
        or continue with {enterprise ? "SSO" : "email"}
        <span className="h-px flex-1 bg-border" />
      </div>
      <form
        className="grid gap-4"
        onSubmit={(e) => {
          e.preventDefault();
          const data = new FormData(e.currentTarget),
            email = String(data.get("email")),
            password = String(data.get("password") ?? "");
          void run(
            "email",
            enterprise
              ? onSSO
                ? () => onSSO("saml", email)
                : undefined
              : onSubmit
                ? () => onSubmit({ email, password })
                : undefined,
          );
        }}
      >
        <label className="grid gap-2 text-xs font-medium">
          {enterprise ? "Work email" : "Email address"}
          <Input
            name="email"
            type="email"
            autoComplete="email"
            required
            placeholder={enterprise ? "you@company.com" : "you@example.com"}
          />
        </label>
        {!enterprise && (
          <label className="grid gap-2 text-xs font-medium">
            Password
            <PasswordInput
              name="password"
              autoComplete="current-password"
              required
              placeholder="Enter your password"
            />
          </label>
        )}
        <Button
          type="submit"
          disabled={!!pending}
          loading={pending === "email"}
          className="mt-1 w-full"
        >
          {enterprise ? (
            <>
              <Building2 size={16} />
              Continue with SSO
            </>
          ) : (
            <>
              Sign in
              <ArrowRight size={16} />
            </>
          )}
        </Button>
      </form>
      {message && (
        <p
          role={error ? "alert" : "status"}
          className={
            error
              ? "text-xs text-danger"
              : "text-xs leading-relaxed text-muted-foreground"
          }
        >
          {message}
        </p>
      )}
      <p className="flex items-center justify-center gap-2 text-[11px] text-muted-foreground">
        <KeyRound size={12} />
        Your workspace. Your secure way in.
      </p>
    </div>
  );
}

registry/ui/button.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Slot } from "radix-ui";
import { LoaderCircle } from "lucide-react";
import { cn } from "./utils";
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
  variant?: "primary" | "secondary" | "outline" | "ghost" | "danger";
  size?: "sm" | "md" | "lg";
  loading?: boolean;
  asChild?: boolean;
};
export function Button({
  variant = "primary",
  size = "md",
  loading,
  asChild,
  className,
  children,
  disabled,
  ...props
}: ButtonProps) {
  const Comp = asChild ? Slot.Root : "button";
  return (
    <Comp
      type={asChild ? undefined : "button"}
      disabled={asChild ? undefined : disabled || loading}
      aria-disabled={disabled || loading || undefined}
      aria-busy={loading || undefined}
      className={cn(
        "relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-transparent text-sm font-medium leading-none transition-[background-color,border-color,box-shadow,transform] duration-150 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-[.98] disabled:pointer-events-none disabled:opacity-45 aria-disabled:pointer-events-none [&_svg]:shrink-0",
        {
          "bg-primary text-primary-foreground shadow-[inset_0_1px_0_#ffffff26,0_1px_2px_#00000012] hover:bg-primary/90":
            variant === "primary",
          "border-border/60 bg-muted text-foreground hover:bg-muted/70":
            variant === "secondary",
          "border-border bg-background text-foreground shadow-sm hover:bg-muted/60":
            variant === "outline",
          "text-muted-foreground hover:bg-muted hover:text-foreground":
            variant === "ghost",
          "bg-danger text-danger-foreground hover:bg-danger/90":
            variant === "danger",
        },
        {
          "h-8 px-3 text-xs": size === "sm",
          "h-10 px-4": size === "md",
          "h-12 px-6": size === "lg",
        },
        className,
      )}
      {...props}
    >
      {asChild ? (
        children
      ) : (
        <>
          <span
            className={cn(
              "inline-flex min-w-0 flex-1 items-center justify-center gap-2",
              loading && "invisible",
            )}
          >
            {children}
          </span>
          {loading && (
            <LoaderCircle
              aria-hidden="true"
              className="absolute size-4 animate-spin motion-reduce:animate-none"
            />
          )}
        </>
      )}
    </Comp>
  );
}

registry/ui/input.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
export function Input({ className, ...props }: React.ComponentProps<"input">) {
  return (
    <input
      className={cn(
        "block h-10 w-full min-w-0 rounded-lg border border-border bg-background px-3 text-sm leading-normal shadow-[0_1px_2px_#00000004] transition-[border-color,box-shadow] placeholder:text-muted-foreground/75 hover:border-foreground/25 focus:border-primary focus:outline-none focus:ring-3 focus:ring-primary/10 aria-invalid:border-danger aria-invalid:ring-danger/10 disabled:cursor-not-allowed disabled:bg-muted/50 disabled:opacity-50",
        className,
      )}
      {...props}
    />
  );
}

registry/ui/password-input.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Eye, EyeOff, LockKeyhole } from "lucide-react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { Input } from "./input";
import { cn } from "./utils";
export function PasswordInput({
  className,
  ...props
}: Omit<React.ComponentProps<typeof Input>, "type">) {
  const [visible, setVisible] = React.useState(false);
  const reduce = useReducedMotion();
  return (
    <div className={cn("group relative w-full", className)}>
      <LockKeyhole
        size={15}
        className="pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 text-muted-foreground transition-colors group-focus-within:text-primary"
      />
      <Input
        aria-label="Password"
        autoComplete="current-password"
        {...props}
        type={visible ? "text" : "password"}
        className="px-10"
      />
      <button
        type="button"
        disabled={props.disabled}
        aria-label={visible ? "Hide password" : "Show password"}
        aria-pressed={visible}
        onMouseDown={(e) => e.preventDefault()}
        onClick={() => setVisible((v) => !v)}
        className="absolute right-1 top-1 grid size-8 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"
      >
        <AnimatePresence mode="wait" initial={false}>
          <motion.span
            key={String(visible)}
            initial={{
              opacity: 0,
              rotate: reduce ? 0 : -35,
              scale: reduce ? 1 : 0.7,
            }}
            animate={{ opacity: 1, rotate: 0, scale: 1 }}
            exit={{
              opacity: 0,
              rotate: reduce ? 0 : 35,
              scale: reduce ? 1 : 0.7,
            }}
            transition={{ duration: reduce ? 0 : 0.12 }}
          >
            {visible ? <EyeOff size={16} /> : <Eye size={16} />}
          </motion.span>
        </AnimatePresence>
      </button>
    </div>
  );
}

Dependencies

clsx@2.1.1 · tailwind-merge@3.5.0 · lucide-react@0.577.0 · radix-ui@1.6.7 · motion@13.2.0

Accessibility & behaviour

Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.

Read the accessibility and performance guide →