Skip to content

Commit 5698cb4

Browse files
committed
feat(CFormSwitch): add a reverse property to allow put switches to the opposite side
1 parent 28eb51c commit 5698cb4

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Diff for: packages/coreui-vue/src/components/form/CFormSwitch.ts

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ const CFormSwitch = defineComponent({
3131
type: [Boolean, String],
3232
value: undefined,
3333
},
34+
/**
35+
* Put checkboxes or radios on the opposite side.
36+
*
37+
* @sinve 4.8.0
38+
*/
39+
reverse: Boolean,
3440
/**
3541
* Size the component large or extra large. Works only with `switch`.
3642
*
@@ -82,6 +88,7 @@ const CFormSwitch = defineComponent({
8288
class: [
8389
'form-check form-switch',
8490
{
91+
'form-check-reverse': props.reverse,
8592
[`form-switch-${props.size}`]: props.size,
8693
'is-invalid': props.invalid,
8794
'is-valid': props.valid,

Diff for: packages/docs/forms/switch.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ description: Create consistent cross-browser and cross-device switch component.
55
other_frameworks: switch
66
---
77

8-
## Switches
8+
## About
99

10-
A switch has the markup of a custom checkbox but uses the `switch` boolean properly to render a toggle switch. Switches also support the `disabled` attribute.
10+
Vue Switch Components are a type of UI component that allows users to toggle between two states, usually represented as "on" or "off", "enabled" or "disabled", or "checked" or "unchecked".
11+
12+
When a user interacts with the component by clicking or tapping on it, the switch toggles its state, triggering an action or changing the appearance of the component. This type of component is often used in forms, settings panels, and other places where users need to turn something on or off or choose between two options.
13+
14+
## Example
1115

1216
::: demo
1317
<CFormSwitch label="Default switch checkbox input" id="formSwitchCheckDefault"/>
@@ -22,7 +26,9 @@ A switch has the markup of a custom checkbox but uses the `switch` boolean prope
2226
<CFormSwitch label="Disabled checked switch checkbox input" id="formSwitchCheckCheckedDisabled" checked disabled/>
2327
```
2428

25-
### Sizes
29+
## Sizing
30+
31+
Larger or smaller react switches? Add `size="lg"` or `size="xl"` for additional sizes.
2632

2733
::: demo
2834
<CFormSwitch label="Default switch checkbox input" id="formSwitchCheckDefault"/>
@@ -35,6 +41,19 @@ A switch has the markup of a custom checkbox but uses the `switch` boolean prope
3541
<CFormSwitch size="xl" label="Extra large switch checkbox input" id="formSwitchCheckDefaultXL"/>
3642
```
3743

44+
## Reverse
45+
46+
Put your switches on the opposite side by adding `reverse` boolean property.
47+
48+
::: demo
49+
<CFormSwitch reverse type="radio" id="reverseFormSwitch1" label="Reverse switch"/>
50+
<CFormSwitch reverse type="radio" id="reverseFormSwitch2" label="Disabled reverse switch" disabled/>
51+
:::
52+
```vue
53+
<CFormSwitch reverse type="radio" id="reverseFormSwitch1" label="Reverse switch"/>
54+
<CFormSwitch reverse type="radio" id="reverseFormSwitch2" label="Disabled reverse switch" disabled/>
55+
```
56+
3857
## API
3958

4059
!!!include(./api/form/CFormSwitch.api.md)!!!

0 commit comments

Comments
 (0)