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>(defaultfalse)options: InputSignal<ISignInFormOptions | undefined>cssClass: InputSignal<string>(aliasclass)submit: OutputEmitterRef<ISignInFormSubmit>socialClick: OutputEmitterRef<ISignInFormSocialClick>
API
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
mode | InputSignal<SmartSignInFormMode> | 'sign-in' | 'sign-in' or 'sign-up' |
disabled | InputSignal<boolean> | false | Disables inputs and prevents emit |
options | InputSignal<ISignInFormOptions | undefined> | - | Optional configuration (social providers, layout, slots etc.) |
class | InputSignal<string> | '' | External CSS classes (alias for cssClass) |
Outputs
| Output | Type | Description |
|---|---|---|
submit | OutputEmitterRef<ISignInFormSubmit> | Emitted on form submit (when not disabled): { email, password, mode } |
socialClick | OutputEmitterRef<ISignInFormSocialClick> | Emitted on a social provider button click (when not disabled): { providerId, mode } |
ISignInFormOptions
| Field | Type | Default | Description |
|---|---|---|---|
socialProviders | ISocialProvider[] | [] | Social sign-in buttons. |
showLabels | boolean | - | false hides the field labels; the preset's simple-no-labels layout hides them unless this is true. |
forgotPasswordHref | string | - | "Forgot password?" link (sign-in mode). |
signUpHref | string | - | "Create an account" link (sign-in mode). |
signInHref | string | - | "Already have an account?" link (sign-up mode). |
submitLabel | string | mode === 'sign-up' ? 'Sign up' : 'Sign in' | Text of the submit button (not translated). |
emailPlaceholder | string | - | Placeholder of the email field. |
passwordPlaceholder | string | - | Placeholder of the password field. |
extraTpl | TemplateRef<unknown> | - | Extra content at the end of the form (e.g. a "remember me" checkbox or terms). |
ariaLabel | string | - | Accessible name of the <form>. |
layout | SmartSignInFormLayout | 'simple' | Preset only: simple, simple-no-labels, card or split-screen (see the preset section). The standard ignores it. |
heroImageUrl | string | - | 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
| Field | Type | Default | Description |
|---|---|---|---|
id | string | required | Reported as providerId. |
label | string | required | Button text. |
iconTpl | TemplateRef<unknown> | - | Icon template; wins over iconUrl. |
iconUrl | string | - | Icon image (rendered with an empty alt). |
ISignInFormSubmit and ISignInFormSocialClick
| Type | Field | Type | Description |
|---|---|---|---|
ISignInFormSubmit | email | string | The typed email. |
ISignInFormSubmit | password | string | The typed password. |
ISignInFormSubmit | mode | SmartSignInFormMode | The form mode. |
ISignInFormSocialClick | providerId | string | The id of the clicked provider. |
ISignInFormSocialClick | mode | SmartSignInFormMode | The 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.layout | Look |
|---|---|
simple (default) | Single column, max-w-sm mx-auto, labeled fields |
simple-no-labels | Single column, placeholders only (labels off unless showLabels: true) |
card | simple wrapped in a bordered, rounded, shadowed white/dark card |
split-screen | grid 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>withISignInFormOptions, thedisabledinput bound to a pending signal and thesubmitoutput handled asISignInFormSubmit.docs/examples/app/apps/web/src/app/auth/login.service.ts: what the submit handler calls, the OAuth password grant against/api/tokenwith the returned token stored throughAuthService.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-emailand#smart-sign-in-form-passwordinputs and theformsubmit event.docs/examples/app/apps/web-e2e/src/support/app.ts: the Playwright helper that fills the same form by those ids and clicks thebutton.submitelement.
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.
| Export | Kind | What it is |
|---|---|---|
SmartSignInForm | component | Renders the implementation registered as components['sign-in-form'] on SmartProvider, SmartSignInFormStandard by default. |
SmartSignInFormPreset | component | Styled sign-in form variation (preset). |
SmartSignInFormStandard | component | The default, unstyled sign-in form. |
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. |
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
| Prop | Type | Default | Description |
|---|---|---|---|
mode? | SmartSignInFormMode | 'sign-in' | sign-in or sign-up; picks the default submit label and the links shown. |
disabled? | boolean | false | Disables 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
| Field | Type | Default | Description |
|---|---|---|---|
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
| Field | Type | Default | Description |
|---|---|---|---|
email | string | required | The typed email. |
password | string | required | The typed password. |
mode | SmartSignInFormMode | required | The form mode. |
ISignInFormSocialClick
| Field | Type | Default | Description |
|---|---|---|---|
providerId | string | required | The id of the clicked provider. |
mode | SmartSignInFormMode | required | The form mode. |
ISocialProvider
| Field | Type | Default | Description |
|---|---|---|---|
id | string | required | Reported as providerId. |
label | string | required | Button text. |
iconTpl? | ReactNode | — | Icon node. |
iconUrl? | string | — | Icon image. |
Related types
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.
| Returns | Type | Description |
|---|---|---|
email | string | The typed email. |
setEmail | Dispatch<SetStateAction<string>> | Sets the email. |
password | string | The typed password. |
setPassword | Dispatch<SetStateAction<string>> | Sets the password. |
submit | (event: FormEvent<HTMLFormElement>) => void | The form's onSubmit handler: prevents the default and reports onSubmit. |
socialClick | (providerId: string) => void | Reports 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);SmartSignInFormPresetrenders the four layouts withsmart:dark:variants,classNamemerged 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.