Zip code form
Responsive example
The zip code form is wrapped in grid columns that constrain the width at certain breakpoints. The stackUntil prop is set to lg so the input and button begin displaying side-by-side at that breakpoint.
Pre-populate zipcode example
Same as above, except the zip code form can accept an initial zip code value, facilitating the pre-population of zip codes from a form. This feature is beneficial for scenarios where a pre-determined zip code needs to be set, which users can subsequently modify. If the user does not alter the zip code, it will default to the initial value provided.
Dark responsive example
Same as above, except the zip code form is inside a container with a dark background and the dark prop is set to true.
Constrained responsive example
This form has stackUntil set to sm and appears within a smaller-width container. It has constrained set to true in order to make better use of the limited space. This reduces the horizontal padding on the submit button and reduces the size of the privacy text.
Side-by-side example with no privacy section
This form has stackUntil set to xs so it is always side-by-side. It also has the privacy section disabled by setting showPrivacySection to false.
Constrained stacked example
This example remains stacked at every breakpoint, in a limited-width container. This shows how the form would display within a card on the sidebar of a page.
Product specific CTA
This example shows how to specify a product parameter that will be passed along when the form is submitted.
Context message example
This example shows how to use the contextMessage prop to display a message above the ZIP code input.
Enter your ZIP code to get started.
Replace field in URL
This example shows how to use the replaceFieldNameInUrl prop when the zip code needs to be embedded within the URL, rather than appended as a URL parameter. Provide a URL that contains the fieldName within curly braces, such as https://energysage.wattbuy.com/electricity/en/{zip_code}/electricity-plans/.
EsZipCodeForm slots
- Name
buttonText
- Type
String
- Default
'Submit'
- Description
- The caption of the submit button.
- Name
errorMessage
- Type
String
- Default
'Please enter a 5-digit zip code.'
- Description
- The error message displayed when form validation fails.
- Name
privacyExplanation
- Type
String
- Default
'Your information is safe with us.'
- Description
- Text that will appear next to the Privacy Policy link. Intended to be a brief description of our commitment to protecting customer information.
- Name
privacyPolicyLinkText
- Type
String
- Default
'Privacy Policy'
- Description
- The text for the Privacy Policy link.
EsZipCodeForm props
- Name
constrained
- Type
Boolean
- Default
false
- Description
- Reduces the button padding and privacy text font size to better accommodate limited-width layouts.
- Name
contextMessage
- Type
String
- Default
''
- Description
- Optional message to display above the ZIP code input field.
- Name
dark
- Type
Boolean
- Default
false
- Description
- Renders the CTA with white text (suitable for display on a dark background).
- Name
fieldName
- Type
String
- Default
'zip_code'
- Description
- The name to use when submitting the ZIP code to the provided url.
- Name
inputId
- Type
String
- Default
- n/a
- Description
- Required. The id for the zip entry. Must be unique on the page.
- Name
newTab
- Type
Boolean
- Default
false
- Description
- Whether to open the URL in the url prop in a new tab.
- Name
placeholder
- Type
String
- Default
'ZIP code'
- Description
- Shown in the input as placeholder text. Also used as the (visually hidden) label for the input.
- Name
privacyPolicyLink
- Type
String
- Default
''
- Description
- Link to the privacy policy. The link will not be shown if this is left blank.
- Name
privacyPolicyNewTab
- Type
Boolean
- Default
false
- Description
- Whether to open the privacy policy link in a new tab.
- Name
replaceFieldNameInUrl
- Type
Boolean
- Default
false
- Description
- Whether to replace the field name in the URL instead of submitting it as a query string parameter in the URL.
- Name
selectedProduct
- Type
String
- Default
''
- Description
- Specify which product of interest. Options include: solar-pv, heatpump, ev-charger
- Name
showPrivacySection
- Type
Boolean
- Default
true
- Description
- Whether to show the privacy section.
- Name
stackUntil
- Type
String
- Default
''
- Description
- The input will be stacked above the button until the provided breakpoint (e.g. md, lg, xl), at which point they will appear side by side. If no breakpoint is provided, the form will remain stacked on all breakpoints.
- Name
url
- Type
String
- Default
- n/a
- Description
- URL to which the form will submit the provided zip code value.
- Name
zipCodeValue
- Type
String
- Default
''
- Description
- The default zipcode value if passed to the zip code form