Login Form Example

A complete example of a login form with email and password fields.

Schema

{
  "type": "login",
  "title": "Welcome back",
  "description": "Sign in to your account to continue",
  "fields": [
    {
      "name": "email",
      "type": "email",
      "label": "Email Address",
      "placeholder": "you@example.com",
      "required": true,
      "validation": {
        "pattern": "^[^\s@]+@[^\s@]+\.[^\s@]+$"
      }
    },
    {
      "name": "password",
      "type": "password",
      "label": "Password",
      "placeholder": "Enter your password",
      "required": true,
      "validation": {
        "minLength": 8
      }
    },
    {
      "name": "rememberMe",
      "type": "checkbox",
      "label": "Remember me",
      "description": "Keep me signed in on this device"
    }
  ],
  "submit": "Sign In",
  "footer": {
    "text": "Don't have an account?",
    "link": {
      "text": "Create one now",
      "href": "/signup"
    }
  }
}

Usage

import { AuthForm } from 'declarative-auth-forms'
import schema from './login-schema.json'

export default function LoginPage() {
  return (
    <AuthForm 
      schema={schema}
      onSubmit={async (data) => {
        // Handle login
        console.log(data)
      }}
    />
  )
}