Skip to main content

EmailForm

<allegro-email-form> is a web component that renders an email subscription form. On success it transitions to a confirmation state. Both states are fully customizable via attributes, slots, and CSS variables.

Usage

<allegro-email-form></allegro-email-form>

With custom attributes:

<allegro-email-form
placeholder-text="Your email address"
submit-text="Subscribe"
show-disclaimer="true"
disclaimer-text="We'll never share your email."
confirmation-heading="You're in!"
confirmation-text="Thanks for subscribing."
continue-text="Continue"
></allegro-email-form>

Attributes

AttributeTypeDefaultDescription
placeholder-texttextEnter your emailPlaceholder text for the email input field.
submit-texttextSubmitLabel for the submit button.
show-disclaimerbooleanfalseWhether to show the disclaimer paragraph below the form.
disclaimer-texttext(empty)HTML content for the disclaimer paragraph.
confirmation-headingtextThank you!Heading shown in the confirmation state.
confirmation-texttextThanks for providing your email.Body text shown in the confirmation state.
continue-texttextContinueLabel for the continue button in the confirmation state.
tracking-datatext(empty)JSON object of custom data merged into every tracked event, e.g. "{'campaign': 'footer'}".

States

StateTriggerDescription
emailInitial renderThe default state showing the email input form.
confirmationSuccessful form submissionShown after the email is successfully submitted.

Slots

SlotAppears inDescription
confirmationconfirmationReplaces the default confirmation state UI. When present, the default content is not rendered.
<allegro-email-form>
<div slot="confirmation">
<p>Thanks! Check your inbox.</p>
</div>
</allegro-email-form>

Events

Dispatched

EventBubblesDetailDescription
allegro:email-form:successyes{ email: string }Fired when the form is successfully submitted.
allegro:email-form:erroryes{ email: string, error: string }Fired when there is an error during form submission.

Tracked Events

The component records the following events via the Allegro SDK.

EventWhenData
email_form_submittedFired after a successful form submission.(none)

CSS Variables

All visual properties are exposed as CSS custom properties so the component can be themed from the host page without piercing the shadow DOM.

allegro-email-form {
--emailForm--button--background: #1a1a1a;
--emailForm--input--border: 1px solid #ccc;
}

General

VariableDefaultDescription
--emailForm--font-familysystem-ui, sans-serifFont family for the component.

Input

VariableDefaultDescription
--emailForm--input--background#fffInput background color.
--emailForm--input--border1px solid #cccInput border.
--emailForm--input--border-radius0.375remInput border radius.
--emailForm--input--font-size1remInput font size.
--emailForm--input--padding0.75rem 1remInput padding.
--emailForm--input--focus-border-color#555Border color on input focus.

Submit Button

VariableDefaultDescription
--emailForm--button--background#000Button background color.
--emailForm--button--color#fffButton text color.
--emailForm--button--border-radius0.375remButton border radius.
--emailForm--button--font-size0.875remButton font size.
--emailForm--button--font-weight700Button font weight.
--emailForm--button--padding0.75rem 1.25remButton padding.
--emailForm--button--text-transformuppercaseButton text transform.

Error Message

VariableDefaultDescription
--emailForm--error--background#fef2f2Error background color.
--emailForm--error--border1px solid #fecacaError border.
--emailForm--error--accent-color#dc2626Error left accent border color.
--emailForm--error--border-radius0.375remError border radius.
--emailForm--error--color#b91c1cError text color.
--emailForm--error--icon-colorcurrentColorError icon color.
--emailForm--error--padding0.625rem 0.875remError padding.

Confirmation State

VariableDefaultDescription
--emailForm--state-icon--background#111Confirmation icon circle background.
--emailForm--state-heading--color#111Confirmation heading color.
--emailForm--state-heading--font-size1.25remConfirmation heading font size.
--emailForm--state-heading--font-weight700Confirmation heading font weight.
--emailForm--state-body--color#555Confirmation body text color.
--emailForm--state-body--font-size0.9375remConfirmation body font size.

Example: Dark Background

allegro-email-form {
--emailForm--input--background: #1a1a1a;
--emailForm--input--border: 1px solid #444;
--emailForm--input--focus-border-color: #888;
--emailForm--button--background: #fff;
--emailForm--button--color: #000;
--emailForm--state-icon--background: #fff;
--emailForm--state-heading--color: #fff;
--emailForm--state-body--color: #aaa;
}