SSwitch <s-switch>
ts
import { SSwitch } from 'polaris-vue-elements'Example
On: false
vue
<script setup>
import { ref } from 'vue'
import { SSwitch } from 'polaris-vue-elements'
const value = ref(false)
</script>
<template>
<SSwitch label="Enable notifications" v-model="value" />
<p>On: {{ value }}</p>
</template>v-model
v-model on <SSwitch> binds to the checked property and listens for the change DOM event.
template
<SSwitch v-model="value" />is equivalent to:
template
<SSwitch :checked="value" @change="value = $event.target.checked" />Props
| Prop | Type | Description |
|---|---|---|
accessibilityLabel | string | A label used for users using assistive technologies like screen readers. When set, any children or label supplied will not be announced. This can also be used to display a control without a visual label, while still providing context to users using screen readers. |
checked | boolean | Whether the control is active. |
defaultChecked | boolean | Whether the control is active by default. |
details | any | Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user. This will also be exposed to screen reader users. |
disabled | boolean | Disables the control, disallowing any interaction. |
error | any | Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately. |
label | any | Visual content to use as the control label. |
labelAccessibilityVisibility | "visible" | "exclusive" | Changes the visibility of the component's label. - visible: the label is visible to all users. - exclusive: the label is visually hidden but remains in the accessibility tree. |
name | string | An identifier for the control that is unique within the nearest containing Form component. |
required | boolean | Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the error property. |
value | string |
Events
| Event | Type |
|---|---|
blur | CustomEvent |
change | CustomEvent |
input | CustomEvent |
Listen for these with @blur-style listeners on <SSwitch>.