Basic usage

Add components and connect their properties, state, and events to your application.

Connect events#

Handle a regular Button action through the standard click event. Wait for registration to complete before accessing component properties or methods.

JavaScript
await customElements.whenDefined('sy-button');

const button = document.querySelector('#save-button');
button.addEventListener('click', async () => {
  button.loading = true;
  try {
    await saveChanges(); // Your application's save function
  } finally {
    button.loading = false;
  }
});

Handle form submission in the form's submit event. For all Button properties and methods, see Button API.