AuthCard

Sign-in or sign-up card with a ready email and password form, social buttons and a footer link.

Status: beta. Category: Blocks.

import { AuthCard } from '@glyphui/blocks'

Exports: AuthCard.

Notes

  • The built-in form validates email and password before calling onSubmit; throw to show a form-level error.
  • Pass children to replace the built-in form with your own fields, for example a Form from @glyphui/ui/form.

AuthCard props

PropTypeDefaultDescription
title (required)ReactNode
childrenReactNodeReplaces the built-in form with your own fields.
descriptionReactNode
dividerLabelReactNodeorLabel of the divider between social buttons and the form.
footerReactNodeBottom line, e.g. "Don't have an account? Sign up".
headingLevelHeadingLevel1
mode"sign-in" | "sign-up"sign-insign-in uses current-password autocomplete; sign-up uses new-password and a minimum length.
onSubmit((credentials: AuthCredentials) => void | Promise<void>)Built-in email + password form. Throw to show the error's message above the form.
passwordHintReactNodeShown beside the password label, e.g. a "Forgot password?" link.
socialReactNodeSocial sign-in buttons, shown above the form with a divider.
submitLabelReactNode

Example: Sign in

Use any email and the password “wrong” to see the error state.

import { AuthCard } from '@glyphui/blocks'
import { Link } from '@glyphui/ui'

const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))

export default function Example() {
  return (
    <AuthCard
      title="Welcome back"
      description="Sign in to your Ledgerline workspace."
      headingLevel={2}
      passwordHint={<Link href="#reset">Forgot password?</Link>}
      onSubmit={async ({ password }) => {
        await wait(700)
        if (password === 'wrong') throw new Error('That email and password don’t match.')
      }}
      footer={
        <>
          New here? <Link href="#signup">Create an account</Link>
        </>
      }
    />
  )
}

Example: Sign up with social buttons

import { AuthCard } from '@glyphui/blocks'
import { Button, Link } from '@glyphui/ui'
import { Github } from 'lucide-react'

export default function Example() {
  return (
    <AuthCard
      mode="sign-up"
      title="Create your account"
      description="Free for 14 days. No credit card required."
      headingLevel={2}
      social={
        <Button variant="outline" fullWidth leftIcon={<Github />}>
          Continue with GitHub
        </Button>
      }
      dividerLabel="or with email"
      onSubmit={() => new Promise((resolve) => setTimeout(resolve, 700))}
      footer={
        <>
          Already have an account? <Link href="#signin">Sign in</Link>
        </>
      }
    />
  )
}

Live page: https://glyphui.xyz/components/auth-card