import InputSwitch from 'primevue/inputswitch';
Two-way value binding is defined using v-model.
<InputSwitch v-model="checked" />
Enabling checked property displays the component as active initially.
<InputSwitch v-model="checked" />
Invalid state style is added using the p-invalid class to indicate a failed validation.
<InputSwitch v-model="checked" invalid />
When disabled is present, the element cannot be edited and focused.
<InputSwitch v-model="checked" disabled />
InputSwitch component uses a hidden native checkbox element with switch role internally that is only visible to screen readers. Value to describe the component can either be provided via label tag combined with id prop or using aria-labelledby, aria-label props.
<label for="switch1">Remember Me</label>
<InputSwitch inputId="switch1" />
<span id="switch2">Remember Me</span>
<InputSwitch aria-labelledby="switch2" />
<InputSwitch aria-label="Remember Me" />
Key | Function |
---|---|
tab | Moves focus to the switch. |
space | Toggles the checked state. |