# AuthCard

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

Status: beta. Category: Blocks.

```ts
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

| Prop | Type | Default | Description |
|---|---|---|---|
| `title` (required) | `ReactNode` |  |  |
| `children` | `ReactNode` |  | Replaces the built-in form with your own fields. |
| `description` | `ReactNode` |  |  |
| `dividerLabel` | `ReactNode` | `or` | Label of the divider between social buttons and the form. |
| `footer` | `ReactNode` |  | Bottom line, e.g. "Don't have an account? Sign up". |
| `headingLevel` | `HeadingLevel` | `1` |  |
| `mode` | `"sign-in" \| "sign-up"` | `sign-in` | `sign-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. |
| `passwordHint` | `ReactNode` |  | Shown beside the password label, e.g. a "Forgot password?" link. |
| `social` | `ReactNode` |  | Social sign-in buttons, shown above the form with a divider. |
| `submitLabel` | `ReactNode` |  |  |

## Example: Sign in

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

```tsx
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

```tsx
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
