-
-
Notifications
You must be signed in to change notification settings - Fork 272
[docs] Add Form integration page
#2989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
commit: |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
a1de574 to
8d56a2e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
8d56a2e to
3215d45
Compare
|
4d6c5f6 to
5e47c6c
Compare
|
|
||
| ## TanStack Form | ||
|
|
||
| [TanStack Form](https://tanstack.com/form/v1/docs/overview) is a form library with a function-based API for orchestrating validations that can also be integrated with Base UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about linking to the latest doc?
Or do we want to ensure the stability of the example if following majors bring significant BCs?
| [TanStack Form](https://tanstack.com/form/v1/docs/overview) is a form library with a function-based API for orchestrating validations that can also be integrated with Base UI. | |
| [TanStack Form](https://tanstack.com/form/latest/docs/overview) is a form library with a function-based API for orchestrating validations that can also be integrated with Base UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think v1 is good for now... I'm sure v2 will have some big changes
|
|
||
| Base UI also supports [TanStack Form](https://tanstack.com/form/v1/docs/overview), which uses a function-based API to orchestrate validations. | ||
|
|
||
| import { DemoTanstackForm } from './demos/tanstack-form'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, gotcha. 👍
Then, it's only the section headings left, and even those could be left for a follow-up if they need unrelated internal changes. 👌
|
Can you add an example of react-hook-form + zod? |
|
|
||
| import { DemoBaseUIForm } from './demos/hero'; | ||
|
|
||
| <DemoBaseUIForm showExtraPlaygroundLink /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select trigger's and radio group's outline is 1px, not 2px like the other controls
| export function Root({ className, ...props }: Checkbox.Root.Props) { | ||
| return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checkbox example used (Backup schedule) seems like a radio group not a checkbox group. Maybe another example can be used to demonstrate checkboxes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (text === 'React Hook Form' || text === 'TanStack Form') { | ||
| node.properties.id = `${stringToUrl(text)}-${stringToUrl(toString(node))}`; | ||
| break; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered going for a similar approach to Material docs, where a repeated hash is prepended with -N as in #initialize-the-form and #initialize-the-form-2 in the TanStack Forms case?
The other alternative (my biggest preference) would be to join hashes of nested headings.
Yes, that would break currently existing links in the wild, but I wager that the price to pay is not that high compared to piece of mind we'd get. 🙈 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other alternative (my biggest preference) would be to join hashes of nested headings
Yeah I think this is better than adding -N as it's more readable, but maybe it's enough to do it selectively like with this file? The other common h2s (Examples, API reference) are much more unlikely to have duplicate heading text
that would break currently existing links in the wild
We'd just have to maintain redirects like this for a very long time 😅 https://github.com/mui/material-ui/blob/master/docs/public/_redirects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no objections to going with the simple solution. 👍
We can consider abstracting it if we need to tweak this place the 3rd or 4th time. 👌
Will add schema validation related stuff in a separate PR ~ |

Preview: https://deploy-preview-2989--base-ui.netlify.app/react/handbook/forms
Added a doc on how to build forms with plain Base UI and guides for React Hook Form and TanStack Form.
Also on the pages of each labelable control, added a bullet point about accessible name and linked to the new doc, it seems more space-efficient than repeating a whole snippet or demo (e.g. like Headless UI or RA).
Only added Tailwind demos, was thinking to not have CSS modules since styling is not the focus of the doc and the styling is already obscured a bit in the demos already.
Closes #21