Skip to content

Conversation

@Adebesin-Cell
Copy link

🎯 Changes

Add Chakra UI integration guide to the TanStack Form UI libraries documentation. This addition covers both composable and pre-composed Checkbox components, providing developers with clear examples for integrating Chakra UI with TanStack Form.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

…umentation

Add comprehensive Chakra UI integration examples to the UI libraries guide,
covering both composable (Checkbox.Root) and pre-composed Checkbox components.
Includes code examples demonstrating how to integrate Chakra UI's Input and
Checkbox components with TanStack Form's Field component, maintaining
consistency with existing Mantine, Material UI, and shadcn/ui examples.
@changeset-bot
Copy link

changeset-bot bot commented Dec 6, 2025

⚠️ No Changeset found

Latest commit: 987ae17

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Adebesin-Cell Adebesin-Cell changed the title Docs: Add Chakra UI integration guide docs(react-form): Add Chakra UI integration guide Dec 7, 2025
@Adebesin-Cell Adebesin-Cell changed the title docs(react-form): Add Chakra UI integration guide docs(react-form): add Chakra UI integration guide Dec 7, 2025
Copy link
Contributor

@LeCarbonator LeCarbonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I only have a small nitpick, though it’s possible it simply has to be done this way. Let me know, or feel free to adjust the snippets, and I’ll merge it in.

Thanks for the addition!

children={({ state, handleChange, handleBlur }) => (
<Checkbox.Root
checked={state.value}
onCheckedChange={(details) => handleChange(!!details.checked)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This double negation seems weird for a (seemingly) boolean property. Is this accidental?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @LeCarbonator, thanks for pointing that out!

The double negation (!!) here is intentional. In Chakra v3, the Checkbox’s onCheckedChange provides a CheckedChangeDetails object where checked is typed as:

type CheckedState = boolean | "indeterminate";
interface CheckedChangeDetails {
    checked: CheckedState;
}

Our form state (state.value) expects a strict boolean, so passing details.checked directly would cause this TypeScript error:

Argument of type 'CheckedState' is not assignable to parameter of type 'SetStateAction<boolean>'.
  Type '"indeterminate"' is not assignable to type 'SetStateAction<boolean>'.

Using !!details.checked ensures the value is always a boolean (true for checked, false for unchecked or indeterminate), which satisfies the type checker and avoids runtime issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see ... Is this common knowledge for Chakra users, or do you think a comment explaining this would help at that line?

// coerce 'indeterminate' to false

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍

This behavior is documented in the Chakra docs and shown in examples for controlled state and indeterminate checkboxes:

So it should be familiar to Chakra users, but I agree it’s not immediately obvious why the coercion is needed when reading the snippet.

Adding a small comment like you mentioned:

// coerce 'indeterminate' to false

would help clarify the intent. I’m happy to add it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LeCarbonator, I added a line in docs, I hope that helps: e6a7908 (#1909)

children={({ state, handleChange, handleBlur }) => (
<Checkbox
checked={state.value}
onCheckedChange={(details) => handleChange(!!details.checked)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants