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: { |
customValidity | Custom HTML 5 validation error to set on the form control | string | ((currentValue: unknown, state: ValidityState) => string) | - |
|
disabled | Same as native disabled | boolean | - | false |
falseValue | Overrides the returned value when it's not checked | unknown | - | |
id | Same as native id. Also set the for label for o-field wrapper - default is an uuid. | string | - | useId() |
label | Input label, unnecessary when default slot is used | string | - | |
v-model | The input value state, use v-model to make it two-way binding | unknown | - | |
name | Name attribute on native checkbox | string | - | |
nativeValue | Same as native value | unknown | - | |
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 | unknown | - | |
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
SASS Variable | Default |
---|---|
$switch-colors | var.$colors |
$switch-width | 2.75em |
$switch-padding | 0.2em |
$switch-background-color | css.getVar("grey-light") |
$switch-active-background-color | css.getVar("primary") |
$switch-shadow | css.getVar("shadow") |
See ➜ 📄 Full scss file