# Sign in block

Email and password with a show-password button, sign-in with Google or GitHub, and links to reset a password or create an account.

A whole page section built from Halo components. Start from it, then change the words, data and handlers to fit the product. Keep its structure: one primary button, tokens for spacing and type, Field components in forms.

Add it to a project: `npx halo-ds add sign-in` (saves src/blocks/SignIn.tsx). Preview: https://halodesignsystem.dev/components/blocks/sign-in

```tsx
import { Button, Checkbox, Divider, Form, InputField, LinkButton, PasswordInput, SocialButton, Text } from '@halo-ds/react';
import type { FormValues } from '@halo-ds/react';
import { Hexagon } from '@phosphor-icons/react';

// Headings are plain h1, styled with Halo's type tokens. Text is for body copy.
const title = {
  margin: 0,
  font: 'var(--halo-font-weight-semibold) var(--halo-font-size-2xl)/var(--halo-line-height-2xl) var(--halo-font-family-heading)',
};

// Your logo goes here
const logo = {
  display: 'grid',
  placeItems: 'center',
  width: 40,
  height: 40,
  borderRadius: 'var(--halo-radius-4)',
  boxShadow: 'inset 0 0 0 1px var(--halo-border-secondary)',
  color: 'var(--halo-icon-primary)',
  fontSize: 24,
};

export default function SignIn() {
  const signIn = () => {
    // Send the email and password to your sign-in endpoint
  };

  // Form checks the required fields itself and shows each message under its field
  const validate = (values: FormValues) => ({
    email: values.email && !/^\S+@\S+\.\S+$/.test(String(values.email)) ? 'Enter an email like johndoe@example.com.' : undefined,
  });

  return (
    <main style={{ display: 'grid', justifyItems: 'center', padding: 'var(--halo-spacing-12) var(--halo-spacing-7)' }}>
      <div style={{ display: 'grid', gap: 'var(--halo-spacing-8)', width: '100%', maxWidth: 400 }}>
        <header style={{ display: 'grid', gap: 'var(--halo-spacing-5)' }}>
          <span style={logo} aria-hidden="true">
            <Hexagon />
          </span>
          <div style={{ display: 'grid', gap: 'var(--halo-spacing-2)' }}>
            <h1 style={title}>Sign in</h1>
            <Text color="secondary">Welcome back. Sign in to pick up where you left off.</Text>
          </div>
        </header>

        <div style={{ display: 'grid', gap: 'var(--halo-spacing-4)' }}>
          <SocialButton provider="google" variant="outline" fullWidth />
          <SocialButton provider="github" variant="outline" fullWidth />
        </div>

        <Divider label="or" />

        <Form onSubmit={signIn} validate={validate} style={{ gap: 'var(--halo-spacing-6)' }}>
          <InputField label="Email" name="email" type="email" autoComplete="email" placeholder="johndoe@example.com" required />
          <PasswordInput label="Password" name="password" required />
          <div style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: 'var(--halo-spacing-4)' }}>
            <Checkbox size="sm" name="remember" label="Keep me signed in" />
            <LinkButton href="#" size="sm">Forgot password?</LinkButton>
          </div>
          <Button type="submit" style={{ width: '100%' }}>Sign in</Button>
        </Form>

        <Text color="secondary" style={{ textAlign: 'center' }}>
          New here? <LinkButton href="#">Create an account</LinkButton>
        </Text>
      </div>
    </main>
  );
}
```
