@@ -40,6 +40,10 @@ export interface CFormCheckProps extends InputHTMLAttributes<HTMLInputElement> {
40
40
* A string of all className you want applied to the component. [docs]
41
41
*/
42
42
className ?: string
43
+ /**
44
+ * Sets hit area to the full area of the component. [docs]
45
+ */
46
+ hitArea ?: 'full'
43
47
/**
44
48
* The id global attribute defines an identifier (ID) that must be unique in the whole document. [docs]
45
49
*/
@@ -70,7 +74,10 @@ export interface CFormCheckProps extends InputHTMLAttributes<HTMLInputElement> {
70
74
}
71
75
72
76
export const CFormCheck = forwardRef < HTMLInputElement , CFormCheckProps > (
73
- ( { className, button, id, inline, invalid, label, type = 'checkbox' , valid, ...rest } , ref ) => {
77
+ (
78
+ { className, button, hitArea, id, inline, invalid, label, type = 'checkbox' , valid, ...rest } ,
79
+ ref ,
80
+ ) => {
74
81
const _className = classNames (
75
82
'form-check' ,
76
83
{
@@ -84,6 +91,7 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
84
91
const inputClassName = classNames ( button ? 'btn-check' : 'form-check-input' , {
85
92
'is-invalid' : invalid ,
86
93
'is-valid' : valid ,
94
+ 'me-2' : hitArea ,
87
95
} )
88
96
const labelClassName = classNames (
89
97
button
@@ -116,10 +124,17 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
116
124
{ label && formLabel ( ) }
117
125
</ >
118
126
) : label ? (
119
- < div className = { _className } >
120
- { formControl ( ) }
121
- { formLabel ( ) }
122
- </ div >
127
+ hitArea ? (
128
+ < CFormLabel customClassName = { className } { ...( id && { htmlFor : id } ) } >
129
+ { formControl ( ) }
130
+ { label }
131
+ </ CFormLabel >
132
+ ) : (
133
+ < div className = { _className } >
134
+ { formControl ( ) }
135
+ { formLabel ( ) }
136
+ </ div >
137
+ )
123
138
) : (
124
139
formControl ( )
125
140
)
@@ -129,6 +144,7 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
129
144
CFormCheck . propTypes = {
130
145
button : PropTypes . object ,
131
146
className : PropTypes . string ,
147
+ hitArea : PropTypes . oneOf ( [ 'full' ] ) ,
132
148
id : PropTypes . string ,
133
149
inline : PropTypes . bool ,
134
150
invalid : PropTypes . bool ,
0 commit comments