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 | - | false |
| label | Input label, unnecessary when default slot is used | string | - | |
| name | Name attribute on native checkbox | string | - | |
| nativeValue | Same as native value | string|number|boolean | - | |
| 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 | - | true |
| useHtml5Validation | Enable html 5 native validation | boolean | - | From config: { |
| v-model | string|number|boolean | - | ||
| 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 - updated modelValue prop | modelValue prop two-way binding |
| input | value string, number, boolean - 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 Base
| SASS Variable | Default |
|---|---|
| $switch-active-background-color | $primary |
| $switch-action-background | #f5f5f5 |
| $switch-background | $grey-light |
| $switch-border-radius | $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 | $base-disabled-opacity |
| $switch-margin-label | 0.5em |
| $switch-padding | 0.2em |
| $switch-rounded-border-radius | $base-rounded-border-radius |
| $switch-width | 2.75 * 1em |
See ➜ 📄 Full scss file
Current theme ➜ Oruga Full
| SASS Variable | Default |
|---|---|
| $switch-active-background-color | $primary |
| $switch-action-background | #f5f5f5 |
| $switch-background | $grey-light |
| $switch-border-radius | $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 | $base-disabled-opacity |
| $switch-margin-label | 0.5em |
| $switch-padding | 0.2em |
| $switch-rounded-border-radius | $base-rounded-border-radius |
| $switch-width | 2.75 * 1em |
See ➜ 📄 Full scss file
Current theme ➜ Bulma
The theme does not have any custom variables for this component.
