Skip to content

Commit 74116de

Browse files
committedMar 21, 2023
feat(CFormCheck): add reverse option
1 parent f4f64ef commit 74116de

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed
 

‎packages/coreui-react/src/components/form/CFormCheck.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface CFormCheckProps
5555
*/
5656
indeterminate?: boolean
5757
/**
58-
* Group checkboxes or radios on the same horizontal row by adding.
58+
* Group checkboxes or radios on the same horizontal row.
5959
*/
6060
inline?: boolean
6161
/**
@@ -66,6 +66,12 @@ export interface CFormCheckProps
6666
* The element represents a caption for a component.
6767
*/
6868
label?: string | ReactNode
69+
/**
70+
* Put checkboxes or radios on the opposite side.
71+
*
72+
* @sinve 4.7.0
73+
*/
74+
reverse?: boolean
6975
/**
7076
* Specifies the type of component.
7177
*/
@@ -92,6 +98,7 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
9298
inline,
9399
invalid,
94100
label,
101+
reverse,
95102
type = 'checkbox',
96103
valid,
97104
...rest
@@ -183,6 +190,7 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
183190
'form-check',
184191
{
185192
'form-check-inline': inline,
193+
'form-check-reverse': reverse,
186194
'is-invalid': invalid,
187195
'is-valid': valid,
188196
},
@@ -211,6 +219,7 @@ CFormCheck.propTypes = {
211219
indeterminate: PropTypes.bool,
212220
inline: PropTypes.bool,
213221
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
222+
reverse: PropTypes.bool,
214223
type: PropTypes.oneOf(['checkbox', 'radio']),
215224
...CFormControlValidation.propTypes,
216225
}

‎packages/docs/content/forms/checkbox.mdx

+9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ Group checkboxes on the same horizontal row by adding `inline` boolean property
6060
<CFormCheck inline id="inlineCheckbox3" value="option3" label="3 (disabled)" disabled/>
6161
```
6262

63+
## Reverse
64+
65+
Put your checkboxes on the opposite side by adding `reverse` boolean property.
66+
67+
```jsx preview
68+
<CFormCheck reverse id="reverseCheckbox1" value="option1" label="Reverse checkbox"/>
69+
<CFormCheck reverse id="reverseCheckbox2" value="option2" label="Disabled reverse checkbox" disabled/>
70+
```
71+
6372
## Without labels
6473

6574
Remember to still provide some form of accessible name for assistive technologies (for instance, using `aria-label`).

‎packages/docs/content/forms/radio.mdx

+9
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ Group radios on the same horizontal row by adding `inline` boolean property to a
5353
<CFormCheck inline type="radio" name="inlineRadioOptions" id="inlineCheckbox3" value="option3" label="3 (disabled)" disabled/>
5454
```
5555

56+
## Reverse
57+
58+
Put your checkboxes on the opposite side by adding `reverse` boolean property.
59+
60+
```jsx preview
61+
<CFormCheck reverse type="radio" id="reverseOption1" value="option1" label="Reverse radio"/>
62+
<CFormCheck reverse type="radio" id="reverseOption2" value="option2" label="Disabled reverse radio" disabled/>
63+
```
64+
5665
## Without labels
5766

5867
Remember to still provide some form of accessible name for assistive technologies (for instance, using `aria-label`).

0 commit comments

Comments
 (0)
Please sign in to comment.