From 02be2bcafea77b99d145cbabfef4a1b62530b59d Mon Sep 17 00:00:00 2001 From: Segun Adebayo Date: Mon, 14 Mar 2022 23:00:12 +0400 Subject: [PATCH 1/2] 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()) From a7be72918f1e74ce20eb31544433e4321caf5c78 Mon Sep 17 00:00:00 2001 From: Segun Adebayo Date: Mon, 14 Mar 2022 23:27:56 +0400 Subject: [PATCH 2/2] docs: add changeset --- .changeset/chilly-files-argue.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/chilly-files-argue.md diff --git a/.changeset/chilly-files-argue.md b/.changeset/chilly-files-argue.md new file mode 100644 index 00000000000..d9682c4ec09 --- /dev/null +++ b/.changeset/chilly-files-argue.md @@ -0,0 +1,6 @@ +--- +"@chakra-ui/checkbox": minor +"@chakra-ui/radio": minor +--- + +Add support for passing `inputProps` to underlying input element