SCheckbox <s-checkbox>
ts
import { SCheckbox } from 'polaris-vue-elements'Example
Checked: false
vue
<script setup>
import { ref } from 'vue'
import { SCheckbox } from 'polaris-vue-elements'
const value = ref(false)
</script>
<template>
<SCheckbox label="Send me marketing emails" v-model="value" />
<p>Checked: {{ value }}</p>
</template>v-model
v-model on <SCheckbox> binds to the checked property and listens for the change DOM event.
template
<SCheckbox v-model="value" />is equivalent to:
template
<SCheckbox :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. |
defaultIndeterminate | boolean | The initial indeterminate state for uncontrolled components. Use this when you want the checkbox to start in an indeterminate state but don't need to control it afterward. This value applies until indeterminate is explicitly set or the user changes the checkbox state by clicking. |
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. |
indeterminate | boolean | Whether the checkbox displays in an indeterminate state (neither checked nor unchecked), typically used to indicate partial selection in hierarchical lists. This visual state takes priority over the checked prop in appearance only. The form submission value is still determined by the checked prop. If indeterminate has not been explicitly set and hasn't been modified by user interaction, it returns the value of defaultIndeterminate. |
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 | The value used in form data when the control is checked. |
Events
| Event | Type |
|---|---|
blur | CustomEvent |
change | CustomEvent |
input | CustomEvent |
Listen for these with @blur-style listeners on <SCheckbox>.
Slots
| Slot | Description |
|---|---|
details | |
error |