Sign-in Form

The <smart-sign-in-form> component renders a single form that supports both sign-in and sign-up flows via the mode input. It exposes submit and socialClick outputs, optional social provider buttons, optional forgot/sign-in/sign-up links, an optional extra slot, and standard form fields. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract SignInFormBaseComponent defines the shared API — mode ('sign-in' | 'sign-up'), disabled, optional ISignInFormOptions, cssClass (alias class), and the submit / socialClick outputs. SignInFormStandardComponent is a barebones placeholder concrete implementation using a native <form> with <input type="email"> and <input type="password">. SignInFormComponent is the public wrapper that renders SignInFormStandardComponent by default and accepts a custom replacement via SIGN_IN_FORM_STANDARD_COMPONENT_TOKEN.


Usage

<smart-sign-in-form
  [options]="options"
  [mode]="mode"
  (submit)="onSubmit($event)"
  (socialClick)="onSocialClick($event)"
/>
@if (signedInAs()) {
  <p>Signed in as {{ signedInAs() }}</p>
}
@if (provider()) {
  <p>Continue with provider: {{ provider() }}</p>
}

The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Components

SignInFormComponent (<smart-sign-in-form>)

Main wrapper component. Renders SignInFormStandardComponent by default. When SIGN_IN_FORM_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet and hands it mode, disabled, options and class. The wrapper re-emits submit and socialClick from the standard child, or from the preset or custom implementation registered through the token.

SignInFormStandardComponent (<smart-sign-in-form-standard>)

Barebones placeholder concrete implementation using a native <form> (with aria-label from options.ariaLabel). Renders an outer wrapper, the form with Email / Password <label>s (hidden when options.showLabels is false), <input type="email" id="smart-sign-in-form-email">, <input type="password" id="smart-sign-in-form-password"> (with autocomplete="new-password" in sign-up mode, current-password otherwise), an optional Forgot password? link (sign-in mode only), the submit button (options.submitLabel, or Sign in / Sign up after the mode), optional social provider buttons (iconTpl or iconUrl, then label), an optional alt-link (Create an account to signUpHref in sign-in mode, Already have an account? to signInHref in sign-up mode), and an optional extraTpl slot. It does not read layout or heroImageUrl (preset only). The submit handler emits { email, password, mode } via the inherited submit output unless disabled is true. It stops the native submit event from bubbling, because the output shares its name with the DOM event: without that, a (submit) listener on the host would also receive the raw SubmitEvent. A custom implementation must do the same. Each social provider button emits { providerId, mode } via socialClick, also ignored while disabled (the inputs and buttons are disabled too).

SignInFormBaseComponent (abstract)

Abstract base directive. Exposes:

  • mode: InputSignal<SmartSignInFormMode> (default 'sign-in')
  • disabled: InputSignal<boolean> (default false)
  • options: InputSignal<ISignInFormOptions | undefined>
  • cssClass: InputSignal<string> (alias class)
  • submit: OutputEmitterRef<ISignInFormSubmit>
  • socialClick: OutputEmitterRef<ISignInFormSocialClick>

API

Inputs

InputTypeDefaultDescription
modeInputSignal<SmartSignInFormMode>'sign-in''sign-in' or 'sign-up'
disabledInputSignal<boolean>falseDisables inputs and prevents emit
optionsInputSignal<ISignInFormOptions | undefined>-Optional configuration (social providers, layout, slots etc.)
classInputSignal<string>''External CSS classes (alias for cssClass)

Outputs

OutputTypeDescription
submitOutputEmitterRef<ISignInFormSubmit>Emitted on form submit (when not disabled): { email, password, mode }
socialClickOutputEmitterRef<ISignInFormSocialClick>Emitted on a social provider button click (when not disabled): { providerId, mode }

ISignInFormOptions

FieldTypeDefaultDescription
socialProvidersISocialProvider[][]Social sign-in buttons.
showLabelsboolean-false hides the field labels; the preset's simple-no-labels layout hides them unless this is true.
forgotPasswordHrefstring-"Forgot password?" link (sign-in mode).
signUpHrefstring-"Create an account" link (sign-in mode).
signInHrefstring-"Already have an account?" link (sign-up mode).
submitLabelstringmode === 'sign-up' ? 'Sign up' : 'Sign in'Text of the submit button (not translated).
emailPlaceholderstring-Placeholder of the email field.
passwordPlaceholderstring-Placeholder of the password field.
extraTplTemplateRef<unknown>-Extra content at the end of the form (e.g. a "remember me" checkbox or terms).
ariaLabelstring-Accessible name of the <form>.
layoutSmartSignInFormLayout'simple'Preset only: simple, simple-no-labels, card or split-screen (see the preset section). The standard ignores it.
heroImageUrlstring-Preset only: the cover image of the split-screen layout. The standard ignores it.

SmartSignInFormMode is 'sign-in' | 'sign-up'; SmartSignInFormLayout is 'simple' | 'simple-no-labels' | 'split-screen' | 'card'.

ISocialProvider

FieldTypeDefaultDescription
idstringrequiredReported as providerId.
labelstringrequiredButton text.
iconTplTemplateRef<unknown>-Icon template; wins over iconUrl.
iconUrlstring-Icon image (rendered with an empty alt).

ISignInFormSubmit and ISignInFormSocialClick

TypeFieldTypeDescription
ISignInFormSubmitemailstringThe typed email.
ISignInFormSubmitpasswordstringThe typed password.
ISignInFormSubmitmodeSmartSignInFormModeThe form mode.
ISignInFormSocialClickproviderIdstringThe id of the clicked provider.
ISignInFormSocialClickmodeSmartSignInFormModeThe form mode.

SIGN_IN_FORM_STANDARD_COMPONENT_TOKEN

Provide a component class extending SignInFormBaseComponent under SIGN_IN_FORM_STANDARD_COMPONENT_TOKEN; every <smart-sign-in-form> below that injector renders it.

Extending the base class

import {
  ChangeDetectionStrategy,
  Component,
  computed,
  signal,
  ViewEncapsulation,
} from '@angular/core';

import {
  ISignInFormOptions,
  SIGN_IN_FORM_STANDARD_COMPONENT_TOKEN,
  SignInFormBaseComponent,
  SignInFormComponent,
} from '@smartsoft001/angular';

@Component({
  selector: 'docs-custom-sign-in-form',
  template: `
    <form
      [class]="containerClasses()"
      [attr.aria-label]="options()?.ariaLabel ?? submitLabel()"
      (submit)="onSubmit($event)"
    >
      <label class="docs-sign-in-form__field">
        @if (options()?.showLabels) {
          <span>Email address</span>
        }
        <input
          type="email"
          class="docs-sign-in-form__email"
          autocomplete="email"
          [placeholder]="options()?.emailPlaceholder ?? 'you@example.com'"
          [value]="email()"
          (input)="email.set($any($event.target).value)"
        />
      </label>

      <label class="docs-sign-in-form__field">
        @if (options()?.showLabels) {
          <span>Password</span>
        }
        <input
          type="password"
          class="docs-sign-in-form__password"
          [attr.autocomplete]="
            mode() === 'sign-up' ? 'new-password' : 'current-password'
          "
          [placeholder]="options()?.passwordPlaceholder ?? ''"
          [value]="password()"
          (input)="password.set($any($event.target).value)"
        />
      </label>

      @if (options()?.forgotPasswordHref) {
        <a
          class="docs-sign-in-form__forgot"
          [href]="options()?.forgotPasswordHref"
        >
          Forgot password?
        </a>
      }

      <button
        type="submit"
        class="docs-sign-in-form__submit"
        [disabled]="disabled()"
      >
        {{ submitLabel() }}
      </button>

      @for (provider of options()?.socialProviders ?? []; track provider.id) {
        <button
          type="button"
          class="docs-sign-in-form__social"
          [disabled]="disabled()"
          (click)="socialClick.emit({ providerId: provider.id, mode: mode() })"
        >
          {{ provider.label }}
        </button>
      }
    </form>
  `,
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomSignInFormComponent extends SignInFormBaseComponent {
  readonly email = signal('');
  readonly password = signal('');

  readonly submitLabel = computed(
    () =>
      this.options()?.submitLabel ??
      (this.mode() === 'sign-up' ? 'Create account' : 'Sign in'),
  );

  readonly containerClasses = computed(() => {
    const classes = [
      'docs-sign-in-form',
      `docs-sign-in-form--${this.options()?.layout ?? 'simple'}`,
    ];
    const extra = this.cssClass();
    if (extra) classes.push(extra);
    return classes.join(' ');
  });

  onSubmit(event: Event): void {
    event.preventDefault();
    // Keep the native submit event inside the component: only the typed
    // `submit` output should reach a `(submit)` listener on the host.
    event.stopPropagation();
    if (this.disabled()) return;

    this.submit.emit({
      email: this.email(),
      password: this.password(),
      mode: this.mode(),
    });
  }
}

@Component({
  selector: 'docs-sign-in-form-custom-example',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [SignInFormComponent],
  // The token swaps the standard sign-in form for the custom one everywhere
  // below this component, so consumers keep writing `<smart-sign-in-form>`.
  providers: [
    {
      provide: SIGN_IN_FORM_STANDARD_COMPONENT_TOKEN,
      useValue: CustomSignInFormComponent,
    },
  ],
  // The wrapper re-emits the custom component's submit and socialClick.
  template: `
    <smart-sign-in-form
      mode="sign-in"
      [options]="options"
      (submit)="signedInAs.set($event.email)"
      (socialClick)="provider.set($event.providerId)"
    />
    @if (signedInAs()) {
      <p>Signed in as {{ signedInAs() }}</p>
    }
    @if (provider()) {
      <p>Continue with provider: {{ provider() }}</p>
    }
  `,
})
export class SignInFormCustomExampleComponent {
  readonly signedInAs = signal<string | null>(null);
  readonly provider = signal<string | null>(null);

  readonly options: ISignInFormOptions = {
    layout: 'simple',
    showLabels: true,
    forgotPasswordHref: '/forgot',
    socialProviders: [{ id: 'google', label: 'Continue with Google' }],
  };
}

Preset

SignInFormPresetComponent (<smart-sign-in-form-preset>) is a styled drop-in replacement that extends SignInFormStandardComponent, so it inherits all form logic unchanged (email/password signals, onSubmit with the disabled guard, onSocialClick, and mode reactivity for labels/links). It realizes the four options.layout values with Tailwind (smart:-prefixed, explicit smart:dark:* twins) and consistent field styling (rounded-lg, gray borders, blue focus ring; solid blue submit; outline social buttons; blue text links).

options.layoutLook
simple (default)Single column, max-w-sm mx-auto, labeled fields
simple-no-labelsSingle column, placeholders only (labels off unless showLabels: true)
cardsimple wrapped in a bordered, rounded, shadowed white/dark card
split-screengrid lg:grid-cols-2: heroImageUrl cover image column + form column

data-role hooks for testing/styling: container, form, email, password, submit, social, forgot, alt-link, hero, extra, card.

Provide SignInFormPresetComponent under SIGN_IN_FORM_STANDARD_COMPONENT_TOKEN so <smart-sign-in-form> renders the preset, or register every preset of the library at once with provideSmartPresets(). The preset declares cssClass without the class alias: bind [cssClass] when you use <smart-sign-in-form-preset> directly; on <smart-sign-in-form> pass class as usual.

Notes: heroImageUrl renders as a smart:lg:block cover image (hidden below the lg breakpoint); submitLabel, emailPlaceholder, passwordPlaceholder, and the extraTpl slot are all honored. The preset styles the submit button through its data-role="submit" hook and does not carry the standard's submit class.

Reference implementation

The example application under docs/examples/app signs in through this component against a real API; its login page is the pattern to copy.

  • docs/examples/app/apps/web/src/app/auth/login.page.ts: a login page on <smart-sign-in-form> with ISignInFormOptions, the disabled input bound to a pending signal and the submit output handled as ISignInFormSubmit.
  • docs/examples/app/apps/web/src/app/auth/login.service.ts: what the submit handler calls, the OAuth password grant against /api/token with the returned token stored through AuthService.setToken.
  • docs/examples/app/apps/web/src/app/auth/login.page.spec.ts: a Jest test that drives the rendered form through its #smart-sign-in-form-email and #smart-sign-in-form-password inputs and the form submit event.
  • docs/examples/app/apps/web-e2e/src/support/app.ts: the Playwright helper that fills the same form by those ids and clicks the button.submit element.

Source

The component lives in packages/shared/angular/src/lib/components/sign-in-form and is documented for Claude Code by the angular-components-sign-in-form skill.

SmartSignInForm renders an email + password form in sign-in (default) or sign-up mode. Submitting reports onSubmit({ email, password, mode }); social provider buttons report onSocialClick({ providerId, mode }); both are ignored while disabled. Links to "forgot password" (sign-in), sign-up (sign-in) and sign-in (sign-up) are rendered when their hrefs are set. The form does not authenticate anyone: call your API (or AuthService) in onSubmit. SmartSignInFormPreset renders four layouts.


Usage

import { useState } from 'react';

import {
  ISignInFormOptions,
  ISignInFormSocialClick,
  ISignInFormSubmit,
  SmartSignInForm,
  SmartSignInFormMode,
} from '@smartsoft001/react';

const options: ISignInFormOptions = {
  submitLabel: 'Sign in to your account',
  emailPlaceholder: 'you@example.com',
  forgotPasswordHref: '/forgot-password',
  signUpHref: '/sign-up',
  socialProviders: [{ id: 'google', label: 'Continue with Google' }],
};

const mode: SmartSignInFormMode = 'sign-in';

export function SignInFormUsageExample() {
  const [signedInAs, setSignedInAs] = useState<string | null>(null);
  const [provider, setProvider] = useState<string | null>(null);

  // The form does not authenticate anyone: call your API here.
  const onSubmit = ({ email }: ISignInFormSubmit) => setSignedInAs(email);

  const onSocialClick = ({ providerId }: ISignInFormSocialClick) =>
    setProvider(providerId);

  return (
    <>
      <SmartSignInForm
        options={options}
        mode={mode}
        onSubmit={onSubmit}
        onSocialClick={onSocialClick}
      />
      {signedInAs && <p>Signed in as {signedInAs}</p>}
      {provider && <p>Continue with provider: {provider}</p>}
    </>
  );
}

The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.

Exports

All from @smartsoft001/react.

ExportKindWhat it is
SmartSignInFormcomponentRenders the implementation registered as components['sign-in-form'] on SmartProvider, SmartSignInFormStandard by default.
SmartSignInFormPresetcomponentStyled sign-in form variation (preset).
SmartSignInFormStandardcomponentThe default, unstyled sign-in form.
useSignInFormhookThe form logic every sign-in form variant shares: the typed email and password, submit() reporting them with the mode, and socialClick(); both are ignored while disabled.

The preset's class helpers (getSignInFormContainerClasses, getSignInFormCardClasses, getSignInFormHeroClasses, getSignInFormColumnClasses, getSignInFormLabelClasses, getSignInFormInputClasses, getSignInFormSubmitClasses, getSignInFormSocialClasses, getSignInFormLinkClasses) are exported too, for a custom implementation that wants the preset look.

Props and Types

SmartSignInFormProps

PropTypeDefaultDescription
mode?SmartSignInFormMode'sign-in'sign-in or sign-up; picks the default submit label and the links shown.
disabled?booleanfalseDisables the form; submit and social clicks are ignored.
options?ISignInFormOptions—Providers, layout, labels, links and slots.
className?string—Classes on the container.
onSubmit?(value: ISignInFormSubmit) => void—Called with the typed credentials and the mode.
onSocialClick?(value: ISignInFormSocialClick) => void—Called when a social sign-in button is clicked.

ISignInFormOptions

FieldTypeDefaultDescription
socialProviders?ISocialProvider[][]Social sign-in buttons.
layout?SmartSignInFormLayout'simple'Preset only: simple (default), simple-no-labels, card or split-screen. The standard ignores it.
showLabels?boolean—false hides the field labels (the simple-no-labels preset layout hides them unless this is true).
heroImageUrl?string—Preset only: the cover image of the split-screen layout. The standard ignores it.
forgotPasswordHref?string—"Forgot password" link (sign-in mode).
signUpHref?string—Link to the sign-up screen (sign-in mode).
signInHref?string—Link to the sign-in screen (sign-up mode).
submitLabel?string(mode === 'sign-up' ? 'Sign up' : 'Sign in')Submit text; Sign in / Sign up by default (untranslated).
emailPlaceholder?string—Placeholder of the email field.
passwordPlaceholder?string—Placeholder of the password field.
extraTpl?ReactNode—Extra content (e.g. a "remember me" checkbox or terms).
ariaLabel?string—Accessible name of the form.

ISignInFormSubmit

FieldTypeDefaultDescription
emailstringrequiredThe typed email.
passwordstringrequiredThe typed password.
modeSmartSignInFormModerequiredThe form mode.

ISignInFormSocialClick

FieldTypeDefaultDescription
providerIdstringrequiredThe id of the clicked provider.
modeSmartSignInFormModerequiredThe form mode.

ISocialProvider

FieldTypeDefaultDescription
idstringrequiredReported as providerId.
labelstringrequiredButton text.
iconTpl?ReactNode—Icon node.
iconUrl?string—Icon image.
  • SmartSignInFormMode: 'sign-in' \| 'sign-up'
  • SmartSignInFormLayout: 'simple' \| 'simple-no-labels' \| 'split-screen' \| 'card'

Replacing the Implementation

SmartSignInForm renders the component registered under the 'sign-in-form' key of SmartProvider's components, and SmartSignInFormStandard when nothing is registered there. Every SmartSignInForm below the provider then renders the registered component, which receives the same props.

SmartSignInFormPreset is the styled (preset) implementation: register it under the 'sign-in-form' key of SmartProvider's components, render it directly in place of SmartSignInForm, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.

The useSignInForm hook

The form logic every sign-in form variant shares: the typed email and password, submit() reporting them with the mode, and socialClick(); both are ignored while disabled.

ReturnsTypeDescription
emailstringThe typed email.
setEmailDispatch<SetStateAction<string>>Sets the email.
passwordstringThe typed password.
setPasswordDispatch<SetStateAction<string>>Sets the password.
submit(event: FormEvent<HTMLFormElement>) => voidThe form's onSubmit handler: prevents the default and reports onSubmit.
socialClick(providerId: string) => voidReports onSocialClick for a provider.
import { useState } from 'react';

import {
  cn,
  ISignInFormOptions,
  SmartProvider,
  SmartSignInForm,
  SmartSignInFormProps,
  useSignInForm,
} from '@smartsoft001/react';

export function CustomSignInForm(props: SmartSignInFormProps) {
  const { mode = 'sign-in', disabled = false, options, className } = props;
  // useSignInForm keeps the typed email and password; submit() and
  // socialClick() report them with the mode and are ignored while disabled.
  const { email, setEmail, password, setPassword, submit, socialClick } =
    useSignInForm(props);

  const submitLabel =
    options?.submitLabel ?? (mode === 'sign-up' ? 'Create account' : 'Sign in');

  return (
    <form
      className={cn(
        'docs-sign-in-form',
        `docs-sign-in-form--${options?.layout ?? 'simple'}`,
        className,
      )}
      aria-label={options?.ariaLabel ?? submitLabel}
      onSubmit={submit}
    >
      <label className="docs-sign-in-form__field">
        {options?.showLabels && <span>Email address</span>}
        <input
          type="email"
          className="docs-sign-in-form__email"
          autoComplete="email"
          placeholder={options?.emailPlaceholder ?? 'you@example.com'}
          value={email}
          onChange={(event) => setEmail(event.target.value)}
        />
      </label>

      <label className="docs-sign-in-form__field">
        {options?.showLabels && <span>Password</span>}
        <input
          type="password"
          className="docs-sign-in-form__password"
          autoComplete={
            mode === 'sign-up' ? 'new-password' : 'current-password'
          }
          placeholder={options?.passwordPlaceholder ?? ''}
          value={password}
          onChange={(event) => setPassword(event.target.value)}
        />
      </label>

      {options?.forgotPasswordHref && (
        <a
          className="docs-sign-in-form__forgot"
          href={options.forgotPasswordHref}
        >
          Forgot password?
        </a>
      )}

      <button
        type="submit"
        className="docs-sign-in-form__submit"
        disabled={disabled}
      >
        {submitLabel}
      </button>

      {(options?.socialProviders ?? []).map((provider) => (
        <button
          key={provider.id}
          type="button"
          className="docs-sign-in-form__social"
          disabled={disabled}
          onClick={() => socialClick(provider.id)}
        >
          {provider.label}
        </button>
      ))}
    </form>
  );
}

// A module constant: a new object on every render would change the context.
const components = { 'sign-in-form': CustomSignInForm };

const options: ISignInFormOptions = {
  layout: 'simple',
  showLabels: true,
  forgotPasswordHref: '/forgot',
  socialProviders: [{ id: 'google', label: 'Continue with Google' }],
};

export function SignInFormCustomExample() {
  const [signedInAs, setSignedInAs] = useState<string | null>(null);
  const [provider, setProvider] = useState<string | null>(null);

  // Every SmartSignInForm below the provider renders CustomSignInForm, which
  // receives the same props, onSubmit and onSocialClick included.
  return (
    <SmartProvider components={components}>
      <SmartSignInForm
        mode="sign-in"
        options={options}
        onSubmit={({ email }) => setSignedInAs(email)}
        onSocialClick={({ providerId }) => setProvider(providerId)}
      />
      {signedInAs && <p>Signed in as {signedInAs}</p>}
      {provider && <p>Continue with provider: {provider}</p>}
    </SmartProvider>
  );
}

Styling

  • The standard form is unstyled (class hooks such as forgot-password, alt-link, extra); SmartSignInFormPreset renders the four layouts with smart:dark: variants, className merged into its container.

Source

The component lives in packages/shared/react/src/lib/components/sign-in-form and is documented for Claude Code by the react-components-sign-in-form skill.