X Enterprises
nuxt-x-auth

Form

Low-level schema-driven auth form — renders fields, OAuth provider buttons, and a submit button from declarative props; used internally by all auth page components.

Form

The XAuthForm component is the low-level form renderer used internally by all auth page components. It takes a declarative list of fields, an optional Zod schema, and optional OAuth providers, and renders the matching inputs (email/text, password with visibility toggle, OTP pin input) inside a Nuxt UI UForm. Use it when building a custom auth page that doesn't fit the pre-built components.

Components

<XAuthForm />

<script setup>
import { z } from 'zod'

const schema = z.object({ email: z.string().email() })
const fields = [
  { name: 'email', label: 'Email', type: 'email', placeholder: 'you@example.com', required: true },
]
</script>

<template>
  <XAuthForm
    title="Sign in"
    icon="i-lucide-lock"
    :fields="fields"
    :schema="schema"
    :submit="{ label: 'Continue' }"
    @submit="onSubmit"
  />
</template>

Props

PropTypeDefaultDescription
iconstringIcon shown above the title (e.g. 'i-lucide-lock')
titlestringHeading displayed above the form
descriptionstringSubheading below the title (overridden by the description slot)
fieldsArray[]Field definitions — { name, label, type, placeholder, required, length? }. type is 'email' | 'text' | 'password' | 'otp'; length sets the OTP pin count (default 6)
providersArrayOAuth buttons rendered above the form — { label, icon, onClick }
separatorstringLabel for the separator between provider buttons and the form (e.g. 'or')
submit{ label: string }{ label: 'Continue' }Submit button label
schemaobjectZod schema passed to UForm for validation
loadingbooleanfalseDisables inputs and shows a loading state on the submit button

Events

EventPayloadDescription
submitFormSubmitEventEmitted on valid submission. OTP field values are normalized from arrays to joined strings.

Slots

SlotDescription
descriptionCustom content below the title (overrides the description prop)
leadingContent between the provider buttons and the form (e.g. an OTP email indicator)
password-hintHint content for password fields (e.g. a "Forgot password?" link)
footerCentered content below the form

AI Context

component: XAuthForm
package: "@xenterprises/nuxt-x-auth"
use-when: Building a custom auth form from declarative field/provider props with Zod validation
Copyright © 2026