docs(form): add "Prevent default behavior" example

This commit is contained in:
Eric Liu 2022-03-13 12:36:39 -07:00
commit f7c85096da

View file

@ -60,3 +60,17 @@ components: ["Form", "FormGroup"]
</FormGroup> </FormGroup>
<Button type="submit">Submit</Button> <Button type="submit">Submit</Button>
</Form> </Form>
### Prevent default behavior
The forwarded `submit` event is not modified. Use `e.preventDefault()` to prevent the native form submission behavior.
```
<Form on:submit={e => {
e.preventDefault();
console.log("submit", e);
}}>
<Checkbox id="checkbox-0" labelText="Checkbox Label" checked />
<Button type="submit">Submit</Button>
</Form>
```