Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5698cb4

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

File tree

Expand file treeCollapse file tree

2 files changed

+29
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+29
-3
lines changed

‎packages/coreui-vue/src/components/form/CFormSwitch.ts

Copy file name to clipboardExpand all lines: packages/coreui-vue/src/components/form/CFormSwitch.ts
+7Lines changed: 7 additions & 0 deletions
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,

‎packages/docs/forms/switch.md

Copy file name to clipboardExpand all lines: packages/docs/forms/switch.md
+22-3Lines changed: 22 additions & 3 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.