Skip to content

Commit 466bb07

Browse files
authored
Accept tabIndex on Checkbox component (#3645)
This PR allows you to pass a `tabIndex` to the `Checkbox` component.
1 parent 87252e1 commit 466bb07

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/@headlessui-react/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Bump `@tanstack/react-virtual` to be fix warnings in React 19 projects ([#3588](https://github.com/tailwindlabs/headlessui/pull/3588))
1414
- Fix `aria-invalid` attributes to have a valid `'true'` value ([#3639](https://github.com/tailwindlabs/headlessui/pull/3639))
1515

16+
### Added
17+
18+
- Accept `tabIndex` on `Checkbox` component ([#3645](https://github.com/tailwindlabs/headlessui/pull/3645))
19+
1620
## [2.2.0] - 2024-10-25
1721

1822
### Added

packages/@headlessui-react/src/components/checkbox/checkbox.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type CheckboxPropsWeControl =
5151
| 'aria-disabled'
5252
| 'aria-labelledby'
5353
| 'role'
54-
| 'tabIndex'
5554

5655
export type CheckboxProps<
5756
TTag extends ElementType = typeof DEFAULT_CHECKBOX_TAG,
@@ -71,6 +70,7 @@ export type CheckboxProps<
7170
form?: string
7271
name?: string
7372
onChange?: (checked: boolean) => void
73+
tabIndex?: number
7474
}
7575
>
7676

@@ -92,6 +92,7 @@ function CheckboxFn<TTag extends ElementType = typeof DEFAULT_CHECKBOX_TAG, TTyp
9292
value,
9393
form,
9494
indeterminate = false,
95+
tabIndex = 0,
9596
...theirProps
9697
} = props
9798

@@ -148,7 +149,7 @@ function CheckboxFn<TTag extends ElementType = typeof DEFAULT_CHECKBOX_TAG, TTyp
148149
'aria-describedby': describedBy,
149150
'aria-disabled': disabled ? true : undefined,
150151
indeterminate: indeterminate ? 'true' : undefined,
151-
tabIndex: disabled ? undefined : 0,
152+
tabIndex: disabled ? undefined : tabIndex,
152153
onKeyUp: disabled ? undefined : handleKeyUp,
153154
onKeyPress: disabled ? undefined : handleKeyPress,
154155
onClick: disabled ? undefined : handleClick,

0 commit comments

Comments
 (0)