Google and GitHub, or email and password with Forgot password, remember me, loading and a wrong-password error.
$ pnpm dlx shadcn@latest add @dashral/sign-inWhen to use
- Sign in with a provider or email and password, with forgot password, loading and errors.
- Any app's login page.
When not to use
- Making an account: Sign up, split.
- Apps that only sign in through a company's single sign-on: one button says it; the email form would mislead.
Usage
Sign in with your own data: every prop has the sample as its default, so pass only what you have.
import { SignIn } from "@/components/dashral/blocks/sign-in"
<SignIn
providers={providers}
onProvider={(provider) => signIn(provider)}
onSubmit={async ({ email, password }) => {
await signIn("credentials", { email, password })
}}
forgotHref="/forgot-password"
signUpHref="/register"
/>API reference
SignIn
A sign-in card: providers such as Google and GitHub, or email and password with "Forgot password?" by the label, a remember-me box and a loading state. An error shows above the form. Every part comes from props; wire onSubmit to your auth (without it, try any email with the password "password").
| Prop | Type | Default |
|---|---|---|
title | React.ReactNode | "Welcome back" |
description | React.ReactNode | sample |
providers | { id: string; label: string; icon?: React.ReactNode }[]The buttons above the form; none hides them and the "or" under them. | sample |
onProvider | (id: string) => voidCalled with a provider's id when its button is pressed, e.g. to start its sign-in. | — |
onSubmit | (values: SignInValues) => Promise<void> | voidYour sign-in. Resolve to sign in (the card says so); throw an Error to show its message above the form. Without it, the card plays a sample: any email with the password "password". | — |
forgotHref | stringWhere "Forgot password?" and "Create an account" go; none hides them. | "#" |
signUpHref | string | "#" |
signUpPrompt | stringThe words before "Create an account". | "New to Acme?" |
done | { title: string; description?: string }What the card says once signed in. | sample |
type SignInValues
| Prop | Type | Default |
|---|---|---|
email | string | — |
password | string | — |
remember | boolean | — |