- Accordion
- Attachment
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Card
- Checkbox
- Code Block
- Collapsible
- Dialog
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Label
- Marker
- Message
- Number Flow
- Pagination
- Popover
- Progress
- Radio Group
- Select
- Slider
- Slot
- Sonner
- Spinner
- Switch
- Tooltip
- Separator
- Sheet
- Tabs
- Textarea
- Toggle
- Toggle Group
- Trace
Signup Form
Account creation layouts assembled from Frakment primitives.
"use client";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel,
} from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
export function SignupFormBasic({
className,
...props
}: React.ComponentProps<typeof Card>) {
return (
<Card className={cn("mx-auto w-full max-w-sm", className)} {...props}>
<CardHeader>
<CardTitle>Create an account</CardTitle>
<CardDescription>
Enter your information below to create your account
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={(event) => event.preventDefault()}>
<FieldGroup>
<Field>
<FieldLabel htmlFor="signup-basic-name">Full Name</FieldLabel>
<Input
autoComplete="name"
id="signup-basic-name"
placeholder="John Doe"
required
type="text"
/>
</Field>
<Field>
<FieldLabel htmlFor="signup-basic-email">Email</FieldLabel>
<Input
autoComplete="email"
id="signup-basic-email"
placeholder="m@example.com"
required
type="email"
/>
<FieldDescription>
We'll use this to contact you. We will not share your email
with anyone else.
</FieldDescription>
</Field>
<Field>
<FieldLabel htmlFor="signup-basic-password">Password</FieldLabel>
<Input
autoComplete="new-password"
id="signup-basic-password"
required
type="password"
/>
<FieldDescription>
Must be at least 8 characters long.
</FieldDescription>
</Field>
<Field>
<FieldLabel htmlFor="signup-basic-confirm-password">
Confirm Password
</FieldLabel>
<Input
autoComplete="new-password"
id="signup-basic-confirm-password"
required
type="password"
/>
<FieldDescription>Please confirm your password.</FieldDescription>
</Field>
<Field>
<Button type="submit">Create Account</Button>
<Button type="button" variant="outline">
Sign up with Google
</Button>
<FieldDescription className="px-6 text-center">
Already have an account? <a href="#">Sign in</a>
</FieldDescription>
</Field>
</FieldGroup>
</form>
</CardContent>
</Card>
);
}A signup form combines Frakment's button, card, field, and input primitives into account creation layouts.
The examples include a basic form, a two-column password layout, and a branded form with social sign-in actions.
These are copyable layouts, not a standalone registry item, and they do not implement authentication or application-specific validation.
Installation
$ bunx --bun frakment add button card field input$ npx frakment add button card field input$ pnpm dlx frakment add button card field input$ yarn dlx frakment add button card field input
The CLI also installs the label and separator registry dependencies required by field.
Follow the manual setup through the theme setup, then continue with the Signup Form files below.
Copy the primitives and the registry dependencies required by field:
"use client";
import type { VariantProps } from "class-variance-authority";
import * as React from "react";
import {
getTransition,
parseMotion,
useMotionGuard,
useReducedMotion,
} from "@/lib/motion";
import { buttonVariants, cn } from "@/lib/utils";
export interface ButtonBaseProps extends VariantProps<typeof buttonVariants> {
anchorRef?: React.Ref<HTMLAnchorElement>;
as?: React.ElementType;
children?: React.ReactNode;
className?: string;
download?: string | boolean;
href?: string;
motion?: string;
ref?: React.Ref<HTMLButtonElement | HTMLAnchorElement>;
rel?: string;
target?: React.HTMLAttributeAnchorTarget;
}
export type ButtonProps = ButtonBaseProps &
React.ButtonHTMLAttributes<HTMLButtonElement>;
function Button({
as,
className,
variant,
size,
href,
target,
rel,
download,
ref,
anchorRef,
motion,
style,
children,
...props
}: ButtonProps) {
const reduce = useReducedMotion();
const internalRef = React.useRef<HTMLElement | null>(null);
const motionEnabled = motion !== undefined && !reduce;
let resolvedStyle = style as React.CSSProperties | undefined;
if (reduce) {
resolvedStyle = { ...resolvedStyle, transition: "none" };
} else if (motion !== undefined) {
const transition = getTransition(parseMotion(motion));
if (transition) {
resolvedStyle = { ...resolvedStyle, transition };
}
}
const styleFingerprint = JSON.stringify(resolvedStyle ?? null);
const yielded = useMotionGuard(internalRef, motionEnabled, styleFingerprint);
if (yielded && !reduce) {
resolvedStyle = { ...resolvedStyle, transition: "none" };
}
const setRef = React.useCallback(
(el: HTMLElement | null) => {
internalRef.current = el;
if (href !== undefined && anchorRef) {
if (typeof anchorRef === "function") {
anchorRef(el as HTMLAnchorElement | null);
} else {
(
anchorRef as React.MutableRefObject<HTMLAnchorElement | null>
).current = el as HTMLAnchorElement | null;
}
}
if (typeof ref === "function") {
(ref as (el: HTMLElement | null) => void)(el);
} else if (ref && typeof ref === "object") {
(ref as React.MutableRefObject<HTMLElement | null>).current = el;
}
},
[href, ref, anchorRef]
);
const classes = cn(buttonVariants({ className, size, variant }));
const attrs = {
"data-inline": true,
"data-size": size,
"data-slot": "button",
"data-variant": variant,
} as const;
if (as !== undefined) {
const allProps: Record<string, unknown> = {
...attrs,
...props,
className: classes,
ref: setRef,
style: resolvedStyle,
};
if (href !== undefined) {
allProps.href = href;
}
if (download !== undefined) {
allProps.download = download;
}
if (rel !== undefined) {
allProps.rel = rel;
}
if (target !== undefined) {
allProps.target = target;
}
return React.createElement(as, allProps, children);
}
if (href !== undefined) {
const {
type: _t,
disabled: _d,
form: _f,
formAction: _fa,
formEncType: _fe,
formMethod: _fm,
formNoValidate: _fnv,
formTarget: _ft,
name: _n,
value: _v,
...anchorRest
} = props as React.ButtonHTMLAttributes<HTMLButtonElement>;
return (
<a
className={classes}
download={download}
href={href}
ref={setRef}
rel={rel}
style={resolvedStyle}
target={target}
{...attrs}
{...(anchorRest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}
>
{children}
</a>
);
}
return (
<button
className={classes}
ref={setRef}
style={resolvedStyle}
{...attrs}
{...(props as React.ButtonHTMLAttributes<HTMLButtonElement>)}
>
{children}
</button>
);
}
export { Button };import type * as React from "react";
import { cn } from "@/lib/utils";
function Card({
className,
size = "default",
...props
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
return (
<div
className={cn(
"group/card bg-card text-card-foreground ring-foreground/10 flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl py-(--card-spacing) text-sm ring-1 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
className
)}
data-size={size}
data-slot="card"
{...props}
/>
);
}
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
className
)}
data-slot="card-header"
{...props}
/>
);
}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
className
)}
data-slot="card-title"
{...props}
/>
);
}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn("text-muted-foreground text-sm", className)}
data-slot="card-description"
{...props}
/>
);
}
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className
)}
data-slot="card-action"
{...props}
/>
);
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn("px-(--card-spacing)", className)}
data-slot="card-content"
{...props}
/>
);
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"flex items-center rounded-b-xl p-(--card-spacing)",
className
)}
data-slot="card-footer"
{...props}
/>
);
}
export {
Card,
CardAction,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
};"use client";
import type { VariantProps } from "class-variance-authority";
import { cva } from "class-variance-authority";
import { useMemo } from "react";
import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
import { cn } from "@/lib/utils";
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
return (
<fieldset
className={cn(
"flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
className
)}
data-slot="field-set"
{...props}
/>
);
}
function FieldLegend({
className,
variant = "legend",
...props
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
return (
<legend
className={cn(
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
className
)}
data-slot="field-legend"
data-variant={variant}
{...props}
/>
);
}
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
className
)}
data-slot="field-group"
{...props}
/>
);
}
const fieldVariants = cva(
"group/field data-[invalid=true]:text-destructive flex w-full gap-2",
{
defaultVariants: {
orientation: "vertical",
},
variants: {
orientation: {
horizontal:
"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
responsive:
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
},
},
}
);
function Field({
className,
orientation = "vertical",
...props
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
return (
<div
className={cn(fieldVariants({ orientation }), className)}
data-orientation={orientation}
data-slot="field"
role="group"
{...props}
/>
);
}
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
className
)}
data-slot="field-content"
{...props}
/>
);
}
function FieldLabel({
className,
...props
}: React.ComponentProps<typeof Label>) {
return (
<Label
className={cn(
"group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-2.5",
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
className
)}
data-slot="field-label"
{...props}
/>
);
}
function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
className
)}
data-slot="field-label"
{...props}
/>
);
}
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<p
className={cn(
"text-muted-foreground text-left text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
"last:mt-0 nth-last-2:-mt-1",
"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
className
)}
data-slot="field-description"
{...props}
/>
);
}
function FieldSeparator({
children,
className,
...props
}: React.ComponentProps<"div"> & {
children?: React.ReactNode;
}) {
return (
<div
className={cn(
"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
className
)}
data-content={!!children}
data-slot="field-separator"
{...props}
>
<Separator className="absolute inset-0 top-1/2" />
{children && (
<span
className="bg-background text-muted-foreground relative mx-auto block w-fit px-2"
data-slot="field-separator-content"
>
{children}
</span>
)}
</div>
);
}
function FieldError({
className,
children,
errors,
...props
}: React.ComponentProps<"div"> & {
errors?: Array<{ message?: string } | undefined>;
}) {
const content = useMemo(() => {
if (children) {
return children;
}
if (!errors?.length) {
return null;
}
const uniqueErrors = [
...new Map(errors.map((error) => [error?.message, error])).values(),
];
if (uniqueErrors?.length === 1) {
return uniqueErrors[0]?.message;
}
return (
<ul className="ml-4 flex list-disc flex-col gap-1">
{uniqueErrors.map(
(error, index) =>
error?.message && <li key={index}>{error.message}</li>
)}
</ul>
);
}, [children, errors]);
if (!content) {
return null;
}
return (
<div
className={cn("text-destructive text-sm font-normal", className)}
data-slot="field-error"
role="alert"
{...props}
>
{content}
</div>
);
}
export {
Field,
FieldContent,
FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
FieldLegend,
FieldSeparator,
FieldSet,
FieldTitle,
};import { cn } from "@/lib/utils";
const Input = ({
className,
type,
...props
}: React.ComponentProps<"input">) => (
<input
className={cn(
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
className
)}
data-slot="input"
type={type}
{...props}
/>
);
export { Input };"use client";
import type * as React from "react";
import { cn } from "@/lib/utils";
function Label({
className,
onMouseDown,
...props
}: React.ComponentProps<"label">) {
return (
<label
className={cn(
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
className
)}
data-slot="label"
onMouseDown={(event) => {
onMouseDown?.(event);
if (!event.defaultPrevented && event.detail > 1) {
event.preventDefault();
}
}}
{...props}
/>
);
}
export { Label };"use client";
import type * as React from "react";
import { cn } from "@/lib/utils";
export interface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
decorative?: boolean;
orientation?: "horizontal" | "vertical";
}
function Separator({
className,
orientation = "horizontal",
decorative = true,
...props
}: SeparatorProps) {
return (
<div
aria-orientation={decorative ? undefined : orientation}
className={cn(
"bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
className
)}
data-orientation={orientation}
data-slot="separator"
role={decorative ? "none" : "separator"}
{...props}
/>
);
}
export { Separator };Copy the basic signup form layout into your project:
"use client";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel,
} from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
export function SignupFormBasic({
className,
...props
}: React.ComponentProps<typeof Card>) {
return (
<Card className={cn("mx-auto w-full max-w-sm", className)} {...props}>
<CardHeader>
<CardTitle>Create an account</CardTitle>
<CardDescription>
Enter your information below to create your account
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={(event) => event.preventDefault()}>
<FieldGroup>
<Field>
<FieldLabel htmlFor="signup-basic-name">Full Name</FieldLabel>
<Input
autoComplete="name"
id="signup-basic-name"
placeholder="John Doe"
required
type="text"
/>
</Field>
<Field>
<FieldLabel htmlFor="signup-basic-email">Email</FieldLabel>
<Input
autoComplete="email"
id="signup-basic-email"
placeholder="m@example.com"
required
type="email"
/>
<FieldDescription>
We'll use this to contact you. We will not share your email
with anyone else.
</FieldDescription>
</Field>
<Field>
<FieldLabel htmlFor="signup-basic-password">Password</FieldLabel>
<Input
autoComplete="new-password"
id="signup-basic-password"
required
type="password"
/>
<FieldDescription>
Must be at least 8 characters long.
</FieldDescription>
</Field>
<Field>
<FieldLabel htmlFor="signup-basic-confirm-password">
Confirm Password
</FieldLabel>
<Input
autoComplete="new-password"
id="signup-basic-confirm-password"
required
type="password"
/>
<FieldDescription>Please confirm your password.</FieldDescription>
</Field>
<Field>
<Button type="submit">Create Account</Button>
<Button type="button" variant="outline">
Sign up with Google
</Button>
<FieldDescription className="px-6 text-center">
Already have an account? <a href="#">Sign in</a>
</FieldDescription>
</Field>
</FieldGroup>
</form>
</CardContent>
</Card>
);
}Update the import paths to match your project setup.
Usage
Use the primitives to build the form and connect submission to your account creation flow.
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export function SignupForm() {
return (
<Card>
<CardHeader>
<CardTitle>Create an account</CardTitle>
</CardHeader>
<CardContent>
<form>
<FieldGroup>
<Field>
<FieldLabel htmlFor="name">Full Name</FieldLabel>
<Input id="name" type="text" autoComplete="name" required />
</Field>
<Field>
<FieldLabel htmlFor="email">Email</FieldLabel>
<Input id="email" type="email" autoComplete="email" required />
</Field>
<Field>
<FieldLabel htmlFor="password">Password</FieldLabel>
<Input
id="password"
type="password"
autoComplete="new-password"
required
/>
</Field>
<Field>
<Button type="submit">Create Account</Button>
</Field>
</FieldGroup>
</form>
</CardContent>
</Card>
);
}Anatomy
The basic layout groups account fields and the submit action inside a card.
Card
├── CardHeader
└── CardContent
└── form
└── FieldGroup
├── Field (name)
├── Field (email)
├── Field (password)
└── Field (submit action)The social layout adds a two-column password group, while the branded layout adds a brand mark, social actions, and terms text.
Examples
Social
This layout places name and email fields above a two-column password group.
By clicking continue, you agree to our Terms of Service and Privacy Policy.
"use client";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel,
} from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
export function SignupFormSocial({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
className={cn("mx-auto flex w-full max-w-sm flex-col gap-6", className)}
{...props}
>
<Card>
<CardHeader className="text-center">
<CardTitle className="text-xl">Create your account</CardTitle>
<CardDescription>
Enter your information below to create your account
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={(event) => event.preventDefault()}>
<FieldGroup>
<Field>
<FieldLabel htmlFor="signup-social-name">Full Name</FieldLabel>
<Input
autoComplete="name"
id="signup-social-name"
placeholder="John Doe"
required
type="text"
/>
</Field>
<Field>
<FieldLabel htmlFor="signup-social-email">Email</FieldLabel>
<Input
autoComplete="email"
id="signup-social-email"
placeholder="m@example.com"
required
type="email"
/>
</Field>
<div className="grid gap-4">
<div className="grid grid-cols-2 gap-4">
<Field>
<FieldLabel htmlFor="signup-social-password">
Password
</FieldLabel>
<Input
autoComplete="new-password"
id="signup-social-password"
required
type="password"
/>
</Field>
<Field>
<FieldLabel htmlFor="signup-social-confirm-password">
Confirm Password
</FieldLabel>
<Input
autoComplete="new-password"
id="signup-social-confirm-password"
required
type="password"
/>
</Field>
</div>
<FieldDescription>
Must be at least 8 characters long.
</FieldDescription>
</div>
<Field>
<Button type="submit">Create Account</Button>
<FieldDescription className="text-center">
Already have an account? <a href="#">Sign in</a>
</FieldDescription>
</Field>
</FieldGroup>
</form>
</CardContent>
</Card>
<FieldDescription className="px-6 text-center">
By clicking continue, you agree to our <a href="#">Terms of Service</a>{" "}
and <a href="#">Privacy Policy</a>.
</FieldDescription>
</div>
);
}Branded
This layout combines a brand mark, an email field, and Apple and Google signup actions.
By clicking continue, you agree to our Terms of Service and Privacy Policy.
"use client";
import { GalleryVerticalEnd } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel,
FieldSeparator,
} from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
function AppleMark() {
return (
<svg aria-hidden="true" className="size-4" viewBox="0 0 24 24">
<path
d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"
fill="currentColor"
/>
</svg>
);
}
function GoogleMark() {
return (
<svg aria-hidden="true" className="size-4" viewBox="0 0 24 24">
<path
d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"
fill="currentColor"
/>
</svg>
);
}
export function SignupFormBranded({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
className={cn("mx-auto flex w-full max-w-sm flex-col gap-6", className)}
{...props}
>
<form onSubmit={(event) => event.preventDefault()}>
<FieldGroup>
<div className="flex flex-col items-center gap-2 text-center">
<a
className="flex flex-col items-center gap-2 font-medium"
href="#"
>
<div className="flex size-8 items-center justify-center rounded-md">
<GalleryVerticalEnd aria-hidden="true" className="size-6" />
</div>
<span className="sr-only">Acme Inc.</span>
</a>
<h1 className="text-xl font-bold">Welcome to Acme Inc.</h1>
<FieldDescription>
Already have an account? <a href="#">Sign in</a>
</FieldDescription>
</div>
<Field>
<FieldLabel htmlFor="signup-branded-email">Email</FieldLabel>
<Input
autoComplete="email"
id="signup-branded-email"
placeholder="m@example.com"
required
type="email"
/>
</Field>
<Field>
<Button type="submit">Create Account</Button>
</Field>
<FieldSeparator>Or</FieldSeparator>
<Field className="grid gap-4 sm:grid-cols-2">
<Button type="button" variant="outline">
<AppleMark />
Continue with Apple
</Button>
<Button type="button" variant="outline">
<GoogleMark />
Continue with Google
</Button>
</Field>
</FieldGroup>
</form>
<FieldDescription className="px-6 text-center">
By clicking continue, you agree to our <a href="#">Terms of Service</a>{" "}
and <a href="#">Privacy Policy</a>.
</FieldDescription>
</div>
);
}The branded example uses GalleryVerticalEnd from lucide-react, which is installed during Frakment setup.
API
SignupFormBasic accepts and forwards React.ComponentProps<typeof Card>.
SignupFormSocial and SignupFormBranded accept and forward React.ComponentProps<"div">.
className is merged with the default layout classes in all three examples.
Accessibility
- Give every input a matching
FieldLabelandid, and use the appropriate autocomplete value for each field. - For invalid fields, set
data-invalidonField, setaria-invalidon the control, and renderFieldErrorfor the validation message. - Connect form submission and social sign-in buttons to real authentication handlers before using the layouts in an application.
Best Practices
- Use the examples as layout starting points. Add the validation and account creation behavior required by your application.
- Replace placeholder links. Sign-in, Terms of Service, and Privacy Policy links in the examples use
href="#". - Keep the primary action clear. Use one primary submit button for the form.