---
title: "Two-Column Form · UI SDK — StyleX Blocks"
description: "Responsive two-column vendor onboarding and payout profile form with sectioned Fieldset cards, paired field grids, live inline validation, dirty-state tracking, settlement cadence controls, Reset and Save footer actions, and Toaster confirmation feedback."
url: "https://stylexblocks.com/block/ui-sdk/form-two-column/"
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/"
---

# Two-Column Form block

Responsive two-column vendor onboarding and payout profile form with sectioned Fieldset cards, paired field grids, live inline validation, dirty-state tracking, settlement cadence controls, Reset and Save footer actions, and Toaster confirmation feedback.

- Behavior engine: UI SDK
- Category: [Forms](https://stylexblocks.com/blocks/forms.md)
- Built with: [Alert](https://stylexblocks.com/components/ui-sdk/alert.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), [Checkbox](https://stylexblocks.com/components/ui-sdk/checkbox.md), [Field](https://stylexblocks.com/components/ui-sdk/field.md), [Fieldset](https://stylexblocks.com/components/ui-sdk/fieldset.md), [Grid](https://stylexblocks.com/components/ui-sdk/grid.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), [Segment Group](https://stylexblocks.com/components/ui-sdk/segment-group.md), [Select](https://stylexblocks.com/components/ui-sdk/select.md), [Separator](https://stylexblocks.com/components/ui-sdk/separator.md), [Stack](https://stylexblocks.com/components/ui-sdk/stack.md), [Status](https://stylexblocks.com/components/ui-sdk/status.md), [Switch](https://stylexblocks.com/components/ui-sdk/switch.md), [Text](https://stylexblocks.com/components/ui-sdk/text.md), [Textarea](https://stylexblocks.com/components/ui-sdk/textarea.md), [Toast](https://stylexblocks.com/components/ui-sdk/toast.md)
- HTML page: https://stylexblocks.com/block/ui-sdk/form-two-column/

## 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 form-two-column
```

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

## Usage

```tsx
import { FormTwoColumn } from "#components/blocks/ui-sdk/form-two-column.tsx";

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

## Source

`components/blocks/ui-sdk/form-two-column.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { useCallback, useMemo, useState } from "react";
import { Alert } from "#components/ui/ui-sdk/alert.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 { Checkbox } from "#components/ui/ui-sdk/checkbox.tsx";
import { Field } from "#components/ui/ui-sdk/field.tsx";
import { Fieldset } from "#components/ui/ui-sdk/fieldset.tsx";
import { Grid } from "#components/ui/ui-sdk/grid.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 { SegmentGroup } from "#components/ui/ui-sdk/segment-group.tsx";
import { Select } from "#components/ui/ui-sdk/select.tsx";
import { Separator } from "#components/ui/ui-sdk/separator.tsx";
import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";
import { Status } from "#components/ui/ui-sdk/status.tsx";
import { Switch } from "#components/ui/ui-sdk/switch.tsx";
import { Text } from "#components/ui/ui-sdk/text.tsx";
import { Textarea } from "#components/ui/ui-sdk/textarea.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 {
  accentPalette,
  amberPalette,
  emeraldPalette,
  redPalette,
} from "@stylexblocks/ui/themes/palettes.ts";
import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";
import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";
import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";

// ── Types ─────────────────────────────────────────────────────────────────────

export type PayoutCadence = "weekly" | "biweekly" | "monthly" | "net30";

export interface FormSelectOption {
  value: string;
  label: string;
}

export interface VendorSupportChannel {
  label: string;
  email: string;
}

export interface VendorPayoutValues {
  legalName: string;
  tradeName: string;
  taxId: string;
  entityType: string;
  country: string;
  contactEmail: string;
  currency: string;
  payoutCadence: PayoutCadence;
  routingOrIban: string;
  swiftBic: string;
  accountReference: string;
  remittanceNotes: string;
  autoRemittance: boolean;
  complianceConfirmed: boolean;
}

export interface VendorPayoutSavePayload {
  values: VendorPayoutValues;
  updatedFields: Array<keyof VendorPayoutValues>;
  savedAt: string;
}

export interface FormTwoColumnProps extends StyleOverrideProps {
  /** Eyebrow badge rendered above the page title. */
  eyebrow?: string;
  /** Primary display heading for the onboarding form. */
  title?: string;
  /** Supporting subtitle beneath the heading. */
  description?: string;
  /** Optional overrides merged onto the default vendor payout profile values. */
  initialValues?: Partial<VendorPayoutValues>;
  /** Legal entity classification options. */
  entityTypeOptions?: FormSelectOption[];
  /** Country and tax jurisdiction options. */
  countryOptions?: FormSelectOption[];
  /** Supported disbursement currency options. */
  currencyOptions?: FormSelectOption[];
  /** Operations support contacts shown in the bottom strip. */
  supportChannels?: VendorSupportChannel[];
  /** Called with the validated payout profile when saved. */
  onSaveProfile?: (payload: VendorPayoutSavePayload) => void;
  /** Called when unsaved edits are discarded via Reset. */
  onResetProfile?: () => void;
}

type ValidatedFieldKey =
  | "legalName"
  | "taxId"
  | "entityType"
  | "country"
  | "contactEmail"
  | "currency"
  | "routingOrIban"
  | "swiftBic"
  | "remittanceNotes"
  | "complianceConfirmed";

type FormErrors = Partial<Record<ValidatedFieldKey, string>>;

// ── Container Queries ─────────────────────────────────────────────────────────

const STACK_SECTIONS = "@container form-two-column (max-width: 820px)";
const STACK_FIELDS = "@container form-two-column (max-width: 540px)";

// ── Demo Data & Constants ─────────────────────────────────────────────────────

const DEFAULT_ENTITY_TYPE_OPTIONS: FormSelectOption[] = [
  { value: "llc", label: "Limited Liability Company (LLC)" },
  { value: "corporation", label: "Corporation (C-Corp / S-Corp)" },
  { value: "partnership", label: "General or Limited Partnership" },
  { value: "sole-proprietor", label: "Sole Proprietorship" },
  { value: "non-profit", label: "Non-Profit Organization" },
  { value: "foreign-entity", label: "Non-US Foreign Entity" },
];

const DEFAULT_COUNTRY_OPTIONS: FormSelectOption[] = [
  { value: "US", label: "United States" },
  { value: "GB", label: "United Kingdom" },
  { value: "DE", label: "Germany" },
  { value: "NL", label: "Netherlands" },
  { value: "CA", label: "Canada" },
  { value: "SG", label: "Singapore" },
  { value: "AU", label: "Australia" },
  { value: "JP", label: "Japan" },
];

const DEFAULT_CURRENCY_OPTIONS: FormSelectOption[] = [
  { value: "USD", label: "USD — US Dollar (ACH / Fedwire)" },
  { value: "EUR", label: "EUR — Euro (SEPA Credit)" },
  { value: "GBP", label: "GBP — British Pound (Faster Payments)" },
  { value: "CAD", label: "CAD — Canadian Dollar (EFT)" },
  { value: "SGD", label: "SGD — Singapore Dollar (FAST)" },
  { value: "AUD", label: "AUD — Australian Dollar (NPP)" },
];

const DEFAULT_SUPPORT_CHANNELS: VendorSupportChannel[] = [
  { label: "Accounts payable", email: "ap-ops@meridianledger.example" },
  { label: "Tax & W-9 compliance", email: "tax-compliance@meridianledger.example" },
  { label: "Treasury & wire desk", email: "treasury@meridianledger.example" },
];

const CADENCE_OPTIONS: Array<{ value: PayoutCadence; label: string; cutoff: string }> = [
  {
    value: "weekly",
    label: "Weekly",
    cutoff: "Batched every Friday · invoice approval cutoff Thu 17:00 UTC.",
  },
  {
    value: "biweekly",
    label: "Bi-weekly",
    cutoff: "Disbursed on the 1st and 15th · cutoff 24 hours prior.",
  },
  {
    value: "monthly",
    label: "Monthly",
    cutoff: "Consolidated on the last business day of each calendar month.",
  },
  {
    value: "net30",
    label: "Net-30",
    cutoff: "Settled automatically 30 calendar days after invoice verification.",
  },
];

const CURRENCY_RAIL_HINTS: Record<string, { placeholder: string; hint: string; rail: string }> = {
  USD: {
    placeholder: "021000021",
    hint: "9-digit ABA routing number for domestic ACH or Fedwire.",
    rail: "ACH / Fedwire",
  },
  EUR: {
    placeholder: "DE89 3704 0044 0532 0130 00",
    hint: "Standard SEPA IBAN (15–34 alphanumeric characters).",
    rail: "SEPA Credit",
  },
  GBP: {
    placeholder: "GB29 NWBK 6016 1331 9268 19",
    hint: "UK IBAN or 6-digit sort code and 8-digit account number.",
    rail: "Faster Payments",
  },
  CAD: {
    placeholder: "003-21451-8901234",
    hint: "Institution, transit, and account number for Canadian EFT.",
    rail: "Canadian EFT",
  },
  SGD: {
    placeholder: "7171-048-901234",
    hint: "MAS bank code and account number for FAST settlement.",
    rail: "FAST Transfer",
  },
  AUD: {
    placeholder: "062-000 10482910",
    hint: "6-digit BSB code and account number for NPP transfers.",
    rail: "NPP / BECS",
  },
};

const DEFAULT_VALUES: VendorPayoutValues = {
  legalName: "Alder & Pine Logistics LLC",
  tradeName: "Alder Freight",
  taxId: "US-84-3910482",
  entityType: "llc",
  country: "US",
  contactEmail: "ap@alderfreight.example",
  currency: "USD",
  payoutCadence: "biweekly",
  routingOrIban: "021000021",
  swiftBic: "CHASUS33XXX",
  accountReference: "Operating Treasury ••4819",
  remittanceNotes:
    "Include PO number and invoice batch ID in wire memo for automated ledger reconciliation.",
  autoRemittance: true,
  complianceConfirmed: true,
};

const VALUE_KEYS = Object.keys(DEFAULT_VALUES) as Array<keyof VendorPayoutValues>;
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const TAX_ID_PATTERN = /^[A-Z0-9][A-Z0-9\-\s]{4,22}[A-Z0-9]$/i;
const SWIFT_PATTERN = /^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$/i;
const REMITTANCE_MAX_LENGTH = 240;

function formatSavedTime(date: Date): string {
  return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
}

function validateValues(values: VendorPayoutValues): FormErrors {
  const errors: FormErrors = {};
  const legalName = values.legalName.trim();
  const taxId = values.taxId.trim();
  const contactEmail = values.contactEmail.trim();
  const routingCompact = values.routingOrIban.replace(/[\s-]/g, "");
  const swiftCompact = values.swiftBic.trim();

  if (!legalName) {
    errors.legalName = "Enter the registered legal entity name.";
  } else if (legalName.length < 2) {
    errors.legalName = "Legal name must be at least 2 characters.";
  }

  if (!taxId) {
    errors.taxId = "Enter a valid EIN, SSN, or VAT registration ID.";
  } else if (!TAX_ID_PATTERN.test(taxId)) {
    errors.taxId = "Use 6–24 letters, digits, or hyphens (e.g. US-84-3910482).";
  }

  if (!values.entityType) {
    errors.entityType = "Select the vendor legal entity classification.";
  }

  if (!values.country) {
    errors.country = "Select the tax residency country.";
  }

  if (!contactEmail) {
    errors.contactEmail = "Enter a primary accounts payable email address.";
  } else if (!EMAIL_PATTERN.test(contactEmail)) {
    errors.contactEmail = "Enter a valid email address (e.g. ap@company.com).";
  }

  if (!values.currency) {
    errors.currency = "Choose a settlement currency.";
  }

  if (!routingCompact) {
    errors.routingOrIban = "Enter a bank routing number or IBAN.";
  } else if (routingCompact.length < 8) {
    errors.routingOrIban = "Routing number or IBAN must contain at least 8 characters.";
  } else if (!/^[A-Z0-9]+$/i.test(routingCompact)) {
    errors.routingOrIban = "Use letters, digits, spaces, or hyphens only.";
  }

  if (swiftCompact && !SWIFT_PATTERN.test(swiftCompact)) {
    errors.swiftBic = "SWIFT / BIC must be 8 or 11 alphanumeric characters.";
  }

  if (values.remittanceNotes.length > REMITTANCE_MAX_LENGTH) {
    errors.remittanceNotes = `Keep remittance notes within ${REMITTANCE_MAX_LENGTH} characters.`;
  }

  if (!values.complianceConfirmed) {
    errors.complianceConfirmed =
      "Confirm tax accuracy and payout authorization before saving changes.";
  }

  return errors;
}

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

function ShieldCheckIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.65"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M10 2.5 4 5v4.5c0 3.7 2.55 6.2 6 7 3.45-.8 6-3.3 6-7V5l-6-2.5Z" />
      <path d="m7.5 10.25 1.75 1.75 3.5-3.75" />
    </Icon>
  );
}

function BankBuildingIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.65"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M3 7.5 10 3.5l7 4" />
      <path d="M3 16.5h14" />
      <path d="M5.25 10v4.25M8.4 10v4.25M11.6 10v4.25M14.75 10v4.25" />
    </Icon>
  );
}

function AlertCircleIcon() {
  return (
    <Icon
      size="inherit"
      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="8" />
      <path d="M10 6.5v4" />
      <circle cx="10" cy="13.5" r="0.6" fill="currentColor" stroke="none" />
    </Icon>
  );
}

function RotateCcwIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.65"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M4.25 8.25a6 6 0 1 1 1.4 5.75" />
      <path d="M4.25 4.25v4h4" />
    </Icon>
  );
}

function CheckIcon() {
  return (
    <Icon
      size="sm"
      viewBox="0 0 20 20"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.85"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="m4.75 10.5 3.5 3.5 7-7.75" />
    </Icon>
  );
}

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

const styles = stylex.create({
  root: {
    backgroundColor: semanticColors.bg,
    color: semanticColors.fg,
    containerName: "form-two-column",
    containerType: "inline-size",
    fontFamily: fonts.body,
    minHeight: "100%",
    overflowY: "auto",
    width: "100%",
  },
  container: {
    marginInline: "auto",
    maxWidth: "68rem",
    paddingBlock: {
      default: spacing._10,
      [STACK_FIELDS]: spacing._6,
    },
    paddingInline: {
      default: spacing._8,
      [STACK_SECTIONS]: spacing._6,
      [STACK_FIELDS]: spacing._4,
    },
    width: "100%",
  },
  headerTitleGroup: {
    maxWidth: "44rem",
  },
  headingReset: {
    marginBlock: 0,
  },
  pageDescription: {
    lineHeight: lineHeights.md,
  },
  leadingSm: {
    lineHeight: lineHeights.sm,
  },
  fullWidth: {
    width: "100%",
  },
  sectionRow: {
    columnGap: {
      default: spacing._10,
      [STACK_SECTIONS]: spacing._6,
    },
    rowGap: {
      default: spacing._6,
      [STACK_SECTIONS]: spacing._4,
    },
    gridTemplateColumns: {
      default: "minmax(15rem, 19rem) minmax(0, 1fr)",
      [STACK_SECTIONS]: "minmax(0, 1fr)",
    },
    width: "100%",
  },
  sectionAside: {
    paddingTop: {
      default: spacing._1,
      [STACK_SECTIONS]: 0,
    },
  },
  asideCallout: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    color: semanticColors.fgMuted,
    paddingBlock: spacing._3,
    paddingInline: spacing._3_5,
  },
  asideCalloutIcon: {
    color: semanticColors.fgSubtle,
    display: "inline-flex",
    flexShrink: 0,
    marginTop: "0.125rem",
  },
  cardGap5: {
    gap: spacing._5,
  },
  fieldGridTwo: {
    gridTemplateColumns: {
      default: "repeat(2, minmax(0, 1fr))",
      [STACK_FIELDS]: "minmax(0, 1fr)",
    },
    width: "100%",
  },
  labelRow: {
    gap: spacing._2,
    justifyContent: "space-between",
    width: "100%",
  },
  monoInput: {
    fontFamily: fonts.mono,
  },
  requiredStar: {
    lineHeight: 1,
  },
  segmentWrap: {
    maxWidth: "100%",
    overflowX: "auto",
  },
  textarea: {
    minHeight: "5.25rem",
    resize: "vertical",
  },
  switchPanel: {
    alignItems: "center",
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    display: "flex",
    gap: spacing._4,
    justifyContent: "space-between",
    paddingBlock: spacing._3_5,
    paddingInline: spacing._4,
    width: "100%",
  },
  checkboxRoot: {
    alignItems: "flex-start",
    display: "flex",
    width: "100%",
  },
  checkboxControlOffset: {
    marginTop: "0.125rem",
  },
  actionBar: {
    backgroundColor: semanticColors.bgPanel,
    borderColor: semanticColors.border,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    paddingBlock: spacing._3_5,
    paddingInline: spacing._4,
    width: "100%",
  },
  actionButtons: {
    marginInlineStart: "auto",
  },
  supportSection: {
    paddingTop: spacing._1,
    width: "100%",
  },
  supportGrid: {
    columnGap: spacing._6,
    rowGap: spacing._4,
    gridTemplateColumns: {
      default: "repeat(3, minmax(0, 1fr))",
      [STACK_FIELDS]: "minmax(0, 1fr)",
    },
    width: "100%",
  },
  supportColumn: {
    alignItems: {
      default: "center",
      [STACK_FIELDS]: "flex-start",
    },
    textAlign: {
      default: "center",
      [STACK_FIELDS]: "start",
    },
  },
});

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

/**
 * FormTwoColumn — structured two-column vendor onboarding and payout profile
 * form pairing left-column section guidance with right-column `Fieldset` cards,
 * responsive two-column field grids, live inline validation, dirty-state
 * tracking, Reset / Save footer actions, and `Toaster` confirmation feedback.
 */
export function FormTwoColumn({
  eyebrow = "Vendor Onboarding · AP-4029",
  title = "Vendor Onboarding & Payout Profile",
  description = "Configure legal entity details, tax identifiers, and automated settlement instructions for Meridian Ledger disbursements.",
  initialValues,
  entityTypeOptions = DEFAULT_ENTITY_TYPE_OPTIONS,
  countryOptions = DEFAULT_COUNTRY_OPTIONS,
  currencyOptions = DEFAULT_CURRENCY_OPTIONS,
  supportChannels = DEFAULT_SUPPORT_CHANNELS,
  onSaveProfile,
  onResetProfile,
  palette,
  style,
}: FormTwoColumnProps) {
  const queue = useMemo(() => Toast.createToaster(), []);

  const startingValues = useMemo<VendorPayoutValues>(
    () => ({ ...DEFAULT_VALUES, ...initialValues }),
    [initialValues],
  );

  const [savedValues, setSavedValues] = useState<VendorPayoutValues>(startingValues);
  const [draft, setDraft] = useState<VendorPayoutValues>(startingValues);
  const [touched, setTouched] = useState<Partial<Record<ValidatedFieldKey, boolean>>>({});
  const [attemptedSubmit, setAttemptedSubmit] = useState(false);
  const [lastSavedAt, setLastSavedAt] = useState<string | null>(null);

  const allErrors = useMemo(() => validateValues(draft), [draft]);

  const visibleErrors = useMemo<FormErrors>(() => {
    const out: FormErrors = {};
    for (const [key, message] of Object.entries(allErrors) as Array<
      [ValidatedFieldKey, string | undefined]
    >) {
      if (message && (attemptedSubmit || touched[key])) {
        out[key] = message;
      }
    }
    return out;
  }, [allErrors, attemptedSubmit, touched]);

  const visibleErrorCount = Object.keys(visibleErrors).length;

  const modifiedFields = useMemo(
    () => VALUE_KEYS.filter((key) => draft[key] !== savedValues[key]),
    [draft, savedValues],
  );
  const isDirty = modifiedFields.length > 0;

  const updateField = useCallback(
    <K extends keyof VendorPayoutValues>(field: K, value: VendorPayoutValues[K]) => {
      setDraft((prev) => ({ ...prev, [field]: value }));
    },
    [],
  );

  const markTouched = useCallback((field: ValidatedFieldKey) => {
    setTouched((prev) => (prev[field] ? prev : { ...prev, [field]: true }));
  }, []);

  const activeRail = CURRENCY_RAIL_HINTS[draft.currency] ?? CURRENCY_RAIL_HINTS.USD!;
  const activeCadence =
    CADENCE_OPTIONS.find((opt) => opt.value === draft.payoutCadence) ?? CADENCE_OPTIONS[1]!;

  const handleReset = useCallback(() => {
    setDraft(savedValues);
    setTouched({});
    setAttemptedSubmit(false);
    onResetProfile?.();
    queue.info("Changes discarded", {
      description: "Restored the last saved vendor payout profile.",
    });
  }, [onResetProfile, queue, savedValues]);

  const handleSubmit = useCallback(
    (event: React.FormEvent<HTMLFormElement>) => {
      event.preventDefault();
      setAttemptedSubmit(true);

      const currentErrors = validateValues(draft);
      const errorEntries = Object.values(currentErrors).filter(Boolean);
      if (errorEntries.length > 0) {
        queue.error("Fix validation issues before saving", {
          description:
            errorEntries.length === 1
              ? "1 field needs attention before the payout profile can be saved."
              : `${errorEntries.length} fields need attention before the payout profile can be saved.`,
        });
        return;
      }

      const normalized: VendorPayoutValues = {
        ...draft,
        legalName: draft.legalName.trim(),
        tradeName: draft.tradeName.trim(),
        taxId: draft.taxId.trim().toUpperCase(),
        contactEmail: draft.contactEmail.trim(),
        routingOrIban: draft.routingOrIban.trim().toUpperCase(),
        swiftBic: draft.swiftBic.trim().toUpperCase(),
        accountReference: draft.accountReference.trim(),
        remittanceNotes: draft.remittanceNotes.trim(),
      };

      const changed = VALUE_KEYS.filter((key) => normalized[key] !== savedValues[key]);
      const timestamp = formatSavedTime(new Date());

      setSavedValues(normalized);
      setDraft(normalized);
      setTouched({});
      setAttemptedSubmit(false);
      setLastSavedAt(timestamp);

      onSaveProfile?.({
        values: normalized,
        updatedFields: changed,
        savedAt: timestamp,
      });

      queue.success("Payout profile saved", {
        description:
          changed.length === 0
            ? `${normalized.legalName} verified for ${normalized.currency} settlements (${timestamp}).`
            : `Updated ${changed.length} ${changed.length === 1 ? "field" : "fields"} for ${normalized.legalName} (${normalized.currency} · ${activeCadence.label}).`,
      });
    },
    [activeCadence.label, draft, onSaveProfile, queue, savedValues],
  );

  const handleSupportLinkClick = useCallback(
    (channel: VendorSupportChannel) => (event: React.MouseEvent<HTMLAnchorElement>) => {
      event.preventDefault();
      queue.info(`${channel.label} desk`, {
        description: `Reach ${channel.email} with vendor reference AP-4029 for priority routing.`,
      });
    },
    [queue],
  );

  const headerStatus =
    visibleErrorCount > 0 ? (
      <Status.Root size="sm" palette={redPalette}>
        <Status.Indicator />
        <Text render={<span />} size="xs" tone="muted" tabular="true">
          {visibleErrorCount === 1
            ? "1 validation issue"
            : `${visibleErrorCount} validation issues`}
        </Text>
      </Status.Root>
    ) : isDirty ? (
      <Status.Root size="sm" palette={amberPalette}>
        <Status.Indicator />
        <Text render={<span />} size="xs" tone="muted" tabular="true">
          {modifiedFields.length === 1
            ? "1 unsaved change"
            : `${modifiedFields.length} unsaved changes`}
        </Text>
      </Status.Root>
    ) : (
      <Status.Root size="sm" palette={emeraldPalette}>
        <Status.Indicator />
        <Text render={<span />} size="xs" tone="muted" tabular="true">
          {lastSavedAt ? `Saved at ${lastSavedAt}` : "Profile synced"}
        </Text>
      </Status.Root>
    );

  return (
    <VStack gap="0" palette={palette} style={[styles.root, style]}>
      <VStack render={<main />} gap="8" style={styles.container}>
        {/* Page Header */}
        <VStack render={<header />} gap="3">
          <HStack wrap="wrap" justify="between" gap="3">
            {eyebrow ? (
              <Badge variant="subtle" size="sm" palette={accentPalette}>
                {eyebrow}
              </Badge>
            ) : null}
            {headerStatus}
          </HStack>

          <VStack gap="1.5" style={styles.headerTitleGroup}>
            <Heading render={<h1 />} size="3xl" style={styles.headingReset}>
              {title}
            </Heading>
            <Text variant="muted" size="sm" style={styles.pageDescription}>
              {description}
            </Text>
          </VStack>
        </VStack>

        <Separator decorative />

        {/* Two-Column Sectioned Form */}
        <VStack
          render={<form noValidate onSubmit={handleSubmit} />}
          gap="8"
          style={styles.fullWidth}
        >
          {/* Section 1: Organization Details */}
          <Grid
            render={<section aria-labelledby="vendor-org-heading" />}
            align="start"
            style={styles.sectionRow}
          >
            <VStack gap="3" style={styles.sectionAside}>
              <HStack gap="2">
                <Badge variant="outline" size="xs" palette={accentPalette}>
                  01
                </Badge>
                <Heading id="vendor-org-heading" size="lg" style={styles.headingReset}>
                  Organization details
                </Heading>
              </HStack>
              <Text variant="muted" size="sm">
                Legal identity, tax classification, and primary billing contact printed on 1099,
                VAT statements, and remittance records.
              </Text>
              <HStack align="start" gap="2.5" style={styles.asideCallout}>
                <span {...stylex.props(styles.asideCalloutIcon)}>
                  <ShieldCheckIcon />
                </span>
                <VStack gap="1">
                  <Text render={<span />} size="xs" weight="medium">
                    Automated TIN verification
                  </Text>
                  <Text variant="muted" size="xs" style={styles.leadingSm}>
                    Tax identifiers are matched against IRS / VIES registries before the first
                    scheduled disbursement.
                  </Text>
                </VStack>
              </HStack>
            </VStack>

            <Card.Root variant="outline" size="lg">
              <Card.Body style={styles.cardGap5}>
                <Fieldset.Root size="md">
                  <Fieldset.Legend>Legal entity &amp; tax identity</Fieldset.Legend>
                  <Fieldset.Content style={styles.cardGap5}>
                    <Grid columns="2" gap="4" style={styles.fieldGridTwo}>
                      <Field.Root required invalid={Boolean(visibleErrors.legalName)}>
                        <Field.Label>
                          Legal name
                          <Field.RequiredIndicator />
                        </Field.Label>
                        <Input
                          autoComplete="organization"
                          placeholder="Alder & Pine Logistics LLC"
                          value={draft.legalName}
                          onValueChange={(next) => {
                            updateField("legalName", next);
                            markTouched("legalName");
                          }}
                          onBlur={() => markTouched("legalName")}
                        />
                        {visibleErrors.legalName ? (
                          <Field.Error match>{visibleErrors.legalName}</Field.Error>
                        ) : null}
                      </Field.Root>

                      <Field.Root>
                        <Field.Label style={styles.labelRow}>
                          <span>Trade name / DBA</span>
                          <Text render={<span />} size="xs" tone="subtle" weight="normal">
                            Optional
                          </Text>
                        </Field.Label>
                        <Input
                          placeholder="Alder Freight"
                          value={draft.tradeName}
                          onValueChange={(next) => updateField("tradeName", next)}
                        />
                      </Field.Root>
                    </Grid>

                    <Grid columns="2" gap="4" style={styles.fieldGridTwo}>
                      <Field.Root required invalid={Boolean(visibleErrors.taxId)}>
                        <Field.Label>
                          Tax ID / VAT
                          <Field.RequiredIndicator />
                        </Field.Label>
                        <Input
                          placeholder="US-84-3910482"
                          value={draft.taxId}
                          onValueChange={(next) => {
                            updateField("taxId", next);
                            markTouched("taxId");
                          }}
                          onBlur={() => markTouched("taxId")}
                          style={styles.monoInput}
                        />
                        {visibleErrors.taxId ? (
                          <Field.Error match>{visibleErrors.taxId}</Field.Error>
                        ) : (
                          <Field.Description>EIN, SSN, or EU/UK VAT registration.</Field.Description>
                        )}
                      </Field.Root>

                      <Field.Root required invalid={Boolean(visibleErrors.entityType)}>
                        <Field.Label>
                          Entity type
                          <Field.RequiredIndicator />
                        </Field.Label>
                        <Select.Root
                          items={entityTypeOptions}
                          value={draft.entityType || null}
                          onValueChange={(next) => {
                            updateField("entityType", next ?? "");
                            markTouched("entityType");
                          }}
                          style={styles.fullWidth}
                        >
                          <Select.Control>
                            <Select.Trigger onBlur={() => markTouched("entityType")}>
                              <Select.Value placeholder="Select entity type" />
                            </Select.Trigger>
                            <Select.IndicatorGroup>
                              <Select.Icon />
                            </Select.IndicatorGroup>
                          </Select.Control>
                          <Select.Content>
                            {entityTypeOptions.map((option) => (
                              <Select.Item key={option.value} value={option.value}>
                                <Select.ItemText>{option.label}</Select.ItemText>
                                <Select.ItemIndicator />
                              </Select.Item>
                            ))}
                          </Select.Content>
                        </Select.Root>
                        {visibleErrors.entityType ? (
                          <Field.Error match>{visibleErrors.entityType}</Field.Error>
                        ) : null}
                      </Field.Root>
                    </Grid>

                    <Grid columns="2" gap="4" style={styles.fieldGridTwo}>
                      <Field.Root required invalid={Boolean(visibleErrors.country)}>
                        <Field.Label>
                          Country / Jurisdiction
                          <Field.RequiredIndicator />
                        </Field.Label>
                        <Select.Root
                          items={countryOptions}
                          value={draft.country || null}
                          onValueChange={(next) => {
                            updateField("country", next ?? "");
                            markTouched("country");
                          }}
                          style={styles.fullWidth}
                        >
                          <Select.Control>
                            <Select.Trigger onBlur={() => markTouched("country")}>
                              <Select.Value placeholder="Select country" />
                            </Select.Trigger>
                            <Select.IndicatorGroup>
                              <Select.Icon />
                            </Select.IndicatorGroup>
                          </Select.Control>
                          <Select.Content>
                            {countryOptions.map((option) => (
                              <Select.Item key={option.value} value={option.value}>
                                <Select.ItemText>{option.label}</Select.ItemText>
                                <Select.ItemIndicator />
                              </Select.Item>
                            ))}
                          </Select.Content>
                        </Select.Root>
                        {visibleErrors.country ? (
                          <Field.Error match>{visibleErrors.country}</Field.Error>
                        ) : null}
                      </Field.Root>

                      <Field.Root required invalid={Boolean(visibleErrors.contactEmail)}>
                        <Field.Label>
                          Primary contact email
                          <Field.RequiredIndicator />
                        </Field.Label>
                        <Input
                          type="email"
                          autoComplete="email"
                          placeholder="ap@alderfreight.example"
                          value={draft.contactEmail}
                          onValueChange={(next) => {
                            updateField("contactEmail", next);
                            markTouched("contactEmail");
                          }}
                          onBlur={() => markTouched("contactEmail")}
                        />
                        {visibleErrors.contactEmail ? (
                          <Field.Error match>{visibleErrors.contactEmail}</Field.Error>
                        ) : null}
                      </Field.Root>
                    </Grid>
                  </Fieldset.Content>
                </Fieldset.Root>
              </Card.Body>
            </Card.Root>
          </Grid>

          <Separator decorative />

          {/* Section 2: Settlement & Compliance */}
          <Grid
            render={<section aria-labelledby="vendor-settlement-heading" />}
            align="start"
            style={styles.sectionRow}
          >
            <VStack gap="3" style={styles.sectionAside}>
              <HStack gap="2">
                <Badge variant="outline" size="xs" palette={accentPalette}>
                  02
                </Badge>
                <Heading id="vendor-settlement-heading" size="lg" style={styles.headingReset}>
                  Settlement &amp; compliance
                </Heading>
              </HStack>
              <Text variant="muted" size="sm">
                Define disbursement currency, payout cadence, and receiving bank coordinates.
                Updating routing details triggers a micro-deposit check.
              </Text>

              <HStack align="start" gap="2.5" style={styles.asideCallout}>
                <span {...stylex.props(styles.asideCalloutIcon)}>
                  <BankBuildingIcon />
                </span>
                <VStack gap="1">
                  <Text render={<span />} size="xs" weight="medium">
                    Active settlement rail
                  </Text>
                  <HStack wrap="wrap" gap="1.5">
                    <Badge variant="subtle" size="xs" palette={accentPalette}>
                      {draft.currency || "USD"}
                    </Badge>
                    <Badge variant="surface" size="xs">
                      {activeRail.rail}
                    </Badge>
                    <Badge variant="surface" size="xs">
                      {activeCadence.label}
                    </Badge>
                  </HStack>
                  <Text variant="muted" size="xs" style={styles.leadingSm}>
                    {activeCadence.cutoff}
                  </Text>
                </VStack>
              </HStack>
            </VStack>

            <Card.Root variant="outline" size="lg">
              <Card.Body style={styles.cardGap5}>
                <Fieldset.Root size="md">
                  <Fieldset.Legend>Disbursement rails &amp; authorization</Fieldset.Legend>
                  <Fieldset.Content style={styles.cardGap5}>
                    <Grid columns="2" gap="4" style={styles.fieldGridTwo}>
                      <Field.Root required invalid={Boolean(visibleErrors.currency)}>
                        <Field.Label>
                          Settlement currency
                          <Field.RequiredIndicator />
                        </Field.Label>
                        <Select.Root
                          items={currencyOptions}
                          value={draft.currency || null}
                          onValueChange={(next) => {
                            updateField("currency", next ?? "");
                            markTouched("currency");
                          }}
                          style={styles.fullWidth}
                        >
                          <Select.Control>
                            <Select.Trigger onBlur={() => markTouched("currency")}>
                              <Select.Value placeholder="Select currency" />
                            </Select.Trigger>
                            <Select.IndicatorGroup>
                              <Select.Icon />
                            </Select.IndicatorGroup>
                          </Select.Control>
                          <Select.Content>
                            {currencyOptions.map((option) => (
                              <Select.Item key={option.value} value={option.value}>
                                <Select.ItemText>{option.label}</Select.ItemText>
                                <Select.ItemIndicator />
                              </Select.Item>
                            ))}
                          </Select.Content>
                        </Select.Root>
                        {visibleErrors.currency ? (
                          <Field.Error match>{visibleErrors.currency}</Field.Error>
                        ) : null}
                      </Field.Root>

                      <Field.Root required invalid={Boolean(visibleErrors.routingOrIban)}>
                        <Field.Label>
                          Routing number / IBAN
                          <Field.RequiredIndicator />
                        </Field.Label>
                        <Input
                          placeholder={activeRail.placeholder}
                          value={draft.routingOrIban}
                          onValueChange={(next) => {
                            updateField("routingOrIban", next);
                            markTouched("routingOrIban");
                          }}
                          onBlur={() => markTouched("routingOrIban")}
                          style={styles.monoInput}
                        />
                        {visibleErrors.routingOrIban ? (
                          <Field.Error match>{visibleErrors.routingOrIban}</Field.Error>
                        ) : (
                          <Field.Description>{activeRail.hint}</Field.Description>
                        )}
                      </Field.Root>
                    </Grid>

                    <VStack gap="2" style={styles.fullWidth}>
                      <HStack render={<span id="vendor-payout-cadence-label" />} gap="1">
                        <Text render={<span />} variant="label" size="sm">
                          Payout cadence
                        </Text>
                        <Text
                          render={<span />}
                          size="sm"
                          tone="error"
                          style={styles.requiredStar}
                          aria-hidden="true"
                        >
                          *
                        </Text>
                      </HStack>
                      <div {...stylex.props(styles.segmentWrap)}>
                        <SegmentGroup.Root
                          size="sm"
                          value={draft.payoutCadence}
                          onValueChange={(next) =>
                            updateField("payoutCadence", next as PayoutCadence)
                          }
                          aria-labelledby="vendor-payout-cadence-label"
                        >
                          {CADENCE_OPTIONS.map((option) => (
                            <SegmentGroup.Item key={option.value} value={option.value}>
                              {option.label}
                            </SegmentGroup.Item>
                          ))}
                        </SegmentGroup.Root>
                      </div>
                      <Text variant="muted" size="xs" style={styles.leadingSm}>
                        {activeCadence.cutoff}
                      </Text>
                    </VStack>

                    <Grid columns="2" gap="4" style={styles.fieldGridTwo}>
                      <Field.Root invalid={Boolean(visibleErrors.swiftBic)}>
                        <Field.Label style={styles.labelRow}>
                          <span>SWIFT / BIC</span>
                          <Text render={<span />} size="xs" tone="subtle" weight="normal">
                            Optional
                          </Text>
                        </Field.Label>
                        <Input
                          placeholder="CHASUS33XXX"
                          value={draft.swiftBic}
                          onValueChange={(next) => {
                            updateField("swiftBic", next);
                            markTouched("swiftBic");
                          }}
                          onBlur={() => markTouched("swiftBic")}
                          style={styles.monoInput}
                        />
                        {visibleErrors.swiftBic ? (
                          <Field.Error match>{visibleErrors.swiftBic}</Field.Error>
                        ) : (
                          <Field.Description>Required only for cross-border wires.</Field.Description>
                        )}
                      </Field.Root>

                      <Field.Root>
                        <Field.Label style={styles.labelRow}>
                          <span>Account reference</span>
                          <Text render={<span />} size="xs" tone="subtle" weight="normal">
                            Optional
                          </Text>
                        </Field.Label>
                        <Input
                          placeholder="Operating Treasury ••4819"
                          value={draft.accountReference}
                          onValueChange={(next) => updateField("accountReference", next)}
                        />
                        <Field.Description>Internal nickname shown on payout logs.</Field.Description>
                      </Field.Root>
                    </Grid>

                    <Field.Root invalid={Boolean(visibleErrors.remittanceNotes)}>
                      <Field.Label style={styles.labelRow}>
                        <span>Remittance notes</span>
                        <Text
                          render={<span />}
                          size="xs"
                          tone={
                            draft.remittanceNotes.length > REMITTANCE_MAX_LENGTH
                              ? "error"
                              : "subtle"
                          }
                          weight={
                            draft.remittanceNotes.length > REMITTANCE_MAX_LENGTH
                              ? "medium"
                              : "normal"
                          }
                          tabular="true"
                        >
                          {draft.remittanceNotes.length} / {REMITTANCE_MAX_LENGTH}
                        </Text>
                      </Field.Label>
                      <Textarea
                        rows={3}
                        placeholder="Include PO references, cost center codes, or reconciliation instructions…"
                        value={draft.remittanceNotes}
                        onValueChange={(next) => {
                          updateField("remittanceNotes", next);
                          markTouched("remittanceNotes");
                        }}
                        onBlur={() => markTouched("remittanceNotes")}
                        style={styles.textarea}
                      />
                      {visibleErrors.remittanceNotes ? (
                        <Field.Error match>{visibleErrors.remittanceNotes}</Field.Error>
                      ) : (
                        <Field.Description>
                          Appended to wire memos and automated ACH addenda records.
                        </Field.Description>
                      )}
                    </Field.Root>

                    <Switch.Root size="md" palette={accentPalette} style={styles.switchPanel}>
                      <VStack render={<span />} gap="0.5">
                        <Text render={<span />} size="sm" weight="medium">
                          Email PDF remittance advice
                        </Text>
                        <Text
                          render={<span />}
                          variant="muted"
                          size="xs"
                          style={styles.leadingSm}
                        >
                          Automatically deliver itemized invoice statements to{" "}
                          {draft.contactEmail.trim() || "the primary contact"} on each payout.
                        </Text>
                      </VStack>
                      <Switch.Control
                        checked={draft.autoRemittance}
                        onCheckedChange={(checked) => updateField("autoRemittance", checked)}
                      />
                    </Switch.Root>

                    <Field.Root required invalid={Boolean(visibleErrors.complianceConfirmed)}>
                      <Checkbox.Root size="md" palette={accentPalette} style={styles.checkboxRoot}>
                        <Checkbox.Control
                          checked={draft.complianceConfirmed}
                          onCheckedChange={(next) => {
                            updateField("complianceConfirmed", next === true);
                            markTouched("complianceConfirmed");
                          }}
                          style={styles.checkboxControlOffset}
                        />
                        <Checkbox.Label>
                          <VStack render={<span />} gap="0.5">
                            <Text render={<span />} size="sm" weight="medium">
                              Confirm tax accuracy &amp; payout authorization
                            </Text>
                            <Text
                              render={<span />}
                              variant="muted"
                              size="xs"
                              weight="normal"
                              style={styles.leadingSm}
                            >
                              I certify that the legal entity and tax ID above are accurate under
                              W-9 / W-8BEN-E and authorize Meridian Ledger to initiate settlements
                              to this bank account.
                            </Text>
                          </VStack>
                        </Checkbox.Label>
                      </Checkbox.Root>
                      {visibleErrors.complianceConfirmed ? (
                        <Field.Error match>{visibleErrors.complianceConfirmed}</Field.Error>
                      ) : null}
                    </Field.Root>
                  </Fieldset.Content>
                </Fieldset.Root>
              </Card.Body>
            </Card.Root>
          </Grid>

          {/* Footer Action Bar */}
          <VStack gap="4" style={styles.fullWidth}>
            {attemptedSubmit && visibleErrorCount > 0 ? (
              <Alert.Root status="error" variant="subtle" size="sm" palette={redPalette}>
                <Alert.Indicator>
                  <AlertCircleIcon />
                </Alert.Indicator>
                <Alert.Content>
                  <Alert.Title>
                    {visibleErrorCount === 1
                      ? "1 required field needs attention before saving."
                      : `${visibleErrorCount} fields need attention before saving.`}
                  </Alert.Title>
                </Alert.Content>
              </Alert.Root>
            ) : null}

            <HStack wrap="wrap" justify="between" gap="4" style={styles.actionBar}>
              {isDirty ? (
                <Status.Root size="sm" palette={amberPalette}>
                  <Status.Indicator />
                  <Text render={<span />} size="xs" tone="muted" tabular="true">
                    {modifiedFields.length === 1
                      ? "1 unsaved change — reset or save to apply."
                      : `${modifiedFields.length} unsaved changes — reset or save to apply.`}
                  </Text>
                </Status.Root>
              ) : (
                <Status.Root size="sm" palette={emeraldPalette}>
                  <Status.Indicator />
                  <Text render={<span />} size="xs" tone="muted" tabular="true">
                    {lastSavedAt
                      ? `All payout details saved at ${lastSavedAt}.`
                      : "All payout details match the active disbursement profile."}
                  </Text>
                </Status.Root>
              )}

              <HStack wrap="wrap" gap="2.5" style={styles.actionButtons}>
                <Button
                  type="button"
                  variant="outline"
                  size="md"
                  disabled={!isDirty && !attemptedSubmit}
                  onClick={handleReset}
                >
                  <RotateCcwIcon />
                  Reset
                </Button>
                <Button type="submit" variant="solid" size="md" palette={accentPalette}>
                  <CheckIcon />
                  Save payout profile
                </Button>
              </HStack>
            </HStack>
          </VStack>
        </VStack>

        {/* Bottom Operations Contact Strip */}
        <VStack render={<footer />} gap="5" style={styles.supportSection}>
          <Separator decorative />
          <Grid columns="3" style={styles.supportGrid}>
            {supportChannels.map((channel) => (
              <VStack key={channel.label} gap="1" style={styles.supportColumn}>
                <Text render={<span />} variant="caption">
                  {channel.label}
                </Text>
                <Link
                  href={`mailto:${channel.email}`}
                  variant="underline"
                  palette={accentPalette}
                  onClick={handleSupportLinkClick(channel)}
                >
                  {channel.email}
                </Link>
              </VStack>
            ))}
          </Grid>
        </VStack>
      </VStack>

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

Credit: Inspired by [Two-column Form](https://astryx.atmeta.com/playground?template=form-two-column) from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.)
