Form
Wraps one or more form controls and enables implicit submission, letting users submit the form from any input by pressing “Enter.” Unlike the HTML form element, this component doesn’t automatically submit data via HTTP. You must register a submit event to handle form submission in JavaScript.
Anchor to propertiesProperties
- Anchor to idididstringstring
A unique identifier for the element.
Anchor to eventsEvents
Learn more about registering events.
- Anchor to submitsubmitsubmitCallbackEventListener<typeof tagName>CallbackEventListener<typeof tagName>
A callback that is run when the form is submitted.
CallbackEventListener
(EventListener & {
(event: CallbackEvent<TTagName, Event> & TData): void;
}) | nullCallbackEvent
TEvent & {
currentTarget: HTMLElementTagNameMap[TTagName];
}Examples
<s-form>
<s-text-field label="Email address" />
<s-button type="submit" variant="primary">Submit</s-button>
</s-form>
Preview

Examples
Code
Default
<s-form> <s-text-field label="Email address" /> <s-button type="submit" variant="primary">Submit</s-button> </s-form>
Anchor to best-practicesBest Practices
- Wrap around all form input elements.
- Forms can have only one submit button and it must be at the end of the form.
Was this page helpful?