Form
The form component wraps form controls and enables implicit submission, allowing users to submit from any input by pressing Enter. Use form to group related input fields and handle form submission through JavaScript event handlers.
Unlike HTML forms, form doesn't automatically submit data using HTTP—you must register a submit event to process form data programmatically. For Shopify Functions configuration forms, use function settings.
Supported targets
- admin.
abandoned-checkout-details. block. render - admin.
catalog-details. block. render - admin.
collection-details. block. render - admin.
company-details. block. render - admin.
company-location-details. block. render - admin.
customer-details. block. render - admin.
discount-details. function-settings. render - admin.
draft-order-details. block. render - admin.
gift-card-details. block. render - admin.
order-details. block. render - admin.
product-details. block. render - admin.
product-details. configuration. render - admin.
product-details. reorder. render - admin.
product-variant-details. block. render - admin.
product-variant-details. configuration. render - admin.
settings. order-routing-rule. render - admin.
settings. validation. render
Supported targets
- admin.
abandoned-checkout-details. block. render - admin.
catalog-details. block. render - admin.
collection-details. block. render - admin.
company-details. block. render - admin.
company-location-details. block. render - admin.
customer-details. block. render - admin.
discount-details. function-settings. render - admin.
draft-order-details. block. render - admin.
gift-card-details. block. render - admin.
order-details. block. render - admin.
product-details. block. render - admin.
product-details. configuration. render - admin.
product-details. reorder. render - admin.
product-variant-details. block. render - admin.
product-variant-details. configuration. render - admin.
settings. order-routing-rule. render - admin.
settings. validation. render
Anchor to EventsEvents
The form component provides event callbacks for handling user interactions. Learn more about handling events.
- Anchor to resetresetresetCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback that is run when the form is reset.
- Anchor to submitsubmitsubmitCallbackExtendableEventListener<typeof tagName> | nullCallbackExtendableEventListener<typeof tagName> | nullrequiredrequired
A callback that is run when the form is submitted.
CallbackEventListener
A function that handles events from UI components. This type represents an event listener callback that receives a `CallbackEvent` with a strongly-typed `currentTarget`. Use this for component event handlers like `click`, `focus`, `blur`, and other DOM events.
(EventListener & {
(event: CallbackEvent<T>): void;
}) | nullCallbackEvent
An event object with a strongly-typed `currentTarget` property that references the specific HTML element that triggered the event. This type extends the standard DOM `Event` interface and ensures type safety when accessing the element that fired the event.
Event & {
currentTarget: HTMLElementTagNameMap[T];
}CallbackExtendableEventListener
A function that handles extendable events from UI components. This type represents an event listener callback that can use `waitUntil` to extend the event lifetime.
(EventListener & {
(event: CallbackExtendableEvent<TTagName>): void;
}) | nullCallbackExtendableEvent
- AT_TARGET
2 - bubbles
The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
boolean - BUBBLING_PHASE
3 - cancelable
The **`cancelable`** read-only property of the Event interface indicates whether the event can be canceled, and therefore prevented as if the event never happened. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
boolean - cancelBubble
The **`cancelBubble`** property of the Event interface is deprecated.
boolean - CAPTURING_PHASE
1 - composed
The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
boolean - composedPath
The **`composedPath()`** method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
() => EventTarget[] - currentTarget
The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
EventTarget | null - defaultPrevented
The **`defaultPrevented`** read-only property of the Event interface returns a boolean value indicating whether or not the call to Event.preventDefault() canceled the event. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
boolean - eventPhase
The **`eventPhase`** read-only property of the being evaluated. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
number - initEvent
The **`Event.initEvent()`** method is used to initialize the value of an event created using Document.createEvent().
(type: string, bubbles?: boolean, cancelable?: boolean) => void - isTrusted
The **`isTrusted`** read-only property of the when the event was generated by the user agent (including via user actions and programmatic methods such as HTMLElement.focus()), and `false` when the event was dispatched via The only exception is the `click` event, which initializes the `isTrusted` property to `false` in user agents. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
boolean - NONE
0 - preventDefault
The **`preventDefault()`** method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
() => void - returnValue
The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
boolean - srcElement
The deprecated **`Event.srcElement`** is an alias for the Event.target property.
EventTarget | null - stopImmediatePropagation
The **`stopImmediatePropagation()`** method of the If several listeners are attached to the same element for the same event type, they are called in the order in which they were added. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
() => void - stopPropagation
The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
() => void - target
The read-only **`target`** property of the dispatched. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
EventTarget | null - timeStamp
The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
DOMHighResTimeStamp - type
The **`type`** read-only property of the Event interface returns a string containing the event's type. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
string - waitUntil
A method that accepts a promise signaling the duration and eventual success or failure of event-related actions. Can be called multiple times to add promises to the event, but must be called synchronously during event dispatch. Cannot be called after a `setTimeout` or within a microtask.
(promise: Promise<void>) => void
Anchor to ExamplesExamples
Anchor to Submit a basic formSubmit a basic form
Group input fields that submit together when a merchant presses Enter or clicks a submit button. This example shows a basic form with a text field and submit button.
Preview
html
Anchor to Build a campaign form with date and money fieldsBuild a campaign form with date and money fields
Use specialized field types like date field and money field to collect structured campaign data. This example includes a reset button alongside submit so merchants can clear and start over.
Preview
html
Anchor to Show field validation errorsShow field validation errors
Display specific error messages on individual fields to guide merchants toward valid input. This example shows a required text field and number field with inline validation errors.
Preview
html
Anchor to Use select and checkbox fieldsUse select and checkbox fields
Mix text inputs with selects and checkboxes to capture different kinds of merchant decisions. This example combines a text field, a select dropdown, and a checkbox for creating a discount.
Preview
html
Anchor to Group fields into sectionsGroup fields into sections
Organize a longer form into labeled groups so merchants can scan and complete it more easily. This example uses sections to separate contact information from shipping preferences.
Preview
html
Anchor to Best practicesBest practices
- Group related fields logically: Organize fields by category or workflow step so merchants can complete forms efficiently.
- Validate with specific error messages: Instead of Invalid input, provide actionable feedback like Email must include @ symbol or Password must be at least 8 characters.
- Mark required fields clearly: Use the
requiredproperty and show validation errors only after user interaction or submission attempt. - Choose field types that match data: Use email field for emails, number field for quantities, and date field for dates to provide appropriate keyboards and pickers.
- Provide submission feedback: Show loading states during processing and clear success or error messages after completion. Prevent duplicate submissions while processing.
- Handle unsaved changes: For long or complex forms, consider auto-saving drafts or prompting before navigation when changes exist.
Anchor to LimitationsLimitations
- Unlike native HTML forms, the component doesn't automatically submit data using HTTP. You must register a
submitevent handler to process form data programmatically.