@@ -40,6 +40,10 @@ export interface CFormCheckProps extends InputHTMLAttributes<HTMLInputElement> {
4040 * A string of all className you want applied to the component. [docs]
4141 */
4242 className ?: string
43+ /**
44+ * Sets hit area to the full area of the component. [docs]
45+ */
46+ hitArea ?: 'full'
4347 /**
4448 * The id global attribute defines an identifier (ID) that must be unique in the whole document. [docs]
4549 */
@@ -70,7 +74,10 @@ export interface CFormCheckProps extends InputHTMLAttributes<HTMLInputElement> {
7074}
7175
7276export 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+ ) => {
7481 const _className = classNames (
7582 'form-check' ,
7683 {
@@ -84,6 +91,7 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
8491 const inputClassName = classNames ( button ? 'btn-check' : 'form-check-input' , {
8592 'is-invalid' : invalid ,
8693 'is-valid' : valid ,
94+ 'me-2' : hitArea ,
8795 } )
8896 const labelClassName = classNames (
8997 button
@@ -116,10 +124,17 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
116124 { label && formLabel ( ) }
117125 </ >
118126 ) : 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+ )
123138 ) : (
124139 formControl ( )
125140 )
@@ -129,6 +144,7 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
129144CFormCheck . propTypes = {
130145 button : PropTypes . object ,
131146 className : PropTypes . string ,
147+ hitArea : PropTypes . oneOf ( [ 'full' ] ) ,
132148 id : PropTypes . string ,
133149 inline : PropTypes . bool ,
134150 invalid : PropTypes . bool ,
0 commit comments