Editorial Login
A working editorial login with illustrative data and frontend interactions.
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/editorial-login.jsonUse it
Scroll horizontally for long lines
"use client";
import { EditorialLogin } from "@/components/jez-ui/blocks/editorial-login";
export default function Example() {
return (
<>
<EditorialLogin />
</>
);
}
Compose your own
These styled parts are included in the same install. Use children to build your layout; add className only when you want an override.
Scroll horizontally for long lines
import { EditorialLogin, EditorialLoginHeader, EditorialLoginContent, EditorialLoginTitle } from "@/components/jez-ui/blocks/editorial-login";Props & types
Scroll horizontally for long lines
export type EditorialLoginOptions = LoginHandlers &
LoginPresentation & {
imageSrc?: string;
imageAlt?: string;
} & {
form?: React.ReactNode;
formProps?: React.ComponentProps<typeof LoginFields>;
};
export type EditorialLoginProps = Omit<
React.ComponentProps<"section">,
keyof EditorialLoginOptions
> &
EditorialLoginOptions;
EditorialLoginPropsSource
View 7 source files
registry/blocks/editorial-login.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "../ui/utils";
import {
LoginFields,
type LoginHandlers,
type LoginPresentation,
} from "./login-fields";
export type EditorialLoginOptions = LoginHandlers &
LoginPresentation & {
imageSrc?: string;
imageAlt?: string;
} & {
form?: React.ReactNode;
formProps?: React.ComponentProps<typeof LoginFields>;
};
export type EditorialLoginProps = Omit<
React.ComponentProps<"section">,
keyof EditorialLoginOptions
> &
EditorialLoginOptions;
export function EditorialLogin({
className,
brand = "Margin",
title = "A good place to return to.",
description = "Sign in to your reading room.",
imageSrc = "/assets/editorial-slow.svg",
imageAlt = "Editorial artwork about slow creative practice",
onSubmit,
onSSO,
form,
formProps,
children,
...rootProps
}: EditorialLoginProps) {
return (
<section
{...rootProps}
className={cn(
"overflow-hidden rounded-xl border border-border bg-background",
className,
)}
>
{children !== undefined ? (
children
) : (
<>
<EditorialLoginHeader>
<span className="font-serif text-3xl">{brand}</span>
<span className="self-center text-xs text-muted-foreground">
For the endlessly curious.
</span>
</EditorialLoginHeader>
<EditorialLoginContent>
<div className="flex items-center px-7 py-12 md:px-12">
<div className="mx-auto w-full max-w-sm">
<EditorialLoginTitle>{title}</EditorialLoginTitle>
<p className="mb-8 mt-4 text-sm text-muted-foreground">
{description}
</p>
{form !== undefined ? (
form
) : (
<LoginFields
onSubmit={onSubmit}
onSSO={onSSO}
{...formProps}
/>
)}
</div>
</div>
<figure className="flex flex-col bg-muted p-6">
<img
src={imageSrc}
alt={imageAlt}
className="min-h-64 w-full flex-1 rounded-lg object-cover"
/>
<figcaption className="flex justify-between gap-4 pt-5 text-xs">
<span>The art of paying attention.</span>
<span>Studio notes</span>
</figcaption>
</figure>
</EditorialLoginContent>
</>
)}
</section>
);
}
export function EditorialLoginHeader({
className,
...props
}: React.ComponentProps<"header">) {
return (
<header
data-slot="editorial-login-header"
className={cn(
"flex flex-wrap justify-between gap-3 border-b border-border px-7 py-5",
className,
)}
{...props}
/>
);
}
export function EditorialLoginContent({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="editorial-login-content"
className={cn("grid md:grid-cols-2", className)}
{...props}
/>
);
}
export function EditorialLoginTitle({
className,
...props
}: React.ComponentProps<"h1">) {
return (
<h1
data-slot="editorial-login-title"
className={cn("font-serif text-4xl leading-tight", className)}
{...props}
/>
);
}
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 { cn } from "../ui/utils";
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,
children,
className,
...rootProps
}: Omit<React.ComponentProps<"div">, keyof LoginHandlers> &
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 {...rootProps} className={cn("grid gap-5", className)}>
{children !== undefined ? (
children
) : (
<>
<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.ComponentProps<"button"> & {
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,
inputClassName,
...props
}: Omit<React.ComponentProps<typeof Input>, "type"> & {
inputClassName?: string;
}) {
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={cn("px-10", inputClassName)}
/>
<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>
);
}
assets/editorial-slow.svg
Scroll horizontally for long lines
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 900"><rect width="1600" height="900" fill="#d8dbcc"/><rect x="160" y="120" width="1280" height="660" rx="16" fill="#f4efe1" stroke="#32483c" stroke-width="3"/><path d="M160 200H1440" stroke="#32483c" stroke-width="3"/><g fill="#a76245"><circle cx="205" cy="160" r="9"/><circle cx="239" cy="160" r="9"/><circle cx="273" cy="160" r="9"/></g><path d="M250 685V470a230 230 0 01460 0v215z" fill="#32483c"/><path d="M860 685V420a230 230 0 01460 0v265z" fill="#c68c66"/><g fill="none" stroke="#f4efe1" stroke-width="3"><path d="M280 655C440 280 550 290 680 630S980 930 1160 330"/><path d="M290 680C450 305 560 315 690 655S990 955 1170 355"/><path d="M300 705C460 330 570 340 700 680S1000 980 1180 380"/></g><circle cx="1090" cy="435" r="96" fill="#f4efe1"/><path d="M1035 381v118l34-34 25 48 24-13-27-45h53z" fill="#32483c"/><path d="M350 732H1250" stroke="#32483c" stroke-width="2"/><circle cx="790" cy="160" r="8" fill="#32483c"/></svg>
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 →