p-switch component is a control that is used to quickly switch between two possible states. A switch is only used
for these binary actions that occur immediately after the user “flips the switch”. Commonly it is used for “on/off”
state.p-switch component can be used with a visible or hidden label, but it's recommended to keep the label visible for
better accessibility whenever possible. A label is a caption which informs the user which action is followed by
interaction. When used with hidden label, it's best practice to provide a descriptive label text for screen readers.click, focus, focusin, blur and focusout events on the p-switch.<!doctype html>
<html lang="en" class="scheme-light-dark">
<head>
<title></title>
</head>
<body class="bg-canvas">
<p-switch>
Some label
</p-switch>
<script>
const pSwitch = document.querySelector("p-switch");
pSwitch.addEventListener('update', (e) => e.target.checked = e.detail.checked);
</script>
</body>
</html>