Form

Collect fields, validate them, and emit a submission event.

Reserve a workshop place

Labels, fields and actions form a small vertical rhythm. Submitting stays inside this preview.

Search the archive

A compact single-purpose form with a query and one action.

A local form

Type a name and submit. The result stays in this preview.

The example has no action endpoint. Submit an empty field to see validation, then enter a name to see the form data. It sends no server request.

Use a native <button type="submit"> in the form slot. ds-button does not forward a submit type.

AttributeTypeDefaultWhat it does
actionstringEmptyOptional server endpoint.
methodstringpostHTTP method for a server submission.
namestringEmptyForm name.
novalidatebooleanfalseSkips validation.
autocompletestringonAutocomplete preference.
const form = document.querySelector('ds-form');
form.addEventListener('form-submit', (event) => {
console.log(event.detail.data);
});

form-invalid reports validation errors. form-reset, form-response and form-error report reset and server outcomes. Methods are getFormData(), validate(), reset() and submit().

Input · Button