From 02be2bcafea77b99d145cbabfef4a1b62530b59d Mon Sep 17 00:00:00 2001 From: Segun Adebayo Date: Mon, 14 Mar 2022 23:00:12 +0400 Subject: [PATCH] fix: add support for input props in radio and checkbox --- packages/checkbox/src/checkbox.tsx | 10 +++++++++- packages/radio/src/radio.tsx | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/checkbox/src/checkbox.tsx b/packages/checkbox/src/checkbox.tsx index cc2c697870b..5834e3146b6 100644 --- a/packages/checkbox/src/checkbox.tsx +++ b/packages/checkbox/src/checkbox.tsx @@ -72,6 +72,10 @@ export interface CheckboxProps * @default CheckboxIcon */ icon?: React.ReactElement + /** + * Additional props to be forwarded to the `input` element + */ + inputProps?: React.InputHTMLAttributes } /** @@ -100,6 +104,7 @@ export const Checkbox = forwardRef((props, ref) => { isChecked: isCheckedProp, isDisabled = group?.isDisabled, onChange: onChangeProp, + inputProps, ...rest } = ownProps @@ -150,7 +155,10 @@ export const Checkbox = forwardRef((props, ref) => { className={cx("chakra-checkbox", className)} {...getRootProps()} > - + } /** @@ -57,6 +61,7 @@ export const Radio = forwardRef((props, ref) => { isFullWidth, isDisabled = group?.isDisabled, isFocusable = group?.isFocusable, + inputProps: htmlInputProps, ...rest } = ownProps @@ -90,7 +95,7 @@ export const Radio = forwardRef((props, ref) => { const [layoutProps, otherProps] = split(htmlProps, layoutPropNames as any) const checkboxProps = getCheckboxProps(otherProps) - const inputProps = getInputProps({}, ref) + const inputProps = getInputProps(htmlInputProps, ref) const labelProps = getLabelProps() const rootProps = Object.assign({}, layoutProps, getRootProps())