diff --git a/packages/ui-checkbox/src/Checkbox/index.tsx b/packages/ui-checkbox/src/Checkbox/index.tsx index 989d57f7bc..1b45efee0e 100644 --- a/packages/ui-checkbox/src/Checkbox/index.tsx +++ b/packages/ui-checkbox/src/Checkbox/index.tsx @@ -273,27 +273,29 @@ class Checkbox extends Component { onMouseOut={createChainedFunction(onMouseOut, this.handleMouseOut)} ref={this.handleRef} > - { - this._input = c - }} - disabled={disabled || readOnly} - aria-checked={indeterminate ? 'mixed' : undefined} - css={styles?.input} - onChange={this.handleChange} - onKeyDown={createChainedFunction(onKeyDown, this.handleKeyDown)} - onFocus={createChainedFunction(onFocus, this.handleFocus)} - onBlur={createChainedFunction(onBlur, this.handleBlur)} - checked={this.checked} - /> - +
+ { + this._input = c + }} + disabled={disabled || readOnly} + aria-checked={indeterminate ? 'mixed' : undefined} + css={styles?.input} + onChange={this.handleChange} + onKeyDown={createChainedFunction(onKeyDown, this.handleKeyDown)} + onFocus={createChainedFunction(onFocus, this.handleFocus)} + onBlur={createChainedFunction(onBlur, this.handleBlur)} + checked={this.checked} + /> + +
) } diff --git a/packages/ui-checkbox/src/Checkbox/props.ts b/packages/ui-checkbox/src/Checkbox/props.ts index b025415df2..3349d826e7 100644 --- a/packages/ui-checkbox/src/Checkbox/props.ts +++ b/packages/ui-checkbox/src/Checkbox/props.ts @@ -87,9 +87,12 @@ type AllowedPropKeys = Readonly> type CheckboxProps = CheckboxOwnProps & WithStyleProps & - OtherHTMLAttributes & WithDeterministicIdProps + OtherHTMLAttributes & + WithDeterministicIdProps -type CheckboxStyle = ComponentStyle<'checkbox' | 'input' | 'control'> +type CheckboxStyle = ComponentStyle< + 'checkbox' | 'input' | 'control' | 'container' +> const propTypes: PropValidators = { label: PropTypes.node.isRequired, diff --git a/packages/ui-checkbox/src/Checkbox/styles.ts b/packages/ui-checkbox/src/Checkbox/styles.ts index f1e9dc802b..abfcc4350c 100644 --- a/packages/ui-checkbox/src/Checkbox/styles.ts +++ b/packages/ui-checkbox/src/Checkbox/styles.ts @@ -57,6 +57,10 @@ const generateStyle = ( width: 'auto' }) }, + // this container is added to reduce the clickable area of the checkbox to the actual checkbox and label + container: { + width: 'fit-content' + }, input: { label: 'checkbox__input', padding: 0, diff --git a/packages/ui-radio-input/src/RadioInput/index.tsx b/packages/ui-radio-input/src/RadioInput/index.tsx index 7b5b6b1d2b..2b0a7fdf95 100644 --- a/packages/ui-radio-input/src/RadioInput/index.tsx +++ b/packages/ui-radio-input/src/RadioInput/index.tsx @@ -141,26 +141,28 @@ class RadioInput extends Component { this.ref = el }} > - { - this._input = c - }} - value={value} - name={name} - checked={this.checked} - type="radio" - css={styles?.input} - disabled={disabled || readOnly} - aria-disabled={disabled || readOnly ? 'true' : undefined} - onChange={this.handleChange} - onClick={this.handleClick} - /> - +
+ { + this._input = c + }} + value={value} + name={name} + checked={this.checked} + type="radio" + css={styles?.input} + disabled={disabled || readOnly} + aria-disabled={disabled || readOnly ? 'true' : undefined} + onChange={this.handleChange} + onClick={this.handleClick} + /> + +
) } diff --git a/packages/ui-radio-input/src/RadioInput/props.ts b/packages/ui-radio-input/src/RadioInput/props.ts index 04ad79e644..79ec8d0588 100644 --- a/packages/ui-radio-input/src/RadioInput/props.ts +++ b/packages/ui-radio-input/src/RadioInput/props.ts @@ -87,7 +87,7 @@ type RadioInputProps = RadioInputOwnProps & WithDeterministicIdProps type RadioInputStyle = ComponentStyle< - 'radioInput' | 'input' | 'control' | 'facade' | 'label' + 'radioInput' | 'input' | 'control' | 'facade' | 'label' | 'container' > type RadioInputState = { diff --git a/packages/ui-radio-input/src/RadioInput/styles.ts b/packages/ui-radio-input/src/RadioInput/styles.ts index 8fc237002c..ea9f1efa3d 100644 --- a/packages/ui-radio-input/src/RadioInput/styles.ts +++ b/packages/ui-radio-input/src/RadioInput/styles.ts @@ -273,6 +273,10 @@ const generateStyle = ( ...(disabled && { cursor: 'not-allowed' }) } }, + // this container is added to reduce the clickable area to the size of the radio button and label + container: { + width: 'fit-content' + }, input: { label: 'radioInput__input', ...inputStyles,