You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(react-form): add Chakra UI integration guide (#1909)
* docs(react-form): add Chakra UI integration guide to ui-libraries documentation
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.
* docs: Update Chakra UI Checkbox example in UI libraries guide
Copy file name to clipboardExpand all lines: docs/framework/react/guides/ui-libraries.md
+60-4Lines changed: 60 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,15 @@ title: UI Libraries
5
5
6
6
## Usage of TanStack Form with UI Libraries
7
7
8
-
TanStack Form is a headless library, offering you complete flexibility to style it as you see fit. It's compatible with a wide range of UI libraries, including `Tailwind`, `Material UI`, `Mantine`, `shadcn/ui`, or even plain CSS.
8
+
TanStack Form is a headless library, offering you complete flexibility to style it as you see fit. It's compatible with a wide range of UI libraries, including `Chakra UI`, `Tailwind`, `Material UI`, `Mantine`, `shadcn/ui`, or even plain CSS.
9
9
10
-
This guide focuses on `Material UI`, `Mantine`, and `shadcn/ui`, but the concepts are applicable to any UI library of your choice.
10
+
This guide focuses on `Chakra UI`, `Material UI`, `Mantine`, and `shadcn/ui`, but the concepts are applicable to any UI library of your choice.
11
11
12
12
### Prerequisites
13
13
14
14
Before integrating TanStack Form with a UI library, ensure the necessary dependencies are installed in your project:
15
15
16
+
- For `Chakra UI`, follow the installation instructions on their [official site](https://chakra-ui.com/docs/get-started/installation)
16
17
- For `Material UI`, follow the installation instructions on their [official site](https://mui.com/material-ui/getting-started/).
17
18
- For `Mantine`, refer to their [documentation](https://mantine.dev/).
18
19
- For `shadcn/ui`, refer to their [official site](https://ui.shadcn.com/).
@@ -153,8 +154,63 @@ The process for integrating shadcn/ui components is similar. Here's an example u
153
154
/>
154
155
```
155
156
156
-
- The integration approach is the same as with Mantine and Material UI.
157
+
- The integration approach is the same as with Mantine, Material UI.
157
158
- The primary difference lies in the specific shadcn/ui component properties and styling options.
158
159
- Note the onCheckedChange property of Checkbox instead of onChange.
159
160
160
-
The ShadCN library includes a dedicated guide covering common scenarios for integrating TanStack Form with its components: https://ui.shadcn.com/docs/forms/tanstack-form
161
+
The ShadCN library includes a dedicated guide covering common scenarios for integrating TanStack Form with its components: [https://ui.shadcn.com/docs/forms/tanstack-form](https://ui.shadcn.com/docs/forms/tanstack-form)
162
+
163
+
### Usage with Chakra UI
164
+
165
+
The process for integrating Chakra UI components is similar. Here's an example using Input and Checkbox from Chakra UI:
- The integration approach is the same as with Mantine, Material UI, and shadcn/ui.
196
+
- Chakra UI exposes its Checkbox as a composable component with separate `Checkbox.Root`, `Checkbox.Control`, `Checkbox.Label`, and `Checkbox.HiddenInput` parts that you wire together.
197
+
- The double negation `!!` is used on `onCheckedChange` to coerce Chakra's `"indeterminate"` state to a boolean, ensuring it matches the form state. See the [Chakra UI Checkbox documentation](https://chakra-ui.com/docs/components/checkbox#indeterminate) for more details.
198
+
- Alternatively, Chakra UI offers a pre-composed Checkbox component that works the same way as their standard examples, without requiring manual composition. You can learn more about this closed component approach in the [Chakra UI Checkbox documentation](https://chakra-ui.com/docs/components/checkbox#closed-component).
199
+
- The TanStack Form integration works identically with either approach—simply attach the `checked`, `onCheckedChange`, and `onBlur` handlers to your chosen component.
0 commit comments