diff --git a/packages/@headlessui-react/CHANGELOG.md b/packages/@headlessui-react/CHANGELOG.md
index 6c9ecf2933..3694842687 100644
--- a/packages/@headlessui-react/CHANGELOG.md
+++ b/packages/@headlessui-react/CHANGELOG.md
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix cursor position when re-focusing the `ComboboxInput` component ([#3065](https://github.com/tailwindlabs/headlessui/pull/3065))
- Keep focus inside of the `` component ([#3073](https://github.com/tailwindlabs/headlessui/pull/3073))
- Fix enter transitions for the `Transition` component ([#3074](https://github.com/tailwindlabs/headlessui/pull/3074))
+- Render hidden form input fields for `Checkbox`, `Switch` and `RadioGroup` components ([#3095](https://github.com/tailwindlabs/headlessui/pull/3095))
### Changed
diff --git a/packages/@headlessui-react/src/components/checkbox/checkbox.test.tsx b/packages/@headlessui-react/src/components/checkbox/checkbox.test.tsx
index 623fcdb380..4aff6769e4 100644
--- a/packages/@headlessui-react/src/components/checkbox/checkbox.test.tsx
+++ b/packages/@headlessui-react/src/components/checkbox/checkbox.test.tsx
@@ -135,8 +135,10 @@ describe('Form submissions', () => {
)
+ let checkbox = document.querySelector('[id^="headlessui-checkbox-"]') as HTMLInputElement
+
// Focus the checkbox
- await focus(getCheckbox())
+ await focus(checkbox)
// Submit
await press(Keys.Enter)
@@ -145,7 +147,7 @@ describe('Form submissions', () => {
expect(handleSubmission).toHaveBeenLastCalledWith({})
// Toggle
- await click(getCheckbox())
+ await click(checkbox)
// Submit
await press(Keys.Enter)
@@ -154,7 +156,7 @@ describe('Form submissions', () => {
expect(handleSubmission).toHaveBeenLastCalledWith({ notifications: 'on' })
// Toggle
- await click(getCheckbox())
+ await click(checkbox)
// Submit
await press(Keys.Enter)
diff --git a/packages/@headlessui-react/src/components/checkbox/checkbox.tsx b/packages/@headlessui-react/src/components/checkbox/checkbox.tsx
index 1c179ecc83..a8d743ac07 100644
--- a/packages/@headlessui-react/src/components/checkbox/checkbox.tsx
+++ b/packages/@headlessui-react/src/components/checkbox/checkbox.tsx
@@ -174,7 +174,8 @@ function CheckboxFn
diff --git a/packages/@headlessui-react/src/components/radio-group/radio-group.tsx b/packages/@headlessui-react/src/components/radio-group/radio-group.tsx
index 93fce6fa2a..3585106600 100644
--- a/packages/@headlessui-react/src/components/radio-group/radio-group.tsx
+++ b/packages/@headlessui-react/src/components/radio-group/radio-group.tsx
@@ -315,7 +315,8 @@ function RadioGroupFn
diff --git a/packages/@headlessui-react/src/components/switch/switch.tsx b/packages/@headlessui-react/src/components/switch/switch.tsx
index 56b6c7b0bb..45cc4a3fc7 100644
--- a/packages/@headlessui-react/src/components/switch/switch.tsx
+++ b/packages/@headlessui-react/src/components/switch/switch.tsx
@@ -240,7 +240,8 @@ function SwitchFn(
{name != null && (
diff --git a/packages/@headlessui-react/src/internal/form-fields.tsx b/packages/@headlessui-react/src/internal/form-fields.tsx
index ab94d98772..d0d960c088 100644
--- a/packages/@headlessui-react/src/internal/form-fields.tsx
+++ b/packages/@headlessui-react/src/internal/form-fields.tsx
@@ -33,8 +33,10 @@ export function FormFields({
form: formId,
disabled,
onReset,
+ overrides,
}: {
data: Record
+ overrides?: Record
form?: string
disabled?: boolean
onReset?: (e: Event) => void
@@ -66,6 +68,7 @@ export function FormFields({
disabled,
name,
value,
+ ...overrides,
})}
/>
)