Switch
Switch between two opposing states
Class props
Switch component
Switch between two opposing states
html
<o-switch></o-switch>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
autocomplete | Same as native autocomplete options to use in HTML5 validation | string | - | From config: switch: { |
disabled | Same as native disabled | boolean | - | false |
falseValue | Overrides the returned value when it's not checked | string|number|boolean|object | - | false |
label | Input label, unnecessary when default slot is used | string | - | |
v-model | The input value state | string|number|boolean|object | - | |
name | Name attribute on native checkbox | string | - | |
nativeValue | Same as native value | string|number|boolean|object | - | |
override | Override existing theme classes completely | boolean | - | |
passiveVariant | Color of the switch when is passive | string | primary , info , success , warning , danger , and any other custom color | From config: switch: { |
position | Label position | string | - | "right" |
required | Same as native required | boolean | - | false |
rounded | Rounded style | boolean | - | true |
size | Size of the control | string | small , medium , large | From config: switch: { |
trueValue | Overrides the returned value when it's checked | string|number|boolean|object | - | true |
useHtml5Validation | Enable html 5 native validation | boolean | - | From config: { |
variant | Color of the control | string | primary , info , success , warning , danger , and any other custom color | From config: switch: { |
Events
Event name | Properties | Description |
---|---|---|
update:modelValue | value string | number | boolean | object - updated modelValue prop | modelValue prop two-way binding |
input | value string | number | boolean | object - input valueevent Event - native event | on input change event |
focus | event Event - native event | on input focus event |
blur | event Event - native event | on input blur event |
invalid | event Event - native event | on input invalid event |
Slots
Name | Description | Bindings |
---|---|---|
default | Override the label, default is label prop |
Sass variables
Current theme ➜ Oruga
SASS Variable | Default |
---|---|
$switch-active-background-color | var(--#{$prefix}primary) |
$switch-action-background | #f5f5f5 |
$switch-background | var(--#{$prefix}grey-light) |
$switch-border-radius | var(--#{$prefix}base-border-radius) |
$switch-box-shadow | 0 3px 1px 0 rgba(0, 0, 0, 0.05), 0 2px 2px 0 rgba(0, 0, 0, 0.1), 0 3px 3px 0 rgba(0, 0, 0, 0.05) |
$switch-disabled-opacity | var(--#{$prefix}base-disabled-opacity) |
$switch-margin-label | 0.5em |
$switch-padding | 0.2em |
$switch-rounded-border-radius | var( --#{$prefix}base-border-radius-rounded) |
$switch-width | 2.75 * 1em |
See ➜ 📄 Full scss file
Current theme ➜ Bulma
The theme does not have any custom variables for this component.