Skip to content

Commit ba64ef7

Browse files
committed
Add example for toggle button event listener
1 parent b6be6cd commit ba64ef7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/javascript/components_toggle_button.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ Defaults to `1`.
3434

3535
The custom event `change` is fired on the toggle button whenever the `checked` property of the button changes.
3636
The event detail contains `{ checked: boolean }`, alternatively the property `checked` can be queried to fetch the current state.
37+
38+
Example:
39+
40+
```ts
41+
document.getElementId("toggle-button-id").addEventListener("change", (event: CustomEvent) => {
42+
if (event.detail.checked) {
43+
// button is checked
44+
}
45+
});
46+
```

0 commit comments

Comments
 (0)